abstract class UnicodePlot::Canvas

Overview

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

Direct Known Subclasses

Defined in:

unicode_plot/canvas.cr

Constructors

Instance Method Summary

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

def self.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) #

[View source]

Instance Method Detail

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

Annotate a character at canvas coords (x, y)


[View source]
def annotate!(x : Float64, y : Float64, text : String, color : UInt32, blend : Bool, halign : Symbol = :center, valign : Symbol = :center) : self #

[View source]
abstract def blank : Char #

[View source]
def blend? : Bool #

[View source]
def char_point!(col : Int32, row : Int32, char : Char, color : UInt32, blend : Bool) : Nil #

[View source]
def color_at(row : Int32, col : Int32) : UInt32 #

[View source]
def color_set!(row : Int32, col : Int32, color : UInt32) : Nil #

[View source]
def grid_at(row : Int32, col : Int32) : UInt32 #

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


[View source]
abstract def grid_char_at(row : Int32, col : Int32) : Char #

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


[View source]
def grid_set!(row : Int32, col : Int32, val : UInt32) : Nil #

[View source]
def height : Float64 #

[View source]
def lines!(x1 : Float64, y1 : Float64, x2 : Float64, y2 : Float64, color : UInt32, blend : Bool) : self #

Digital differential analyser (DDA) line drawing


[View source]
def lines!(xs : Array(Float64), ys : Array(Float64), color : UInt32, blend : Bool) : self #

Vector line drawing (polyline)


[View source]
def lines!(x1 : Float64, y1 : Float64, x2 : Float64, y2 : Float64, *, color : Symbol = :normal) : self #

[View source]
def ncols : Int32 #

[View source]
def nrows : Int32 #

[View source]
def origin_x : Float64 #

[View source]
def origin_y : Float64 #

[View source]
abstract def pixel!(pixel_x : Int32, pixel_y : Int32, color : UInt32, blend : Bool) : self #

[View source]
def pixel!(pixel_x : Int32, pixel_y : Int32, *, color : UInt32 = INVALID_COLOR) : self #

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


[View source]
def pixel_height : Int32 #

[View source]
def pixel_width : Int32 #

[View source]
def points!(x : Float64, y : Float64, color : UInt32, blend : Bool) : self #

Plot a single point (canvas coordinates)


[View source]
def points!(xs : Array(Float64), ys : Array(Float64), color : UInt32, blend : Bool) : self #

Plot a vector of points


[View source]
def points!(x : Float64, y : Float64, *, color : Symbol = :normal) : self #

[View source]
def print_row(io : IO, row : Int32, use_color : Bool) : Nil #
Description copied from class UnicodePlot::GraphicsArea

Print a single row. Implementations add ANSI color via use_color.


[View source]
def scale_x_to_pixel(x : Float64) : Float64 #

[View source]
def scale_y_to_pixel(y : Float64) : Float64 #

[View source]
def set_color!(col : Int32, row : Int32, color : UInt32, blend : Bool) : Nil #

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


[View source]
def valid_x?(x : Float64) : Bool #

[View source]
def valid_x_pixel?(px : Int32) : Bool #

[View source]
def valid_y?(y : Float64) : Bool #

[View source]
def valid_y_pixel?(py : Int32) : Bool #

[View source]
def visible? : Bool #

[View source]
def width : Float64 #

[View source]
abstract def x_pixel_per_char : Int32 #

[View source]
def x_to_pixel(x : Float64) : Float64 #

[View source]
def xflip? : Bool #

[View source]
def xscale : Proc(Float64, Float64) #

[View source]
abstract def y_pixel_per_char : Int32 #

[View source]
def y_to_pixel(y : Float64) : Float64 #

Coordinate transforms: value → pixel


[View source]
def yflip? : Bool #

[View source]
def yscale : Proc(Float64, Float64) #

[View source]