Back to Projects
TUIX v0.6Beta

Last Updated: 2026-08-14

Canvas & Drawing Surface (`content_builder.CANVAS`)

Canvas is a free-draw pixel surface providing Bresenham line rasterization, rectangle/circle geometry primitives, UTF-8 text drawing, raw pixel memory insertion, and native GPU/RAM sprite caching.

MethodDescription
objects.tuix_canvas_set_pixel(obj, x, y, sym, fgr, fgg, fgb, bgr, bgg, bgb)Sets an individual pixel with glyph symbol and RGB colors.
objects.tuix_canvas_draw_line(obj, x0, y0, x1, y1, sym, fgr, fgg, fgb, bgr, bgg, bgb)Renders a straight line between coordinates.
objects.tuix_canvas_draw_rect(obj, x, y, w, h, sym, filled, fgr, fgg, fgb, bgr, bgg, bgb)Draws an outlined (filled=0) or filled (filled=1) rectangle.
objects.tuix_canvas_draw_circle(obj, cx, cy, radius, sym, filled, fgr, fgg, fgb, bgr, bgg, bgb)Draws an outlined or filled circle.
objects.tuix_canvas_draw_text(obj, x, y, text, fgr, fgg, fgb, bgr, bgg, bgb)Renders UTF-8 text string at canvas cell coordinates.
objects.tuix_canvas_cache_sprite(obj, sprite_w, sprite_h, sprite_ptr) -> intRegisters sprite pixel memory in native cache and returns unique integer sprite ID.
objects.tuix_canvas_draw_cached_sprite(obj, sprite_id: int, dst_x: int, dst_y: int) -> intFast blit of pre-cached sprite ID at destination coordinates.
objects.tuix_canvas_free_cached_sprite(obj, sprite_id: int) -> NoneDeallocates cached sprite from native memory.
from tuix.core import object as objects, content_builder

uid = objects.create_object(content_builder.CANVAS, b'Main', 0.8, 0.6, 0.1, 0.1)
canvas = objects.get_object_by_uid(uid)

objects.tuix_canvas_draw_rect(canvas, 2, 2, 30, 10, '#', 0, 100, 150, 255, 0, 0, 0)
objects.tuix_canvas_draw_line(canvas, 2, 2, 31, 11, '/', 255, 200, 80, 0, 0, 0)
objects.tuix_canvas_draw_text(canvas, 5, 5, 'TUIX Graphics', 255, 255, 255, 0, 0, 0)