pub struct Scene { /* private fields */ }Expand description
A render context for GPU rendering.
This context maintains the state for path rendering and manages the rendering pipeline from paths to strips that can be rendered by the GPU.
Implementations§
Source§impl Scene
impl Scene
Sourcepub fn new(width: u16, height: u16) -> Self
pub fn new(width: u16, height: u16) -> Self
Create a new render context with the given width and height in pixels.
Sourcepub fn new_with(width: u16, height: u16, level: Level) -> Self
pub fn new_with(width: u16, height: u16, level: Level) -> Self
Create a new render context with a specific SIMD level.
Sourcepub fn push_clip_path(&mut self, path: &BezPath)
pub fn push_clip_path(&mut self, path: &BezPath)
Push a new clip path to the clip stack.
See the explanation in the clipping
example for how this method differs from push_clip_layer.
Sourcepub fn push_clip_rect(&mut self, rect: &Rect)
pub fn push_clip_rect(&mut self, rect: &Rect)
Push a rectangular clip path.
Sourcepub fn pop_clip(&mut self)
pub fn pop_clip(&mut self)
Pop the most recently pushed clip path or clip rectangle from the clip stack.
Note that unlike push_clip_layer, it is permissible to have pending
pushed clips before finishing the rendering operation.
Sourcepub fn stroke_path(&mut self, path: &BezPath)
pub fn stroke_path(&mut self, path: &BezPath)
Stroke a path with the current paint and stroke settings.
Sourcepub fn set_aliasing_threshold(&mut self, aliasing_threshold: Option<u8>)
pub fn set_aliasing_threshold(&mut self, aliasing_threshold: Option<u8>)
Set the aliasing threshold.
If set to None (which is the recommended option in nearly all cases),
anti-aliasing will be applied.
If instead set to some value, then a pixel will be fully painted if the coverage is bigger than the threshold (between 0 and 255), otherwise it will not be painted at all.
Note that there is no performance benefit to disabling anti-aliasing and this functionality is simply provided for compatibility.
Sourcepub fn fill_rect(&mut self, rect: &Rect)
pub fn fill_rect(&mut self, rect: &Rect)
Fill a rectangle with the current paint and fill rule.
Sourcepub fn stroke_rect(&mut self, rect: &Rect)
pub fn stroke_rect(&mut self, rect: &Rect)
Stroke a rectangle with the current paint and stroke settings.
Sourcepub fn fill_blurred_rounded_rect(
&mut self,
rect: &Rect,
radius: f32,
std_dev: f32,
invert: bool,
)
pub fn fill_blurred_rounded_rect( &mut self, rect: &Rect, radius: f32, std_dev: f32, invert: bool, )
Fill a blurred rectangle with the given corner radius and standard deviation.
When invert is true, the inverse (1 - alpha) of the blur coverage is painted: the
paint is fully opaque outside the blurred rectangle and fades to transparent inside it. This
can be used to implement inset box shadows.
This operation uses the current transform and paint transform. Like Vello CPU, it only uses solid paints; non-solid paints fall back to black.
Sourcepub fn glyph_run<'a>(
&'a mut self,
resources: &'a mut Resources,
font: &FontData,
) -> GlyphRunBuilder<'a>
pub fn glyph_run<'a>( &'a mut self, resources: &'a mut Resources, font: &FontData, ) -> GlyphRunBuilder<'a>
Creates a builder for drawing a run of glyphs that have the same attributes.
Sourcepub fn push_layer(
&mut self,
clip_path: Option<&BezPath>,
blend_mode: Option<BlendMode>,
opacity: Option<f32>,
mask: Option<Mask>,
filter: Option<Filter>,
)
pub fn push_layer( &mut self, clip_path: Option<&BezPath>, blend_mode: Option<BlendMode>, opacity: Option<f32>, mask: Option<Mask>, filter: Option<Filter>, )
Push a new layer with the given properties.
§Panics
Panics if mask is provided because mask layers are not yet supported.
Sourcepub fn push_clip_layer(&mut self, path: &BezPath)
pub fn push_clip_layer(&mut self, path: &BezPath)
Push a new clip layer.
See the explanation in the clipping
example for how this method differs from push_clip_path.
Sourcepub fn push_blend_layer(&mut self, blend_mode: BlendMode)
pub fn push_blend_layer(&mut self, blend_mode: BlendMode)
Push a new blend layer.
Sourcepub fn push_opacity_layer(&mut self, opacity: f32)
pub fn push_opacity_layer(&mut self, opacity: f32)
Push a new opacity layer.
Sourcepub fn push_mask_layer(&mut self, mask: Mask)
pub fn push_mask_layer(&mut self, mask: Mask)
Push a new mask layer.
§Panics
This method currently always panics since masks are not supported yet.
Sourcepub fn push_filter_layer(&mut self, filter: Filter)
pub fn push_filter_layer(&mut self, filter: Filter)
Push a new filter layer.
Sourcepub fn set_blend_mode(&mut self, blend_mode: BlendMode)
pub fn set_blend_mode(&mut self, blend_mode: BlendMode)
Set the blend mode for subsequent rendering operations.
§Panics
Panics if blend_mode is destructive, which is currently not supported for
non-isolated blends. You need to use clip layers instead if you need that behavior.
Sourcepub fn set_stroke(&mut self, stroke: Stroke)
pub fn set_stroke(&mut self, stroke: Stroke)
Set the stroke settings for subsequent stroke operations.
Sourcepub fn set_paint(&mut self, paint: impl Into<PaintType>)
pub fn set_paint(&mut self, paint: impl Into<PaintType>)
Set the paint for subsequent rendering operations.
Sourcepub fn set_tint(&mut self, tint: Option<Tint>)
pub fn set_tint(&mut self, tint: Option<Tint>)
Set the tint for subsequent image paint operations.
Sourcepub fn reset_tint(&mut self)
pub fn reset_tint(&mut self)
Clear the tint, so subsequent image paints are drawn without tinting.
Sourcepub fn set_paint_transform(&mut self, paint_transform: Affine)
pub fn set_paint_transform(&mut self, paint_transform: Affine)
Set the current paint transform.
The paint transform is applied to the paint after the transform of the geometry the paint is drawn in, i.e., the paint transform is applied after the global transform. This allows transforming the paint independently from the drawn geometry.
Sourcepub fn reset_paint_transform(&mut self)
pub fn reset_paint_transform(&mut self)
Reset the current paint transform.
Sourcepub fn set_fill_rule(&mut self, fill_rule: Fill)
pub fn set_fill_rule(&mut self, fill_rule: Fill)
Set the fill rule for subsequent fill operations.
Sourcepub fn set_transform(&mut self, transform: Affine)
pub fn set_transform(&mut self, transform: Affine)
Set the transform for subsequent rendering operations.
Sourcepub fn reset_transform(&mut self)
pub fn reset_transform(&mut self)
Reset the transform to identity.
Sourcepub fn set_filter_effect(&mut self, filter: Filter)
pub fn set_filter_effect(&mut self, filter: Filter)
Apply filter to the current paint (affects next drawn element).
Sourcepub fn reset_filter_effect(&mut self)
pub fn reset_filter_effect(&mut self)
Reset the current filter effect.
Sourcepub fn reset_and_resize(&mut self, width: u16, height: u16)
pub fn reset_and_resize(&mut self, width: u16, height: u16)
Reset the scene and update its size.
Sourcepub fn take_current_state(&mut self) -> RenderState
pub fn take_current_state(&mut self) -> RenderState
Take current rendering state and reset the existing state to its default.
Sourcepub fn save_current_state(&mut self) -> RenderState
pub fn save_current_state(&mut self) -> RenderState
Save a copy of the current rendering state.
Sourcepub fn restore_state(&mut self, state: RenderState)
pub fn restore_state(&mut self, state: RenderState)
Restore rendering state.
Trait Implementations§
Source§impl DrawSink for Scene
impl DrawSink for Scene
Source§fn set_transform(&mut self, t: Affine)
fn set_transform(&mut self, t: Affine)
Source§fn set_paint(&mut self, paint: AtlasPaint)
fn set_paint(&mut self, paint: AtlasPaint)
Source§fn set_paint_transform(&mut self, t: Affine)
fn set_paint_transform(&mut self, t: Affine)
Source§fn push_clip_layer(&mut self, clip: &BezPath)
fn push_clip_layer(&mut self, clip: &BezPath)
Source§fn push_clip_path(&mut self, clip: &BezPath)
fn push_clip_path(&mut self, clip: &BezPath)
Source§fn push_clip_rect(&mut self, clip: &Rect)
fn push_clip_rect(&mut self, clip: &Rect)
Source§fn push_blend_layer(&mut self, blend_mode: BlendMode)
fn push_blend_layer(&mut self, blend_mode: BlendMode)
Source§fn pop_clip_path(&mut self)
fn pop_clip_path(&mut self)
Source§impl GlyphRenderer for Scene
impl GlyphRenderer for Scene
Source§type SavedState = RenderState
type SavedState = RenderState
Source§fn save_state(&mut self) -> Self::SavedState
fn save_state(&mut self) -> Self::SavedState
Source§fn restore_state(&mut self, state: Self::SavedState)
fn restore_state(&mut self, state: Self::SavedState)
Source§fn stroke_path(&mut self, path: &BezPath)
fn stroke_path(&mut self, path: &BezPath)
Source§fn set_paint_image(&mut self, image: Image)
fn set_paint_image(&mut self, image: Image)
Source§fn get_context_color(&self) -> AlphaColor<Srgb>
fn get_context_color(&self) -> AlphaColor<Srgb>
Source§fn current_paint(&self) -> &PaintType
fn current_paint(&self) -> &PaintType
Source§fn atlas_image_source(&self, atlas_slot: &AtlasSlot) -> ImageSource
fn atlas_image_source(&self, atlas_slot: &AtlasSlot) -> ImageSource
ImageSource for sampling a cached glyph from the atlas.