generative-art-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Geometry.Shapes

Description

Predefined shapes.

Synopsis

Documentation

:: [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)

Expand
>>> :{
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)

Expand
>>> :{
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

spiralPolygon Source #

Arguments

:: Int

Winding number

-> Double

Width

-> Polygon 

Rectangular spiral. Useful as an example for very much non-convex polygons. PolygonPositive orientation.

(image code)

Expand
>>> :{
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