pub struct RenderContext { /* private fields */ }
Expand description
A render context.
Implementations§
Source§impl RenderContext
impl RenderContext
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 stroke_path(&mut self, path: &BezPath)
pub fn stroke_path(&mut self, path: &BezPath)
Stroke a path.
Sourcepub fn fill_blurred_rounded_rect(
&mut self,
rect: &Rect,
radius: f32,
std_dev: f32,
)
pub fn fill_blurred_rounded_rect( &mut self, rect: &Rect, radius: f32, std_dev: f32, )
Fill a blurred rectangle with the given radius and standard deviation.
Note that this only works properly if the current paint is set to a solid color. If not, it will fall back to using black as the fill color.
Sourcepub fn stroke_rect(&mut self, rect: &Rect)
pub fn stroke_rect(&mut self, rect: &Rect)
Stroke a rectangle.
Sourcepub fn glyph_run(&mut self, font: &Font) -> GlyphRunBuilder<'_, Self>
pub fn glyph_run(&mut self, font: &Font) -> GlyphRunBuilder<'_, Self>
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>,
)
pub fn push_layer( &mut self, clip_path: Option<&BezPath>, blend_mode: Option<BlendMode>, opacity: Option<f32>, mask: Option<Mask>, )
Push a new layer with the given properties.
Note that the mask, if provided, needs to have the same size as the render context. Otherwise, it will be ignored. In addition to that, the mask will not be affected by the current transformation matrix in place.
Sourcepub fn push_clip_layer(&mut self, path: &BezPath)
pub fn push_clip_layer(&mut self, path: &BezPath)
Push a new clip layer.
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.
Note that the mask, if provided, needs to have the same size as the render context. Otherwise, it will be ignored. In addition to that, the mask will not be affected by the current transformation matrix in place.
Sourcepub fn set_stroke(&mut self, stroke: Stroke)
pub fn set_stroke(&mut self, stroke: Stroke)
Set the current stroke.
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 current fill rule.
Sourcepub fn set_transform(&mut self, transform: Affine)
pub fn set_transform(&mut self, transform: Affine)
Set the current transform.
Sourcepub fn reset_transform(&mut self)
pub fn reset_transform(&mut self)
Reset the current transform.
Sourcepub fn render_to_buffer(
&self,
buffer: &mut [u8],
width: u16,
height: u16,
render_mode: RenderMode,
)
pub fn render_to_buffer( &self, buffer: &mut [u8], width: u16, height: u16, render_mode: RenderMode, )
Render the current context into a buffer.
The buffer is expected to be in premultiplied RGBA8 format with length width * height * 4
Sourcepub fn render_to_pixmap(&self, pixmap: &mut Pixmap, render_mode: RenderMode)
pub fn render_to_pixmap(&self, pixmap: &mut Pixmap, render_mode: RenderMode)
Render the current context into a pixmap.