class

Tryst::Vector::Context

Inherits Reference < Object

Yielded to Surface#draw - the drawing vocabulary for one frame.

Every shape a Context creates gets the Surface's own HiDPI scale applied via tvg_paint_scale before anything else touches it, so coordinates passed to #rect/#rounded_rect/#circle are always logical pixels (matching the Surface's own width/height), never device pixels - a #draw block is written once and looks right at any scale.

Constructors

new(canvas : LibThorVG::Canvas, scale : Float64)

@api private - only Surface builds these, one per #draw call.

Source

Instance methods

arc(cx : Float64, cy : Float64, r : Float64, start_deg : Float64, sweep_deg : Float64) : Shape

A stroked circular arc - the one primitive here with no fill concept, since a partial ring only makes sense as an outline (a filled version would be a pie slice; #polygon can already build that shape directly if something needs it later). Internally sets a fully transparent fill regardless of what a caller does afterward, since ThorVG has no "unset" fill state - only ever a color - and this shape's own path is deliberately never closed, so an opaque default fill would render as a solid pie slice behind the stroke.

start_deg/sweep_deg: 0 degrees is 12 o'clock, positive sweeps clockwise (screen coordinates - y grows downward) - the convention a progress ring or spinner is actually thought about in, not math's usual 0=east/counterclockwise. A negative sweep_deg sweeps counterclockwise from start_deg.

ThorVG has no native arc path command (see bindings/core.cr's own comment on tvg_shape_cubic_to), so this builds one as a sequence of cubic Bezier segments, each capped at 90 degrees - the standard circular-arc-as-Bezier construction, accurate to a small fraction of a pixel at any spinner/progress-ring radius this project draws at.

Source
circle(cx : Float64, cy : Float64, r : Float64) : Shape
Source
polygon(points : Array(Tuple(Float64, Float64))) : Shape

An arbitrary closed straight-edged shape from its own vertices - e.g. a tooltip's pointer arrow, which none of #rect/#rounded_rect/ #circle can produce. Needs at least 3 points; raises otherwise rather than handing ThorVG a degenerate path.

Source
rect(x : Float64, y : Float64, w : Float64, h : Float64) : Shape
Source
rounded_rect(x : Float64, y : Float64, w : Float64, h : Float64, rx : Float64, ry : Float64 = rx) : Shape

rx/ry default to the same value - a uniform corner radius is the common case, and Tk's own -cornerradius-flavored options follow the same one-arg-usually shorthand.

Source