[][src]Struct widgetry::GeomBatch

pub struct GeomBatch {
    pub(crate) list: Vec<(Fill, Polygon, f64)>,
    pub autocrop_dims: bool,
}

A mutable builder for a group of colored polygons.

Fields

list: Vec<(Fill, Polygon, f64)>autocrop_dims: bool

Implementations

impl GeomBatch[src]

pub fn new() -> GeomBatch[src]

Creates an empty batch.

pub fn push<F: Into<Fill>>(&mut self, fill: F, p: Polygon)[src]

pub fn push_with_z<F: Into<Fill>>(&mut self, fill: F, p: Polygon, z_offset: f64)[src]

Offset z value to render above/below other polygons. z must be in (-1, 0] to ensure we don't traverse layers of the UI - to make sure we don't inadvertently render something above a tooltip, etc.

pub fn extend<F: Into<Fill>>(&mut self, fill: F, polys: Vec<Polygon>)[src]

Applies one Fill to many polygons.

pub fn append(&mut self, other: GeomBatch)[src]

Appends all colored polygons from another batch to the current one.

pub fn consume(self) -> Vec<(Fill, Polygon, f64)>[src]

Returns the colored polygons in this batch, destroying the batch.

pub fn draw(self, g: &mut GfxCtx<'_>)[src]

Draws the batch, consuming it. Only use this for drawing things once.

pub fn upload(self, ctx: &EventCtx<'_>) -> Drawable[src]

Upload the batch of polygons to the GPU, returning something that can be cheaply redrawn many times later.

pub fn batch(self) -> Widget[src]

Wrap in a Widget for layouting, so this batch can become part of a larger one.

pub fn to_btn(self, ctx: &EventCtx<'_>) -> BtnBuilder[src]

Turn this batch into a button.

pub fn get_bounds(&self) -> Bounds[src]

Compute the bounds of all polygons in this batch.

pub fn autocrop(self) -> GeomBatch[src]

Sets the top-left to 0, 0. Not sure exactly when this should be used.

pub fn unioned_polygon(&self) -> Polygon[src]

Builds a single polygon covering everything in this batch. Use to create a hitbox.

pub(crate) fn is_empty(&self) -> bool[src]

True when the batch is empty.

pub fn get_dims(&self) -> ScreenDims[src]

Returns the width and height of all geometry contained in the batch.

pub fn from_svg_contents(raw: Vec<u8>) -> GeomBatch[src]

Returns a batch containing a parsed SVG string.

pub fn load_svg(prerender: &Prerender, filename: &str) -> GeomBatch[src]

Returns a batch containing an SVG from a file.

pub fn color(self, transformation: RewriteColor) -> GeomBatch[src]

Transforms all colors in a batch.

pub fn centered_on(self, center: Pt2D) -> GeomBatch[src]

Translates the batch to be centered on some point.

pub fn translate(self, dx: f64, dy: f64) -> GeomBatch[src]

Translates the batch by some offset.

pub fn rotate(self, angle: Angle) -> GeomBatch[src]

Rotates each polygon in the batch relative to the center of that polygon.

pub fn rotate_around_batch_center(self, angle: Angle) -> GeomBatch[src]

Rotates each polygon in the batch relative to the center of the entire batch.

pub fn scale(self, factor: f64) -> GeomBatch[src]

Scales the batch by some factor.

pub fn set_z_offset(self, offset: f64) -> GeomBatch[src]

Overrides the Z-ordering offset for the batch. Must be in (-1, 0], with values closer to -1 rendering on top.

Trait Implementations

impl Clone for GeomBatch[src]

impl<F: Into<Fill>> From<Vec<(F, Polygon)>> for GeomBatch[src]

fn from(list: Vec<(F, Polygon)>) -> GeomBatch[src]

Creates a batch of filled polygons.

Auto Trait Implementations

impl RefUnwindSafe for GeomBatch

impl Send for GeomBatch

impl Sync for GeomBatch

impl Unpin for GeomBatch

impl UnwindSafe for GeomBatch

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.