Struct widgetry::GeomBatch [−][src]
A mutable builder for a group of colored polygons.
Fields
list: Vec<(Fill, Polygon, f64)>
autocrop_dims: bool
Implementations
impl GeomBatch
[src]
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 into_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.