markersKit.draw — small, pure drawing helpers every style shares.
local D = require("~.draw")
local pen = D.pen("#ffffff", 2) -- colour, stroke width
pen:line(10, 20, 10, 30); pen:circle(20, 20, 8); pen:dot(20, 20, 2)
local node = D.svgNode(pen:svg(40), cx - 20, cy - 20, 40)
Every stroke is drawn twice, a dark outline under the colour, so a
crosshair or a marker stays readable over a bright sky or a dark pit.
f(n: number) → string
| arg | type | description |
|---|
| n | number | |
box(style: any, children: { any }?) → any
| arg | type | description |
|---|
| style | any | |
| children | { any }? | |
row(style: any, children: { any }?) → any
| arg | type | description |
|---|
| style | any | |
| children | { any }? | |
label(text: string, style: any) → any
| arg | type | description |
|---|
| text | string | |
| style | any | |
svgNode(svg: string, x: number, y: number, w: number, h: number?, extra: any?) → any
An absolutely placed svg node of size w x h (h defaults to w) with its top-left at x, y.
| arg | type | description |
|---|
| svg | string | |
| x | number | |
| y | number | |
| w | number | |
| h | number? | |
| extra | any? | |
rgb(hex: string?) → void
"#rrggbb" (or "#rgb") to r, g, b in 0..255. Bad input gives white.
| arg | type | description |
|---|
| hex | string? | |
rgba(hex: string?, a: number) → string
A hex colour as an rgba() string with alpha a.
| arg | type | description |
|---|
| hex | string? | |
| a | number | |
isColor(v: any) → boolean
Is this a usable "#rgb" / "#rrggbb" colour?
mix(a: string, b: string, t: number) → string
Mix two hex colours (t = 0 gives a, 1 gives b).
| arg | type | description |
|---|
| a | string | |
| b | string | |
| t | number | |
ease(x: number) → number
| arg | type | description |
|---|
| x | number | |
easeBack(x: number) → number
| arg | type | description |
|---|
| x | number | |
pen(color: string, width: number, opts: any?) → any
A pen that collects shapes and writes them as one outlined svg. opts: { outline = "#000", outlineAlpha = 0.65, cap = "round", glow = false }.
| arg | type | description |
|---|
| color | string | |
| width | number | |
| opts | any? | |
line(self: any, x1: number, y1: number, x2: number, y2: number) → void
| arg | type | description |
|---|
| self | any | |
| x1 | number | |
| y1 | number | |
| x2 | number | |
| y2 | number | |
circle(self: any, cx: number, cy: number, r: number) → void
| arg | type | description |
|---|
| self | any | |
| cx | number | |
| cy | number | |
| r | number | |
path(self: any, d: string) → void
| arg | type | description |
|---|
| self | any | |
| d | string | |
poly(self: any, pts: { number }, closed: boolean?) → void
| arg | type | description |
|---|
| self | any | |
| pts | { number } | |
| closed | boolean? | |
arc(self: any, cx: number, cy: number, r: number, a0: number, a1: number) → void
An arc of the circle (cx, cy, r) from angle a0 to a1 in degrees (0 = up, clockwise).
| arg | type | description |
|---|
| self | any | |
| cx | number | |
| cy | number | |
| r | number | |
| a0 | number | |
| a1 | number | |
dot(self: any, cx: number, cy: number, r: number) → void
| arg | type | description |
|---|
| self | any | |
| cx | number | |
| cy | number | |
| r | number | |
rect(self: any, x: number, y: number, w: number, h: number) → void
| arg | type | description |
|---|
| self | any | |
| x | number | |
| y | number | |
| w | number | |
| h | number | |
fillPoly(self: any, pts: { number }) → void
| arg | type | description |
|---|
| self | any | |
| pts | { number } | |
raw(self: any, s: string) → void
Raw svg markup drawn on top, as-is.
| arg | type | description |
|---|
| self | any | |
| s | string | |
svg(self: any, w: number, h: number?) → string
The pen's shapes as a complete svg string of size w x h (h defaults to w).
| arg | type | description |
|---|
| self | any | |
| w | number | |
| h | number? | |
arcPath(cx: number, cy: number, r: number, a0: number, a1: number) → string
An svg arc path on circle (cx, cy, r) from a0 to a1 degrees (0 = up, clockwise).
| arg | type | description |
|---|
| cx | number | |
| cy | number | |
| r | number | |
| a0 | number | |
| a1 | number | |
pt(a: number) → void
| arg | type | description |
|---|
| a | number | |
pixelSvg(text: string, u: number, color: string, opts: any?) → void
Pixel-art text as svg. u = size of one pixel in points. Returns svg, width, height.
| arg | type | description |
|---|
| text | string | |
| u | number | |
| color | string | |
| opts | any? | |
pixelText(text: string, u: number, color: string, opts: any?) → any
Pixel-art text as a (non-absolute) svg node sized to fit.
| arg | type | description |
|---|
| text | string | |
| u | number | |
| color | string | |
| opts | any? | |
num(n: number) → string
A whole number as text with thousands separators: 12345 -> "12,345".
| arg | type | description |
|---|
| n | number | |
hash(n: number) → number
A tiny deterministic noise for shakes and scatter: same seed, same wobble.
| arg | type | description |
|---|
| n | number | |