pub struct Storage { /* private fields */ }
Expand description
This struct handles storage and fast retrieval of shapes.
Implementations§
source§impl Storage
impl Storage
A storage struct that organizes shapes by their zoom level and allows for fast queries given a zoom and a bbox.
pub fn new() -> Storage
sourcepub fn add(&mut self, shape: Box<dyn ShapeStored>) -> ShapeId
pub fn add(&mut self, shape: Box<dyn ShapeStored>) -> ShapeId
Adds a new shape to the storage
sourcepub fn remove(&mut self, id: ShapeId) -> Option<Shape>
pub fn remove(&mut self, id: ShapeId) -> Option<Shape>
Deletes a shape from this storage given its id if such id exists
sourcepub fn remove_circle(
&mut self,
center: Vec2D<WorldUnit>,
radius: WorldUnit
) -> impl Iterator<Item = Shape> + '_
pub fn remove_circle( &mut self, center: Vec2D<WorldUnit>, radius: WorldUnit ) -> impl Iterator<Item = Shape> + '_
Returns the id of a shape intersecting the circle described by center and radius, if any.
sourcepub fn shape_count(&self) -> usize
pub fn shape_count(&self) -> usize
Returns the number of shapes in this storage
sourcepub fn shapes_by_index(&self) -> impl Iterator<Item = &dyn ShapeStored>
pub fn shapes_by_index(&self) -> impl Iterator<Item = &dyn ShapeStored>
Returns the shapes stored in this storage ordered by their index. It is used for rendering the shapes in the order they where drawn. Creates an allocation.
sourcepub fn draw_commands(&self, bbox: [Vec2D<WorldUnit>; 2]) -> Vec<DrawCommand>
pub fn draw_commands(&self, bbox: [Vec2D<WorldUnit>; 2]) -> Vec<DrawCommand>
gets all the draw commands necessary to paint the portion of the screen indicated by bbox. Commands are cached to improve the performance of continuously drawing on the same portion of the screen