class

Egui::Canvas

Inherits Egui::Widget < Reference < Object

Constructors

new(id : String, width : Int32, height : Int32, fill : Color32 = Color32.new(255, 255, 255))
Source

Instance methods

[](x : Int32, y : Int32) : Color32
Source
[]=(x : Int32, y : Int32, color : Color32) : Nil

Solid write (alpha overwrite); out-of-bounds writes are ignored.

Source
blend(x : Int32, y : Int32, color : Color32, cov : Int32) : Nil

Coverage blend: cov in 0..255 multiplies the incoming color's alpha (antialiased glyph rendering).

Source
blit(x : Int32, y : Int32, data : Bytes, w : Int32, h : Int32, transparent_color : Color32 | Nil = nil) : Nil

Blit an RGBA8 w×h buffer at (x, y). transparent_color skips matching pixels (Paint's transparent-selection mode).

Source
brush_line(x0 : Int32, y0 : Int32, x1 : Int32, y1 : Int32, size : Int32, shape : Symbol, color : Color32) : Nil

Freehand stroke through an already-stamped dab trail is just repeated #line calls in the app; brushes with round/diagonal stamps use this segmented variant.

Source
destroy_texture(ctx : Context) : Nil

Release the GPU texture (app shutdown / canvas replacement).

Source
dirty?
Source
ellipse_fill(x : Int32, y : Int32, w : Int32, h : Int32, color : Color32) : Nil
Source
ellipse_outline(x : Int32, y : Int32, w : Int32, h : Int32, color : Color32, width : Int32 = 1) : Nil

Ellipse inscribed in the bounding rect (x, y, w, h). Midpoint algorithm (both quadrant pairs), every boundary pixel stamped for width thickness.

Source
erase_region(x : Int32, y : Int32, w : Int32, h : Int32, color : Color32) : Nil

Erase a w×h region down to one color (selection lift/cut).

Source
fill_with(color : Color32) : Nil
Source
flood_fill(x : Int32, y : Int32, color : Color32) : Nil

Scanline flood fill (4-connected, exact color match).

Source
flush(ctx : Context) : Nil

Upload pending pixels NOW (show/flush otherwise catch it a frame later) — call after this frame's tool processing. Skipped when the buffer was resized after the texture (post-#show #resize): the stale texture gets wrong-size data — #ensure_texture recreates it on the next #show, and a same-frame second update is a sokol validation error (one sg_update_image per image per frame).

Source
height
Source
inside?(x : Int32, y : Int32) : Bool
Source
inspector_label

Short human label for the inspector (the button's text, a label's text…); nil = no meaningful label.

Source
invert

RGB inversion of the whole canvas (Paint: Image → Invert Colors).

Source
line(x0 : Int32, y0 : Int32, x1 : Int32, y1 : Int32, color : Color32, width : Int32 = 1) : Nil

Bresenham line stamped with a square brush width px across.

Source
mark_dirty
Source
pixels

The raw RGBA8 buffer (top-down, stride width*4). Read-only use; mutations through this reference bypass the dirty flag — call #mark_dirty after writing.

Source
rect_fill(x : Int32, y : Int32, w : Int32, h : Int32, color : Color32) : Nil
Source
rect_outline(x : Int32, y : Int32, w : Int32, h : Int32, color : Color32, width : Int32 = 1) : Nil

Outline of width device pixels, drawn inside the rect.

Source
region(x : Int32, y : Int32, w : Int32, h : Int32) : Bytes

Copy a w×h region out (RGBA8); out-of-bounds areas read as transparent black.

Source
replace_pixels(data : Bytes) : Nil

Replace the whole buffer (must be widthheight4 bytes, RGBA8).

Source
resize(width : Int32, height : Int32, fill : Color32 = Color32.new(255, 255, 255)) : Nil

New dimensions; content is NOT preserved (call #snapshot/#restore around it when needed). The GPU texture is recreated lazily on the next #show.

Source
restore(data : Bytes) : Nil
Source
restore_sized(w : Int32, h : Int32, data : Bytes) : Nil

Undo across resizes: a snapshot from a different canvas size resizes the canvas back and then restores the pixels.

Source
scale

Zoom: screen pixels per canvas pixel (integer, ≥ 1).

Source
scale=(scale : Int32)

Zoom: screen pixels per canvas pixel (integer, ≥ 1).

Source
show(ui : Ui) : Interaction

Allocate, interact, paint. Returns this frame's Interaction.

Source
snapshot
Source
span(x0 : Int32, x1 : Int32, y : Int32, color : Color32) : Nil

Horizontal span, inclusive of both ends.

Source
stamp(x : Int32, y : Int32, size : Int32, shape : Symbol, color : Color32) : Nil

One brush dab centered on (x, y): shape is :square, :circle, :fslash (╲) or :bslash (╱); size is the full diameter.

Source
texture_id
Source
ui(ui : Ui) : Response
Source
width
Source

Nested types