Expand description
A mutable builder for a group of colored polygons.
Fields
list: Vec<(Fill, Polygon, f64)>
autocrop_dims: bool
Implementations
sourceimpl GeomBatch
impl GeomBatch
sourcepub fn push<F: Into<Fill>>(&mut self, fill: F, p: Polygon)
pub fn push<F: Into<Fill>>(&mut self, fill: F, p: Polygon)
Adds a single polygon, painted according to Fill
sourcepub fn push_with_z<F: Into<Fill>>(&mut self, fill: F, p: Polygon, z_offset: f64)
pub fn push_with_z<F: Into<Fill>>(&mut self, fill: F, p: Polygon, z_offset: f64)
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.
sourcepub fn unshift<F: Into<Fill>>(&mut self, fill: F, p: Polygon)
pub fn unshift<F: Into<Fill>>(&mut self, fill: F, p: Polygon)
Adds a single polygon to the front of the batch, painted according to Fill
sourcepub fn extend<F: Into<Fill>>(&mut self, fill: F, polys: Vec<Polygon>)
pub fn extend<F: Into<Fill>>(&mut self, fill: F, polys: Vec<Polygon>)
Applies one Fill to many polygons.
sourcepub fn append(&mut self, other: GeomBatch)
pub fn append(&mut self, other: GeomBatch)
Appends all colored polygons from another batch to the current one.
sourcepub fn consume(self) -> Vec<(Fill, Polygon, f64)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn consume(self) -> Vec<(Fill, Polygon, f64)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the colored polygons in this batch, destroying the batch.
sourcepub fn draw(self, g: &mut GfxCtx<'_>)
pub fn draw(self, g: &mut GfxCtx<'_>)
Draws the batch, consuming it. Only use this for drawing things once.
sourcepub fn upload(self, ctx: &EventCtx<'_>) -> Drawable
pub fn upload(self, ctx: &EventCtx<'_>) -> Drawable
Upload the batch of polygons to the GPU, returning something that can be cheaply redrawn many times later.
sourcepub fn batch(self) -> Widget
pub fn batch(self) -> Widget
Wrap in a Widget for layouting, so this batch can become part of a larger one.
sourcepub fn into_widget(self, ctx: &EventCtx<'_>) -> Widget
pub fn into_widget(self, ctx: &EventCtx<'_>) -> Widget
Wrap in a Widget, so the batch can be drawn as part of a Panel.
sourcepub fn get_bounds(&self) -> Bounds
pub fn get_bounds(&self) -> Bounds
Compute the bounds of all polygons in this batch.
sourcepub fn autocrop(self) -> GeomBatch
pub fn autocrop(self) -> GeomBatch
Sets the top-left to 0, 0. Not sure exactly when this should be used.
sourcepub fn unioned_polygon(&self) -> Polygon
pub fn unioned_polygon(&self) -> Polygon
Builds a single polygon covering everything in this batch. Use to create a hitbox.
sourcepub fn get_dims(&self) -> ScreenDims
pub fn get_dims(&self) -> ScreenDims
Returns the width and height of all geometry contained in the batch.
sourcepub fn load_svg<P: AsRef<Prerender>, I: AsRef<str>>(
prerender: &P,
filename: I
) -> GeomBatch
pub fn load_svg<P: AsRef<Prerender>, I: AsRef<str>>(
prerender: &P,
filename: I
) -> GeomBatch
Returns a batch containing an SVG from a file.
sourcepub fn load_svg_bytes<P: AsRef<Prerender>>(
prerender: &P,
labeled_bytes: (&str, &[u8])
) -> GeomBatch
pub fn load_svg_bytes<P: AsRef<Prerender>>(
prerender: &P,
labeled_bytes: (&str, &[u8])
) -> GeomBatch
Returns a GeomBatch from the bytes of a utf8 encoded SVG string.
sourcepub fn load_svg_bytes_uncached(raw: &[u8]) -> GeomBatch
pub fn load_svg_bytes_uncached(raw: &[u8]) -> GeomBatch
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.
sourcepub fn color(self, transformation: RewriteColor) -> GeomBatch
pub fn color(self, transformation: RewriteColor) -> GeomBatch
Transforms all colors in a batch.
sourcepub fn centered_on(self, center: Pt2D) -> GeomBatch
pub fn centered_on(self, center: Pt2D) -> GeomBatch
Translates the batch to be centered on some point.
sourcepub fn rotate(self, angle: Angle) -> GeomBatch
pub fn rotate(self, angle: Angle) -> GeomBatch
Rotates each polygon in the batch relative to the center of that polygon.
sourcepub fn rotate_around_batch_center(self, angle: Angle) -> GeomBatch
pub fn rotate_around_batch_center(self, angle: Angle) -> GeomBatch
Rotates each polygon in the batch relative to the center of the entire batch.
pub fn scale_xy(self, x_factor: f64, y_factor: f64) -> GeomBatch
sourcepub fn set_z_offset(self, offset: f64) -> GeomBatch
pub fn set_z_offset(self, offset: f64) -> GeomBatch
Overrides the Z-ordering offset for the batch. Must be in (-1, 0], with values closer to -1 rendering on top.
sourcepub fn into_geojson(self, gps_bounds: Option<&GPSBounds>) -> Vec<Feature>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn into_geojson(self, gps_bounds: Option<&GPSBounds>) -> Vec<Feature>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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
sourceimpl From<GeomBatch> for ToggleZoomedBuilder
impl From<GeomBatch> for ToggleZoomedBuilder
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more