waterfall-cad 0.5.1.0 → 0.5.1.1
raw patch · 4 files changed
+42/−4 lines, 4 filesdep ~opencascade-hsPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: opencascade-hs
API changes (from Hackage documentation)
+ Waterfall.TwoD.Shape: unitPolygon :: Integer -> Shape
Files
- CHANGELOG.md +6/−0
- README.md +15/−0
- src/Waterfall/TwoD/Shape.hs +19/−2
- waterfall-cad.cabal +2/−2
CHANGELOG.md view
@@ -9,6 +9,12 @@ ## Unreleased +## 0.5.1.1++### Added ++- Added `unitPolygon`+ ## 0.5.1.0 ### Added
README.md view
@@ -17,3 +17,18 @@ There are examples of how to use the library in [waterfall-cad-examples](https://hackage.haskell.org/package/waterfall-cad-examples). You can see images of these examples in the [main readme](https://github.com/joe-warren/opencascade-hs/#examples) on Github.++## Imports ++This library is recommended to used by importing the root `Waterfall` module, qualified, which includes the entire public API.+You'll also almost certainly need to import [`Linear`](https://hackage.haskell.org/package/linear), in my experience this is best imported unqualified, e.g:++```haskell+import qualified Waterfall+import Linear+```++It should also be possible to import the library unqualified, or to import the individual modules.++The examples use qualified imports from the individual modules, in order to communicate the module structure.+However this can be a little tedious for regular use.
src/Waterfall/TwoD/Shape.hs view
@@ -5,17 +5,18 @@ , unitCircle , unitSquare , centeredSquare+, unitPolygon ) where import Waterfall.TwoD.Internal.Shape (Shape (..)) import Waterfall.TwoD.Internal.Path2D (Path2D (..))-import Waterfall.TwoD.Transforms (translate2D)+import Waterfall.TwoD.Transforms (translate2D, rotate2D) import Waterfall.Internal.Finalizers (toAcquire, unsafeFromAcquire) import Waterfall.Internal.Edges (allWires) import qualified OpenCascade.BRepBuilderAPI.MakeFace as MakeFace import OpenCascade.Inheritance (upcast) import Linear (unit, _x, _y, zero, V2 (..))-import Waterfall.Path.Common (pathFrom, arcViaTo, lineTo)+import Waterfall.Path.Common (pathFrom, arcViaTo, lineTo, line) import Waterfall.Internal.Path.Common (RawPath(ComplexRawPath)) -- | Construct a 2D Shape from a closed path @@ -58,3 +59,19 @@ -- | Square with side length of 1, centered on the origin centeredSquare :: Shape centeredSquare = translate2D (V2 (-0.5) (-0.5)) unitSquare++-- | \(n\) sided Polygon, centered on the origin+-- +-- Ill-defined when n <= 2+unitPolygon :: Integer -> Shape+unitPolygon n = + let n' = fromIntegral n+ points = [+ rotate2D (2 * pi * fromIntegral i / n') (unit _x)+ | i <- [0..n]+ ]+ paths = mconcat [+ line a b+ | (a, b) <- zip points (tail points)+ ]+ in makeShape paths
waterfall-cad.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: waterfall-cad-version: 0.5.1.0+version: 0.5.1.1 synopsis: Declarative CAD/Solid Modeling Library description: Please see the README on GitHub at <https://github.com/joe-warren/opencascade-hs#readme> category: Graphics@@ -70,7 +70,7 @@ , lattices >=2.0 && <3 , lens ==5.* , linear >=1.21 && <2- , opencascade-hs >=0.5.1.0 && <0.6+ , opencascade-hs >=0.5.1.1 && <0.6 , primitive >=0.7 && <0.10 , resourcet >=1.2 && <1.4 default-language: Haskell2010