Rasterises lines, rectangles and circles into a FrenchCurve.Raster.
Every function takes a raster as its first argument and returns a new one, so calls
compose in a pipeline. Coordinates are integer pixels, {0, 0} at the top left, and may
fall outside the raster: the parts that land inside are drawn and the rest is clipped.
Colours are {r, g, b, a} byte tuples written opaquely, with no blending against what
is already there.
FrenchCurve.Raster.new(40, 20)
|> FrenchCurve.Draw.rect({0, 0}, {39, 19}, {80, 80, 80, 255})
|> FrenchCurve.Draw.fill_circle({20, 10}, 6, {255, 0, 0, 255})
Summary
Functions
Draws a one-pixel-wide circle outline of radius pixels around the centre {cx, cy}.
Fills a disc of radius pixels around the centre {cx, cy}.
Fills every pixel of the rectangle spanned by two opposite corners, edges included.
Draws a one-pixel-wide line between the two endpoints, both inclusive.
Draws a connected run of line segments through points in order.
Draws the four edges of the rectangle spanned by two opposite corners.
Types
Functions
@spec circle( FrenchCurve.Raster.t(), coord(), non_neg_integer(), FrenchCurve.Raster.color() ) :: FrenchCurve.Raster.t()
Draws a one-pixel-wide circle outline of radius pixels around the centre {cx, cy}.
radius must be a non-negative integer. The interior is untouched.
@spec fill_circle( FrenchCurve.Raster.t(), coord(), non_neg_integer(), FrenchCurve.Raster.color() ) :: FrenchCurve.Raster.t()
Fills a disc of radius pixels around the centre {cx, cy}.
radius must be a non-negative integer.
@spec fill_rect(FrenchCurve.Raster.t(), coord(), coord(), FrenchCurve.Raster.color()) :: FrenchCurve.Raster.t()
Fills every pixel of the rectangle spanned by two opposite corners, edges included.
Both corners are inclusive and may be given in any order.
@spec line(FrenchCurve.Raster.t(), coord(), coord(), FrenchCurve.Raster.color()) :: FrenchCurve.Raster.t()
Draws a one-pixel-wide line between the two endpoints, both inclusive.
Handles any direction, including purely horizontal, vertical and single-point lines.
@spec polyline(FrenchCurve.Raster.t(), [coord()], FrenchCurve.Raster.color()) :: FrenchCurve.Raster.t()
Draws a connected run of line segments through points in order.
A single point plots that pixel and an empty list leaves the raster unchanged. Points are not closed back to the first one; pass the first point again to close the shape.
@spec rect(FrenchCurve.Raster.t(), coord(), coord(), FrenchCurve.Raster.color()) :: FrenchCurve.Raster.t()
Draws the four edges of the rectangle spanned by two opposite corners.
Both corners are inclusive and may be given in any order. The interior is untouched.