class

UnicodePlot::Canvas

Inherits UnicodePlot::GraphicsArea < Reference < Object

Abstract pixel-based canvas. The grid is stored as a flat row-major array: index = row * ncols + col (0-based).

Constructors

new(nrows : Int32, ncols : Int32, visible : Bool, blend : Bool, yflip : Bool, xflip : Bool, pixel_height : Int32, pixel_width : Int32, origin_y : Float64, origin_x : Float64, height : Float64, width : Float64, yscale : Proc(Float64, Float64), xscale : Proc(Float64, Float64), fill_value : UInt32)
Source

Instance methods

annotate!(x : Float64, y : Float64, char : Char, color : UInt32, blend : Bool) : self

Annotate a character at canvas coords (x, y)

Source
annotate!(x : Float64, y : Float64, text : String, color : UInt32, blend : Bool, halign : Symbol = :center, valign : Symbol = :center) : self
Source
blank
Source
blend?
Source
char_point!(col : Int32, row : Int32, char : Char, color : UInt32, blend : Bool) : Nil
Source
color_at(row : Int32, col : Int32) : UInt32
Source
color_set!(row : Int32, col : Int32, color : UInt32) : Nil
Source
grid_at(row : Int32, col : Int32) : UInt32

Grid and color accessors (1-based row/col)

Source
grid_char_at(row : Int32, col : Int32) : Char

Map grid value to display character. Must be overridden by subclasses.

Source
grid_set!(row : Int32, col : Int32, val : UInt32) : Nil
Source
height
Source
lines!(x1 : Float64, y1 : Float64, x2 : Float64, y2 : Float64, color : UInt32, blend : Bool) : self

Digital differential analyser (DDA) line drawing

Source
lines!(xs : Array(Float64), ys : Array(Float64), color : UInt32, blend : Bool) : self

Vector line drawing (polyline)

Source
lines!(xs : Array(Float64), ys : Array(Float64), segment_colors : Array(UInt32), blend : Bool) : self

Vector line drawing (polyline) with per-segment colors

Source
lines!(x1 : Float64, y1 : Float64, x2 : Float64, y2 : Float64, *, color : Symbol = :normal) : self
Source
ncols
Source
nrows
Source
origin_x
Source
origin_y
Source
pixel!(pixel_x : Int32, pixel_y : Int32, color : UInt32, blend : Bool) : self
Source
pixel!(pixel_x : Int32, pixel_y : Int32, *, color : UInt32 = INVALID_COLOR) : self

High-level pixel placement (color conversion from symbol/int done by caller)

Source
pixel_height
Source
pixel_width
Source
points!(x : Float64, y : Float64, color : UInt32, blend : Bool) : self

Plot a single point (canvas coordinates)

Source
points!(xs : Array(Float64), ys : Array(Float64), color : UInt32, blend : Bool) : self

Plot a vector of points

Source
points!(xs : Array(Float64), ys : Array(Float64), colors : Array(UInt32), blend : Bool) : self

Plot a vector of points with per-point colors

Source
points!(x : Float64, y : Float64, *, color : Symbol = :normal) : self
Source
scale_x_to_pixel(x : Float64) : Float64
Source
scale_y_to_pixel(y : Float64) : Float64
Source
set_color!(col : Int32, row : Int32, color : UInt32, blend : Bool) : Nil

Set the color at char cell (col, row), blending if requested

Source
valid_x?(x : Float64) : Bool
Source
valid_x_pixel?(px : Int32) : Bool
Source
valid_y?(y : Float64) : Bool
Source
valid_y_pixel?(py : Int32) : Bool
Source
visible?
Source
width
Source
x_pixel_per_char
Source
x_to_pixel(x : Float64) : Float64
Source
xflip?
Source
xscale
Source
y_pixel_per_char
Source
y_to_pixel(y : Float64) : Float64

Coordinate transforms: value → pixel

Source
yflip?
Source
yscale
Source