pub fn vector(asset: VectorAsset) -> ElExpand description
An app-supplied vector asset. By default Aetna preserves authored
fills, strokes, and gradients through the painted vector path; call
El::vector_mask when the asset should be treated as a one-colour
coverage mask. Companion to crate::icon for content that
doesn’t fit icon conventions: arbitrary-aspect bounding boxes,
programmatic construction each frame. Pairs with
crate::vector::PathBuilder for ergonomic path construction.
§Sizing
The default size matches the asset’s view-box dimensions in logical
pixels. Set El::width / El::height / El::fill_size to
override. Painted vectors are tessellated into the resolved rect;
mask vectors sample the backend MSDF atlas across that rect.
§Caching
The asset’s VectorAsset::content_hash
is the backend cache key. Apps that build the same shape twice (two
commits sharing a merge connector geometry, two flowchart edges with
the same arc) can share backend work; per-frame-unique geometry gets
one cache entry per unique shape.
use aetna_core::prelude::*;
use aetna_core::tree::Color;
let curve = PathBuilder::new()
.move_to(0.0, 0.0)
.cubic_to(20.0, 0.0, 0.0, 60.0, 20.0, 60.0)
.stroke_solid(Color::rgb(80, 200, 240), 2.0)
.stroke_line_cap(VectorLineCap::Round)
.build();
let asset = VectorAsset::from_paths([0.0, 0.0, 20.0, 60.0], vec![curve]);
let _ = vector(asset);