Expand description
DOM canvas and drawable trait for mapping Cotis render commands to HTML/CSS.
The typical app path is HTMLRenderer::draw_frame →
draw_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
HTMLCanvas::new→ JSbeginFrame- For each command:
HTMLCanvas::ensure_command_element+ CSS pushes (or clip stack ops) HTMLCanvas::finish→ finalize DOM nodes → JSendFrameremoves unusedcotis-*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
HTMLCanvas::ensure_command_element— open or reuse host for a command id (cotis-{id})HTMLCanvas::new_element— ad-hoc child element with generated idHTMLCanvas::current_element_css_push— append/overwrite CSS on current hostHTMLCanvas::finish— commit frame and remove stale DOM nodes
Modules§
- drawable_
defaults - Default
HTMLDrawableimplementations forcotis_defaults::render_commandstypes.
Structs§
- HTML
Canvas - Per-frame DOM builder: creates/updates
cotis-{id}elements and manages clip stacks.
Traits§
- HTML
Drawable - Types that can draw themselves onto an
HTMLCanvas(typicallycotis-defaultscommands).
Functions§
- draw_
html_ render_ commands - Renders an iterator of drawables as one DOM frame.