pub struct RenderContext {
pub model_stack: Vec<Model>,
pub cache: Option<RcMut<RenderCache>>,
pub progress_tx: Option<ProgressTx>,
/* private fields */
}Expand description
The render context.
Keeps a stack of model nodes and the render cache.
Fields§
§model_stack: Vec<Model>Model stack.
cache: Option<RcMut<RenderCache>>Optional render cache.
progress_tx: Option<ProgressTx>Progress is given as a percentage between 0.0 and 100.0.
Implementations§
Source§impl RenderContext
impl RenderContext
Sourcepub fn new(
model: &Model,
resolution: RenderResolution,
cache: Option<RcMut<RenderCache>>,
progress_tx: Option<ProgressTx>,
) -> RenderResult<Self>
pub fn new( model: &Model, resolution: RenderResolution, cache: Option<RcMut<RenderCache>>, progress_tx: Option<ProgressTx>, ) -> RenderResult<Self>
Initialize context with current model and prerender model.
Sourcepub fn with_model<T>(
&mut self,
model: Model,
f: impl FnOnce(&mut RenderContext) -> T,
) -> T
pub fn with_model<T>( &mut self, model: Model, f: impl FnOnce(&mut RenderContext) -> T, ) -> T
Run the closure f within the given model.
Sourcepub fn progress_in_percent(&self) -> f32
pub fn progress_in_percent(&self) -> f32
Return render progress in percent.
Sourcepub fn update_2d<T: Into<WithBounds2D<Geometry2D>>>(
&mut self,
f: impl FnOnce(&mut RenderContext, Model) -> RenderResult<T>,
) -> RenderResult<Geometry2DOutput>
pub fn update_2d<T: Into<WithBounds2D<Geometry2D>>>( &mut self, f: impl FnOnce(&mut RenderContext, Model) -> RenderResult<T>, ) -> RenderResult<Geometry2DOutput>
Update a 2D geometry if it is not in cache.
Sourcepub fn update_3d<T: Into<WithBounds3D<Geometry3D>>>(
&mut self,
f: impl FnOnce(&mut RenderContext, Model) -> RenderResult<T>,
) -> RenderResult<Geometry3DOutput>
pub fn update_3d<T: Into<WithBounds3D<Geometry3D>>>( &mut self, f: impl FnOnce(&mut RenderContext, Model) -> RenderResult<T>, ) -> RenderResult<Geometry3DOutput>
Update a 3D geometry if it is not in cache.
Sourcepub fn current_resolution(&self) -> RenderResolution
pub fn current_resolution(&self) -> RenderResolution
Return current render resolution.
Trait Implementations§
Source§impl Default for RenderContext
impl Default for RenderContext
Source§fn default() -> RenderContext
fn default() -> RenderContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RenderContext
impl !RefUnwindSafe for RenderContext
impl !Send for RenderContext
impl !Sync for RenderContext
impl Unpin for RenderContext
impl !UnwindSafe for RenderContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more