Drawing

The shapes a drawing call takes, and the interface a UI package draws through.

Everything here is a plain record or tag union. Draw re-exports these, so an app writes Draw.filled(Color.white) and never names this module. A package that renders widgets does name it: Drawable is the set of calls such a package needs from whatever frame it is handed, so the package can be written once and used with any frame that offers them -- the platform's Draw.Frame, or a recording frame a test supplies.

Fill : [NoFill, Fill(Rgba)]

Whether a shape's interior is painted, and in what color.

Stroke : [NoStroke, Stroke({ color : Rgba, thickness : F32 })]

Whether a shape's outline is painted, in what color, and how thick.

ShapeStyle : { fill : Fill, stroke : Stroke }

A shape's interior and outline together. Draw.filled, Draw.outlined and Draw.filled_and_outlined build the usual three.

Rectangle : { x : F32, y : F32, width : F32, height : F32, style : ShapeStyle }

An axis-aligned rectangle and the style to paint it with, as Draw.rectangle! takes it.

RoundedRectangle : { x : F32, y : F32, width : F32, height : F32, radius : F32, segments : I32, style : ShapeStyle }

A rectangle with rounded corners. radius is the corner radius in the same units as the size, and segments is how many line segments approximate each corner arc.

HAlign : [Left, Center, Right]

Which horizontal edge or center of a text box pos refers to.

VAlign : [Top, Middle, Bottom]

Which vertical edge or center of a text box pos refers to.

TextAlign : { horizontal : HAlign, vertical : VAlign }

Where pos sits within the text it places, in both axes at once.

Text : { pos : Vec2, text : Str, size : F32, spacing : F32, color : Rgba, font : Font, align : TextAlign }

A string, where to put it, and how to paint it.

TextureDraw : { texture : Texture, source : Rect, dest : Rect, origin : Vec2, rotation : F32, tint : Rgba }

One textured quad: which part of the texture to read (source), where to put it (dest), the point within dest that rotation turns around (origin), and the color the sample is multiplied by (tint).