module gfx.canvas
pub class Canvas
var m_color: str
var m_width: int64
var m_g_node: Node
var m_svg_node: Node
pub fn save_svg(filename: str)
pub fn set_color(color?: str)
pub fn set_width(width?: int64)
pub fn draw_text(x: int64, y: int64, text: str, halign: HorizontalAnchor, valign: VerticalAnchor)
fn draw_rect(x: int64, y: int64)
pub fn draw_line(x1: int64, y1: int64, x2: int64, y2: int64)
fn add_node(node?: Node)
pub enum HorizontalAnchor
LeftMiddleRight
pub enum VerticalAnchor
TopMiddleBottom
module gfx.chart
Functionality to charts and plotting.
pub class Chart
pub var m_x_axis: Axis
pub var m_y_axis: Axis
pub var m_curves: List[Curve]
var m_color_wheel: ColorWheel
pub fn to_svg(filename: str)
fn new_color() -> str
pub fn new_curve(name: str) -> Curve
pub fn add_curve(name: str, points: List[DataPoint])
fn get_data_bounds() -> Option
pub fn autoscale()
adjust axis to view all data!
pub fn autoscale_x()
Adjust x-axis to fit all data
pub fn autoscale_y()
Adjust y-axis to fit all data
pub fn zoom(factor: float64)
pub fn zoom_in()
pub fn zoom_out()
pub fn pan_x(delta: float64)
pub fn pan_y(delta: float64)
class Axis
pub var lower: float64
pub var upper: float64
pub fn domain() -> float64
pub fn scale(factor: float64)
pub fn pan(delta: float64)
pub class Curve
pub var points: List[DataPoint]
pub var color: str
pub fn add_point(x: float64, y: float64)
pub fn get_data_bounds() -> Option
pub struct DataPoint
x: float64y: float64
struct FRange
x_min: float64x_max: float64y_min: float64y_max: float64
fn containing_rect(left: FRange, right: FRange) -> FRange
fn grow_rect(source: FRange, percent: float64) -> FRange
class ColorWheel
var m_index: int64
var m_colors: List[str]
fn init()
pub fn get_color() -> str
struct FVal
value: float64distance: float64
fn new_fval(value: float64, approx: float64) -> FVal
fn cmp_fval(a: FVal, b: FVal) -> bool
struct TickValue
value: float64text: str
fn calc_tick_values(axis: Axis, n_ticks: int64) -> List[TickValue]
fn round_to_multiple(value: float64, base: float64) -> float64
class ChartDrawer
var m_chart: Chart
var m_canvas: Canvas
var m_x_ticks: List[Tick]
var m_y_ticks: List[Tick]
var m_width: int64
var m_height: int64
var m_axis_tick_size: int64
pub fn draw()
fn calc_x_ticks()
fn calc_y_ticks()
fn draw_grid()
fn draw_x_axis()
fn draw_y_axis()
fn draw_curves()
fn draw_border()
fn to_x_pixel(value?: float64) -> int64
fn to_y_pixel(value?: float64) -> int64
fn draw_path(points: List[Point])
fn set_width(width?: int64)
fn set_color(color?: str)
fn draw_line(x1: int64, y1: int64, x2: int64, y2: int64)
fn draw_rect(x1: int64, y1: int64, x2: int64, y2: int64)
fn draw_text(x: int64, y: int64, text: str, halign: HorizontalAnchor, valign: VerticalAnchor)
struct Tick
value: int64text: str
module gfx.game
Game engine functions.
pub class Engine
3D engine!
var m_screen: Screen
var m_projection: Mat
pub fn set_projection_matrix(fov: float64, near: float64, far: float64)
pub fn draw_mesh(m: Mesh)
pub fn new_cube_mesh() -> Mesh
pub fn new_cylinder_mesh() -> Mesh
pub fn new_mat4() -> Mat
pub fn new_mat(rows: int64, cols: int64) -> Mat
pub fn matrix_multiply(a: Mat, b: Mat, out: Mat)
Matrix multiplication A*B
pub fn matrix_vec_multiply(mat: Mat, vec: Vertex) -> Vertex
pub fn rotx(theta: float64) -> Mat
Rotation matrix around the x axis.
pub fn roty(theta: float64) -> Mat
Rotation matrix around the y axis.
pub fn rotz(theta: float64) -> Mat
Rotation matrix around the z axis.
pub struct Mat
rows: int64cols: int64m: [[float64]]
pub struct VecF
size: int64m: [float64]
pub struct Vertex
x: float64y: float64z: float64
pub fn new_vertex() -> Vertex
pub class Mesh
var vertici: Vector[Vertex]
var faces: Vector[Face]
pub struct Face
v1: int64v2: int64v3: int64
module gfx.lttb
Largest Triangle Three Bucket (LTTB) algorithm
pub fn lttb(values: List[DataPoint], threshold: int64) -> List[DataPoint]
module gfx.screen
pub fn new_screen(width: int64, height: int64) -> Screen
pub class Screen
A bitmap painter.
var m_width: int64
var m_height: int64
var m_image: Image
var m_color: Pixel
pub fn set_color(red: int64, green: int64, blue: int64)
pub fn clear()
Set entire screen to color.
pub fn draw_line(x1: int64, y1: int64, x2: int64, y2: int64)
Draw a line from x1,y1 to x2,y2 in the current color.

Use Bresenham's algorithm

See also: https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
fn draw_vertical_line(x: int64, y1: int64, y2: int64)
Vertical line
fn draw_horizontal_line(y: int64, x1: int64, x2: int64)
Horizontal line
pub fn put_pixel(x: int64, y: int64)
pub fn save_png(path: Path)
module gfx.ui
pub class Button
var x: int64