pub struct Frame {
pub size_px: SizePx,
pub clear_color: Rgba,
pub layers: [Layer; 3],
pub invalidation: Invalidation,
pub pools: FramePools,
pub styles: Vec<SeriesStyle>,
}Expand description
The draw description of one frame.
§Examples
use ferrochart_core::frame::{DrawCmd, Frame, LayerId, RectInst};
use ferrochart_core::geom::{RectPx, Rgba};
let mut frame = Frame::default();
let r = RectInst { rect: RectPx { x: 0.0, y: 0.0, w: 2.0, h: 2.0 }, color: Rgba::hex(0) };
frame.push_rect(LayerId::Main, r);
frame.push_rect(LayerId::Main, r); // merged into the same command
assert_eq!(frame.layers[1].cmds.len(), 1);
assert!(matches!(frame.layers[1].cmds[0], DrawCmd::Rects(s) if s.len == 2));Fields§
§size_px: SizePxSize of the target in physical pixels.
clear_color: RgbaBackground color the target is cleared to.
layers: [Layer; 3]Background, main and overlay layers.
invalidation: InvalidationWhat changed since the previous frame.
pools: FramePoolsPrimitive pools.
styles: Vec<SeriesStyle>Resolved series styles, referenced by SeriesStyleRef.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn begin(&mut self, size: SizePx, clear: Rgba, invalidation: Invalidation)
pub fn begin(&mut self, size: SizePx, clear: Rgba, invalidation: Invalidation)
Starts a new frame: clears all pools and commands, keeping their capacity, and sets the target size, clear color and invalidation.
use ferrochart_core::frame::{Frame, LayerId, RectInst};
use ferrochart_core::geom::{RectPx, Rgba, SizePx};
use ferrochart_core::frame::Invalidation;
let mut frame = Frame::default();
frame.reserve();
let r = RectInst { rect: RectPx { x: 0.0, y: 0.0, w: 2.0, h: 2.0 }, color: Rgba::hex(0) };
frame.push_rect(LayerId::Main, r);
frame.begin(SizePx { w: 100.0, h: 50.0 }, Rgba::hex(0xFF), Invalidation::Full);
assert!(frame.pools.rects.is_empty() && frame.layers[1].cmds.is_empty());Sourcepub fn push_style(&mut self, style: SeriesStyle) -> SeriesStyleRef
pub fn push_style(&mut self, style: SeriesStyle) -> SeriesStyleRef
Adds a resolved style and returns its reference.
Sourcepub fn push_rect(&mut self, layer: LayerId, rect: RectInst)
pub fn push_rect(&mut self, layer: LayerId, rect: RectInst)
Adds a rectangle, extending the layer’s last Rects command if it ends at
the end of the pool.
Sourcepub fn push_line(&mut self, layer: LayerId, line: LineInst)
pub fn push_line(&mut self, layer: LayerId, line: LineInst)
Adds a line, merging with the layer’s last Lines command when possible.
Sourcepub fn push_text(&mut self, layer: LayerId, run: TextRun)
pub fn push_text(&mut self, layer: LayerId, run: TextRun)
Adds a text run whose characters are pools.text[text] (already written),
merging with the layer’s last Text command when possible.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Frame
impl Freeze for Frame
impl Move for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more