module

CRT::Ansi::Canvas

Shared drawing interface for Render and Viewport.

Provides the common API: put, write, clear, cell, box, panel, and blit. Includers implement the abstract methods; the concrete methods build on them.

Instance methods

blit(source : Canvas, *, x : Int, y : Int, w : Int, h : Int, scroll_x : Int = 0, scroll_y : Int = 0) : Nil

Copy a visible window from a source canvas onto this one.

  • x, y — destination position on this canvas
  • w, h — size of the visible window
  • scroll_x, scroll_y — offset into the source
Source
box(x : Int, y : Int, *, w : Int = 0, h : Int = 0, style : Style = default_style, border : Border = Border::Single, fill : Style | Style::Char | Nil = nil) : Nil

Draw a box, horizontal line, or vertical line.

  • w > 0 and h > 0: bordered box (w wide, h tall, inclusive)
  • w > 0 and h == 0: horizontal line of length w
  • w == 0 and h > 0: vertical line of length h
Source
cell(x : Int, y : Int) : Cell
Source
clear(style : Style) : Nil
Source
default_style
Source
height
Source
panel(x : Int, y : Int, *, w : Int, h : Int) : Panel

Returns a Panel builder for fluid drawing within a region.

Source
put(x : Int, y : Int, grapheme : String, style : Style) : Nil
Source
width
Source
write(x : Int, y : Int, text : String, style : Style) : Int32
Source