Skip to main content

Module rendering

Module rendering 

Source
Expand description

DOM canvas and drawable trait for mapping Cotis render commands to HTML/CSS.

The typical app path is HTMLRenderer::draw_framedraw_html_render_commands, which creates an HTMLCanvas, draws each HTMLDrawable command, then calls HTMLCanvas::finish.

Default drawables for cotis_defaults::render_commands live in drawable_defaults.

§Frame lifecycle

  1. HTMLCanvas::new → JS beginFrame
  2. For each command: HTMLCanvas::ensure_command_element + CSS pushes (or clip stack ops)
  3. HTMLCanvas::finish → finalize DOM nodes → JS endFrame removes unused cotis-* ids

§Quick start

use cotis_web::rendering::{HTMLCanvas, HTMLDrawable};

let mut canvas = HTMLCanvas::new();
canvas
    .ensure_command_element(1, "div", None)
    .current_element_css_push("position: absolute; left: 10px; top: 10px")
    .current_element_css_push("width: 100px; height: 50px")
    .current_element_css_push("background-color: red; border-radius: 5px");
canvas.finish();

§Core API

Modules§

drawable_defaults
Default HTMLDrawable implementations for cotis_defaults::render_commands types.

Structs§

HTMLCanvas
Per-frame DOM builder: creates/updates cotis-{id} elements and manages clip stacks.

Traits§

HTMLDrawable
Types that can draw themselves onto an HTMLCanvas (typically cotis-defaults commands).

Functions§

draw_html_render_commands
Renders an iterator of drawables as one DOM frame.