Primitive (line, rectangle and circle) patterns.
This module provides convenience functions for the generation of basic pattern shapes. So far including lines, squares/rectangles and circle rasters.
-- Draw some squares local square_pattern = primitives.square(5) -- 5x5 local rectangle_pattern = primitives.square(3,5) -- 3x5 -- Draw a line local line = primitives.line(cell.new(0,0), cell.new(10,10)) -- Draw a circle about (0,0) with radius 5 local circle = primitives.circle(5)
|square (x, y)||Generate a square pattern.|
|line (start, finish)||Generate a line pattern.|
|quad_bezier (start, control, finish, N)||Draw a quadratic bezier curve.|
|circle (r)||Generate a circle pattern.|
- square (x, y)
Generate a square pattern.
- x size in x
size in y (default
y = x)
square forma.pattern of size
- line (start, finish)
Generate a line pattern.
According to Bresenham's line algorithm.
- start a forma.cell denoting the start of the line
- finish a forma.cell denoting the end of the line
a pattern consisting of a line between
- quad_bezier (start, control, finish, N)
Draw a quadratic bezier curve.
Uses an algorithm from rosettacode.org.
This function returns both a pattern consisting of the drawn bezier curve,
and a list of points along the curve. This may be important in case the
curve back-tracks over existing cells, which cannot be represented in a
forma pattern. The full pattern consists of
Nof these points, joined by bresenham line segments.
- start a forma.cell denoting the start of the curve
- control a forma.cell denoting the control point of the curve
- finish a forma.cell denoting the end of the curve
- N (optional) number of line-segments to construct the curve with
a pattern consisting of a bezier curve between
finish, controlled by
- an ordered list of cells consisting of points along the curve.
- circle (r)
Generate a circle pattern.
- r the radius of the circle to be drawn
circular forma.pattern of radius