[−][src]Struct widgetry::geom::GeomBatch
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]
Adds a single polygon, painted according to Fill
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 unshift<F: Into<Fill>>(&mut self, fill: F, p: Polygon)
[src]
Adds a single polygon to the front of the batch, painted according to Fill
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 into_widget(self, ctx: &EventCtx<'_>) -> Widget
[src]
Wrap in a Widget, so the batch can be drawn as part of a Panel.
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 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 load_svg<P: AsRef<Prerender>, I: AsRef<str>>(
prerender: &P,
filename: I
) -> GeomBatch
[src]
prerender: &P,
filename: I
) -> GeomBatch
Returns a batch containing an SVG from a file.
pub fn load_svg_bytes<P: AsRef<Prerender>>(
prerender: &P,
labeled_bytes: (&str, &[u8])
) -> GeomBatch
[src]
prerender: &P,
labeled_bytes: (&str, &[u8])
) -> GeomBatch
Returns a GeomBatch from the bytes of a utf8 encoded SVG string.
pub fn load_svg_bytes_uncached(raw: &[u8]) -> GeomBatch
[src]
Returns a GeomBatch from the bytes of a utf8 encoded SVG string.
Prefer to use load_svg_bytes
, which caches the parsed SVG, unless
the SVG was dynamically generated, or is otherwise unlikely to be
reused.
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 scale_xy(self, x_factor: f64, y_factor: f64) -> GeomBatch
[src]
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.
pub fn to_geojson(self, gps_bounds: Option<&GPSBounds>) -> Vec<Feature>
[src]
Exports the batch to a list of GeoJSON features, labeling each colored polygon. Z-values, alpha values from the color, and non-RGB fill patterns are lost. If the polygon isn't a ring, it's skipped. The world-space coordinates are optionally translated back to GPS.
Trait Implementations
impl Clone for GeomBatch
[src]
impl Debug for GeomBatch
[src]
impl<F: Into<Fill>> From<Vec<(F, Polygon), Global>> for GeomBatch
[src]
Auto Trait Implementations
impl RefUnwindSafe for GeomBatch
[src]
impl Send for GeomBatch
[src]
impl Sync for GeomBatch
[src]
impl Unpin for GeomBatch
[src]
impl UnwindSafe for GeomBatch
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Send + Sync + Any,
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,