Some examples to get you started with Patterning. You can try them yourself by copying the code below each example and pasting it into the Rose Engine editor.
Basic Polygon
(poly 0 0 0.7 5 {:stroke (p-color 0 255 0), :fill (p-color 150 150 255), :stroke-weight 4})
Five red triangles in a ring
Note the definition of style. A style is represented as a mapping with keyword keys. For example :
{:stroke (p-color 255 100 100) :stroke-weight 2 }
Commonly used entries are :stroke, :stroke-weight and :fill. :stroke and :fill are colours defined with (p-color r g b).
Now let's make a simple pattern.
(def triangles (clock-rotate 5 (poly 0.5 0.5 0.3 3 {:stroke (p-color 255 100 100) :stroke-weight 2 }) ) )
poly creates a regular polygon. Its arguments are x-centre, y-centre, radius, number-of-sides and, optionally, style.
clock-rotate is a Layout, a function which takes an existing pattern and returns a new one.
In this case, clock-rotate takes a number, n, and a pattern, and makes the new pattern by rotating n copies of the input around the centre point.
(clock-rotate 5 (poly 0.5 0.5 0.3 3 {:stroke (p-color 255 100 100), :stroke-weight 2}))
Stack the five triangles on a blue pentagon
(stack (poly 0 0 0.7 5 {:stroke (p-color 0 0 255), :stroke-weight 2}) (clock-rotate 5 (poly 0.5 0.5 0.3 3 {:stroke (p-color 255 100 100), :stroke-weight 2})))