Components / Canvas
Canvas
Box that draws whatever its closure appends to the scene.
Example
The component itself, running in WebAssembly, beside its code in a playground. Try it.
Code
use ravenrs::prelude::*;
fn canvas() -> impl View {
Canvas::new(|frame, scene| {
for i in 0..8 {
let x = frame.x() + i as f32 * 28.0;
let height = 20.0 + i as f32 * 12.0;
let bar = Rect::new(x, frame.max_y() - height, 22.0, height);
// ravenrs-lint: allow(raw_color) a Canvas paints plain colors: it is drawing, with no theme to read
scene.push_quad(Quad::new(bar, Color::rgb(0.3, 0.4, 0.93)).radius(4.0));
}
})
.size(240.0, 130.0)
}