Abstract canvas system that provides different rendering backends: - AsciiCanvas: Basic ASCII characters (*, -, |, +) - BrailleCanvas: Unicode Braille patterns (2x4 dots per cell = 8x resolution) - BlockCanvas: Unicode block elements (half-blocks for 2x vertical resolution)
widthCharacter width of the canvas
heightCharacter height of the canvas
pixel_widthPixel width (may be higher than char width for Braille/Block)
pixel_heightPixel height (may be higher than char height for Braille/Block)
matrixCharacter matrix for rendering
color_matrixParallel matrix tracking colors per cell
x_multHorizontal multiplier (pixels per character)
y_multVertical multiplier (pixels per character)
new()Initialize the canvas
Canvas$new(width, height)widthCharacter width
heightCharacter height
set_pixel()Set a pixel at the given coordinates
Canvas$set_pixel(x, y, color = NULL)xX coordinate (1-based, in pixel space)
yY coordinate (1-based, in pixel space, 1 = top)
colorOptional color name
draw_line()Draw a line between two points
Canvas$draw_line(x0, y0, x1, y1, color = NULL)x0Start X coordinate
y0Start Y coordinate
x1End X coordinate
y1End Y coordinate
colorOptional color name
draw_polyline()Draw multiple connected line segments
Canvas$draw_polyline(xs, ys, color = NULL)xsVector of X coordinates
ysVector of Y coordinates
colorOptional color name
draw_points()Draw points (scatter)
Canvas$draw_points(xs, ys, color = NULL)xsVector of X coordinates
ysVector of Y coordinates
colorOptional color name
fill_rect()Fill a rectangle
Canvas$fill_rect(x0, y0, x1, y1, color = NULL)x0Left X coordinate
y0Top Y coordinate
x1Right X coordinate
y1Bottom Y coordinate
colorOptional color name
fill_bar()Fill a vertical bar from bottom up to a height
Canvas$fill_bar(x, height, bar_width = 2, color = NULL)xX coordinate (center of bar in pixel space)
heightHeight in pixels from bottom
bar_widthWidth of bar in pixels (default 2)
colorOptional color name
draw_text()Place text at a position
Canvas$draw_text(x, y, text, color = NULL)xX coordinate (character position)
yY coordinate (character position)
textText string to place
colorOptional color name
apply_colors()Apply colors to the matrix
Canvas$apply_colors()Matrix with ANSI color codes applied
render()Get the rendered matrix (with colors)
Canvas$render()Character matrix
clear()Clear the canvas
Canvas$clear()
draw_rect()Draw a rectangle outline
Canvas$draw_rect(x0, y0, x1, y1, color = NULL)x0Left X coordinate (pixel space)
y0Top Y coordinate (pixel space)
x1Right X coordinate (pixel space)
y1Bottom Y coordinate (pixel space)
colorOptional color name
fill_area()Fill an area between a polyline and the bottom
Canvas$fill_area(xs, ys, color = NULL)xsVector of X coordinates
ysVector of Y coordinates
colorOptional color name
draw_segment()Draw a segment (line with optional arrowhead)
Canvas$draw_segment(x0, y0, x1, y1, arrow_end = FALSE, color = NULL)x0Start X coordinate
y0Start Y coordinate
x1End X coordinate
y1End Y coordinate
arrow_endAdd arrowhead at end (default FALSE)
colorOptional color name
draw_hline()Draw a horizontal line
Canvas$draw_hline(y, x0 = 1, x1 = NULL, color = NULL)yY coordinate
x0Start X (default 1)
x1End X (default pixel_width)
colorOptional color name
draw_vline()Draw a vertical line
Canvas$draw_vline(x, y0 = 1, y1 = NULL, color = NULL)xX coordinate
y0Start Y (default 1)
y1End Y (default pixel_height)
colorOptional color name
draw_circle()Draw a circle outline
Canvas$draw_circle(cx, cy, r, color = NULL)cxCenter X coordinate
cyCenter Y coordinate
rRadius in pixels
colorOptional color name
fill_circle()Fill a circle
Canvas$fill_circle(cx, cy, r, color = NULL)cxCenter X coordinate
cyCenter Y coordinate
rRadius in pixels
colorOptional color name
draw_polygon()Draw a polygon outline
Canvas$draw_polygon(xs, ys, closed = TRUE, color = NULL)xsVector of X coordinates
ysVector of Y coordinates
closedWhether to close the polygon (default TRUE)
colorOptional color name
clone()The objects of this class are cloneable with this method.
Canvas$clone(deep = FALSE)deepWhether to make a deep clone.
Abstract base class for all canvas types. Provides the interface that all canvas implementations must follow.