Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Predefined shapes.
Synopsis
- haskellLogo :: [Polygon]
- regularPolygon :: Int -> Polygon
- spiralPolygon :: Int -> Double -> Polygon
Documentation
haskellLogo :: [Polygon] Source #
Haskell logo, in the order [left, lambda, upper dash, lower dash]
.
The logo is scaled so that the height of the logo is 1
.
Each polygon starts at the bottom/left corner in screen coordinates (i.e.
(0,0)
is at the top right, x extends to the right, and y extends
downwards).
The orientation is in mathematically positive direction, i.e. clockwise in screen coordinates.
(image code)
>>>
:{
haddockRender "Geometry/Shapes/haskell_logo.svg" 130 100 $ \_ -> do coordinateSystem CairoStandard_ZeroTopLeft_XRight_YDown for_ haskellLogo $ \polygon -> do sketch (transform (translate (Vec2 10 10) <> scale 80) polygon) C.stroke :} Generated file: size 3KB, crc32: 0x98aab3be
>>>
all (\polygon -> polygonOrientation polygon == PolygonPositive) haskellLogo
True
regularPolygon :: Int -> Polygon Source #
Regular n-gon with radius 1, oriented PolygonPositive
,
and starting with the first corner on the positive x axis.
(image code)
>>>
:{
haddockRender "Geometry/Shapes/regular_pentagon.svg" 100 100 $ \_ -> do let polygon = transform (translate (Vec2 50 50) <> scale 45) (regularPolygon 5) sketch polygon C.stroke :} Generated file: size 2KB, crc32: 0x43d94b0e
>>>
polygonOrientation (regularPolygon 5) == PolygonPositive
True
Rectangular spiral. Useful as an example for very much non-convex polygons. PolygonPositive
orientation.
(image code)
>>>
:{
haddockRender "Geometry/Shapes/spiral_polygon.svg" 100 100 $ \_ -> do coordinateSystem (MathStandard_ZeroCenter_XRight_YUp 100 100) let polygon = spiralPolygon 8 10 sketch polygon C.stroke :} Generated file: size 2KB, crc32: 0x7b879da5
>>>
polygonOrientation (spiralPolygon 8 10) == PolygonPositive
True