Skip to main content

FrameBuilder

Struct FrameBuilder 

Source
pub struct FrameBuilder<'a> { /* private fields */ }
Expand description

Writes the primitives of a drawing into the frame (main layer, clipped to the pane by the caller).

Implementations§

Source§

impl<'a> FrameBuilder<'a>

Source

pub fn new(frame: &'a mut Frame, layer: LayerId) -> Self

A builder writing into layer of frame, for code that builds frames outside a Chart (ferrochart-plot).

use ferrochart_core::drawing::FrameBuilder;
use ferrochart_core::frame::{Frame, LayerId, StrokeStyle};
use ferrochart_core::geom::{PointPx, Px, Rgba};

let mut frame = Frame::default();
let mut b = FrameBuilder::new(&mut frame, LayerId::Main);
let stroke = StrokeStyle { color: Rgba::hex(0xFFFF_FFFF), width: Px(1.0), dash: Default::default() };
b.line(PointPx { x: 0.0, y: 0.0 }, PointPx { x: 10.0, y: 0.0 }, stroke);
assert_eq!(frame.pools.lines.len(), 1);
Source

pub fn line(&mut self, from: PointPx, to: PointPx, stroke: StrokeStyle)

A line segment.

Source

pub fn polyline( &mut self, pts: impl IntoIterator<Item = PointPx>, style: StrokeStyle, )

A polyline through pts.

Source

pub fn polygon(&mut self, pts: impl IntoIterator<Item = PointPx>, fill: Rgba)

A filled polygon with vertices pts.

Source

pub fn rect(&mut self, rect: RectPx, color: Rgba)

A filled axis-aligned rectangle.

Source

pub fn text(&mut self, pos: PointPx, text: &str, label: Label)

A line of text; pos.y is its vertical center.

Source

pub fn text_fmt(&mut self, pos: PointPx, args: Arguments<'_>, label: Label)

A line of formatted text, written straight into the frame’s text pool.

Source

pub fn icon(&mut self, icon: IconInst)

An icon from the built-in set (transform_helpers::ICON_*).

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for FrameBuilder<'a>

§

impl<'a> Forget for FrameBuilder<'a>

§

impl<'a> Freeze for FrameBuilder<'a>

§

impl<'a> Move for FrameBuilder<'a>

§

impl<'a> RefUnwindSafe for FrameBuilder<'a>

§

impl<'a> Send for FrameBuilder<'a>

§

impl<'a> Sync for FrameBuilder<'a>

§

impl<'a> Unpin for FrameBuilder<'a>

§

impl<'a> UnsafeUnpin for FrameBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.