pub struct GeomBatch {
pub(crate) list: Vec<(Fill, Tessellation, f64)>,
pub autocrop_dims: bool,
}
Expand description
A mutable builder for a group of colored tessellated polygons.
Fields§
§list: Vec<(Fill, Tessellation, f64)>
§autocrop_dims: bool
Implementations§
source§impl GeomBatch
impl GeomBatch
sourcepub fn push<F: Into<Fill>, T: Into<Tessellation>>(&mut self, fill: F, p: T)
pub fn push<F: Into<Fill>, T: Into<Tessellation>>(&mut self, fill: F, p: T)
Adds a single tessellated polygon, painted according to Fill
sourcepub fn push_with_z<F: Into<Fill>, T: Into<Tessellation>>(
&mut self,
fill: F,
p: T,
z_offset: f64
)
pub fn push_with_z<F: Into<Fill>, T: Into<Tessellation>>( &mut self, fill: F, p: T, 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>, T: Into<Tessellation>>(&mut self, fill: F, p: T)
pub fn unshift<F: Into<Fill>, T: Into<Tessellation>>(&mut self, fill: F, p: T)
Adds a single polygon to the front of the batch, painted according to Fill
sourcepub fn extend<F: Into<Fill>, T: Into<Tessellation>>(
&mut self,
fill: F,
polys: Vec<T>
)
pub fn extend<F: Into<Fill>, T: Into<Tessellation>>( &mut self, fill: F, polys: Vec<T> )
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, Tessellation, f64)>
pub fn consume(self) -> Vec<(Fill, Tessellation, f64)>
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 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.
sourcepub fn multi_transform(
self,
scale: f64,
center_on: Pt2D,
rotate: Angle
) -> GeomBatch
pub fn multi_transform( self, scale: f64, center_on: Pt2D, rotate: Angle ) -> GeomBatch
Equivalent to
self.scale(scale).centered_on(center_on).rotate_around_batch_center(rotate)
, but faster.
pub fn scale_xy(self, x_factor: f64, y_factor: f64) -> GeomBatch
sourcepub fn scale_to_fit_width(self, width: f64) -> GeomBatch
pub fn scale_to_fit_width(self, width: f64) -> GeomBatch
Scales the batch so that the width matches something, preserving aspect ratio.
sourcepub fn scale_to_fit_height(self, height: f64) -> GeomBatch
pub fn scale_to_fit_height(self, height: f64) -> GeomBatch
Scales the batch so that the height matches something, preserving aspect ratio.
sourcepub fn scale_to_fit_square(self, dims: f64) -> GeomBatch
pub fn scale_to_fit_square(self, dims: f64) -> GeomBatch
Scales the batch so that the width and height do not exceed some maximum, preserving aspect ratio.
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>
pub fn into_geojson(self, gps_bounds: Option<&GPSBounds>) -> Vec<Feature>
Exports the batch to a list of GeoJSON features, labeling each colored triangle. Note the result will be very large and kind of meaningless – individual triangles are returned; any original polygons are lost. Z-values, alpha values from the color, and non-RGB fill patterns are lost. The world-space coordinates are optionally translated back to GPS.
pub fn build(self, ctx: &EventCtx<'_>) -> Drawable
Trait Implementations§
source§impl From<GeomBatch> for ToggleZoomedBuilder
impl From<GeomBatch> for ToggleZoomedBuilder
Auto Trait Implementations§
impl Freeze for GeomBatch
impl RefUnwindSafe for GeomBatch
impl Send for GeomBatch
impl Sync for GeomBatch
impl Unpin for GeomBatch
impl UnwindSafe for GeomBatch
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.