#[derive(Node)]
{
// Attributes available to this derive:
#[signal]
}
Expand description
A node of your own from a struct that implements Draw.
Fields marked #[signal] become animatable: the builder gets a setter
of the same name, and the handle (<Name>Handle) a method that returns
the field’s Signal. Other fields are set once on the builder. Every
field type needs Default and Clone; signal fields also Lerp.
ⓘ
#[derive(Node)]
pub struct Gauge {
#[signal] value: f64,
#[signal] size: f64,
}
impl Draw for Gauge {
fn draw(&self, ctx: &mut DrawCtx) {
ctx.arc((0.0, 0.0), self.size / 2.0, 135.0, 270.0 * self.value).stroke(Accent, 16.0);
}
fn size(&self) -> (f64, f64) { (self.size, self.size) }
}
let g = view.add(Gauge::new().size(200.0)); // GaugeHandle
g.value().to(0.8, 1.0).await;