abstract class
UnicodePlot::Canvas
- UnicodePlot::Canvas
- UnicodePlot::GraphicsArea
- Reference
- Object
Overview
Abstract pixel-based canvas. The grid is stored as a flat row-major array: index = row * ncols + col (0-based).
Direct Known Subclasses
- UnicodePlot::AsciiCanvas
- UnicodePlot::BlockCanvas
- UnicodePlot::BrailleCanvas
- UnicodePlot::DensityCanvas
- UnicodePlot::DotCanvas
Defined in:
unicode_plot/canvas.crConstructors
Instance Method Summary
-
#annotate!(x : Float64, y : Float64, char : Char, color : UInt32, blend : Bool) : self
Annotate a character at canvas coords (x, y)
- #annotate!(x : Float64, y : Float64, text : String, color : UInt32, blend : Bool, halign : Symbol = :center, valign : Symbol = :center) : self
- #blank : Char
- #blend? : Bool
- #char_point!(col : Int32, row : Int32, char : Char, color : UInt32, blend : Bool) : Nil
- #color_at(row : Int32, col : Int32) : UInt32
- #color_set!(row : Int32, col : Int32, color : UInt32) : Nil
-
#grid_at(row : Int32, col : Int32) : UInt32
Grid and color accessors (1-based row/col)
-
#grid_char_at(row : Int32, col : Int32) : Char
Map grid value to display character.
- #grid_set!(row : Int32, col : Int32, val : UInt32) : Nil
- #height : Float64
-
#lines!(x1 : Float64, y1 : Float64, x2 : Float64, y2 : Float64, color : UInt32, blend : Bool) : self
Digital differential analyser (DDA) line drawing
-
#lines!(xs : Array(Float64), ys : Array(Float64), color : UInt32, blend : Bool) : self
Vector line drawing (polyline)
-
#lines!(xs : Array(Float64), ys : Array(Float64), segment_colors : Array(UInt32), blend : Bool) : self
Vector line drawing (polyline) with per-segment colors
- #lines!(x1 : Float64, y1 : Float64, x2 : Float64, y2 : Float64, *, color : Symbol = :normal) : self
- #ncols : Int32
- #nrows : Int32
- #origin_x : Float64
- #origin_y : Float64
- #pixel!(pixel_x : Int32, pixel_y : Int32, color : UInt32, blend : Bool) : self
-
#pixel!(pixel_x : Int32, pixel_y : Int32, *, color : UInt32 = INVALID_COLOR) : self
High-level pixel placement (color conversion from symbol/int done by caller)
- #pixel_height : Int32
- #pixel_width : Int32
-
#points!(x : Float64, y : Float64, color : UInt32, blend : Bool) : self
Plot a single point (canvas coordinates)
-
#points!(xs : Array(Float64), ys : Array(Float64), color : UInt32, blend : Bool) : self
Plot a vector of points
-
#points!(xs : Array(Float64), ys : Array(Float64), colors : Array(UInt32), blend : Bool) : self
Plot a vector of points with per-point colors
- #points!(x : Float64, y : Float64, *, color : Symbol = :normal) : self
-
#print_row(io : IO, row : Int32, use_color : Bool) : Nil
Print a single row.
- #scale_x_to_pixel(x : Float64) : Float64
- #scale_y_to_pixel(y : Float64) : Float64
-
#set_color!(col : Int32, row : Int32, color : UInt32, blend : Bool) : Nil
Set the color at char cell (col, row), blending if requested
- #valid_x?(x : Float64) : Bool
- #valid_x_pixel?(px : Int32) : Bool
- #valid_y?(y : Float64) : Bool
- #valid_y_pixel?(py : Int32) : Bool
- #visible? : Bool
- #width : Float64
- #x_pixel_per_char : Int32
- #x_to_pixel(x : Float64) : Float64
- #xflip? : Bool
- #xscale : Proc(Float64, Float64)
- #y_pixel_per_char : Int32
-
#y_to_pixel(y : Float64) : Float64
Coordinate transforms: value → pixel
- #yflip? : Bool
- #yscale : Proc(Float64, Float64)
Instance methods inherited from class UnicodePlot::GraphicsArea
blank : Char
blank,
ncols : Int32
ncols,
nrows : Int32
nrows,
preprocess(io : IO) : GraphicsArea ->
preprocess,
print_row(io : IO, row : Int32, use_color : Bool) : Nil
print_row,
to_s(io : IO) : Nil
to_s,
visible? : Bool
visible?
Constructor Detail
Instance Method Detail
Annotate a character at canvas coords (x, y)
Map grid value to display character. Must be overridden by subclasses.
Digital differential analyser (DDA) line drawing
Vector line drawing (polyline)
Vector line drawing (polyline) with per-segment colors
High-level pixel placement (color conversion from symbol/int done by caller)
Plot a single point (canvas coordinates)
Plot a vector of points
Plot a vector of points with per-point colors
Print a single row. Implementations add ANSI color via use_color.
Set the color at char cell (col, row), blending if requested