DrawingContext
struct · ferroui-base · v0.5.0
struct DrawingContext<'a>
The surface a visual draws itself onto during rendering.
Members
newowneddisposedraw_imagedraw_image_with_rectsdraw_linedraw_geometrydraw_rectangledraw_rounded_rectangledraw_rectangle_outlinefill_rectangledraw_ellipse_atdraw_ellipsecustomdraw_textdraw_glyph_rundraw_rectangle_acrylicpopscopepush_rounded_clippush_clippush_geometry_clippush_opacitytry_push_compositing_layerpush_opacity_maskpush_transformpush_render_optionspush_text_optionspush_effect
new
fn new(core: &'a mut dyn IDrawingContextCore) -> Self
Creates a context over a borrowed core. Dropping (or disposing) the context pops the states still pushed but leaves the core alive.
owned
fn owned(core: Box<dyn IDrawingContextCore>) -> Self
Creates a context that owns its core: disposing (or dropping) the context pops the states still pushed and disposes the core.
dispose
fn dispose(self: Self)
Pops every state still pushed and releases the context (and the core, if the context owns it).
draw_image
fn draw_image(self: &mut Self, source: &dyn IImage, rect: Rect)
Draws an image into rect.
draw_image_with_rects
fn draw_image_with_rects(self: &mut Self, source: &dyn IImage, source_rect: Rect, dest_rect: Rect)
Draws the part of an image inside source_rect into dest_rect.
draw_line
fn draw_line(self: &mut Self, pen: &Rc<dyn IPen>, p1: Point, p2: Point)
Draws a line.
draw_geometry
fn draw_geometry(self: &mut Self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, geometry: &Ref<Geometry>)
Draws a geometry.
draw_rectangle
fn draw_rectangle(self: &mut Self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, rect: Rect, radius_x: f64, radius_y: f64, box_shadows: &BoxShadows)
Draws a rectangle with the specified brush and pen.
The brush and the pen can both be None. If the brush is None, no
fill is performed. If the pen is None, no stroke is performed. If
both are None and there are no box shadows, the call is a no-op.
draw_rounded_rectangle
fn draw_rounded_rectangle(self: &mut Self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, rrect: RoundedRect, box_shadows: &BoxShadows)
Draws a rounded rectangle with the specified brush and pen.
draw_rectangle_outline
fn draw_rectangle_outline(self: &mut Self, pen: &Rc<dyn IPen>, rect: Rect, corner_radius: f32)
Draws the outline of a rectangle.
fill_rectangle
fn fill_rectangle(self: &mut Self, brush: &Rc<dyn IBrush>, rect: Rect, corner_radius: f32)
Draws a filled rectangle.
draw_ellipse_at
fn draw_ellipse_at(self: &mut Self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, center: Point, radius_x: f64, radius_y: f64)
Draws an ellipse given its center and radii.
draw_ellipse
fn draw_ellipse(self: &mut Self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, rect: Rect)
Draws an ellipse inscribed in a rectangle.
custom
fn custom(self: &mut Self, custom: &std::sync::Arc<dyn ICustomDrawOperation>)
Draws a custom drawing operation.
draw_text
fn draw_text(self: &mut Self, text: &FormattedText, origin: Point)
Draws text. origin is the upper-left corner of the text.
draw_glyph_run
fn draw_glyph_run(self: &mut Self, foreground: Option<&Rc<dyn IBrush>>, glyph_run: &Rc<GlyphRun>)
Draws a glyph run.
draw_rectangle_acrylic
fn draw_rectangle_acrylic(self: &mut Self, material: &dyn IExperimentalAcrylicMaterial, rect: RoundedRect)
Draws a rectangle filled with an acrylic-like material. A core
without acrylic support fills the rectangle with the fallback color
of the material; see
IDrawingContextCore::draw_rectangle_acrylic_core.
pop
fn pop(self: &mut Self, state: PushedState)
Pops a pushed state (C# PushedState.Dispose).
Panics if the state is not the most recently pushed one. Popping
PushedState::NONE, or any state after the context has been
disposed, does nothing.
scope
fn scope(self: &mut Self, state: PushedState) -> PushedScope<'_, 'a>
Turns a pushed state into a guard that derefs to the context and pops the state when dropped.
push_rounded_clip
fn push_rounded_clip(self: &mut Self, clip: RoundedRect) -> PushedState
Pushes a rounded clip rectangle.
push_clip
fn push_clip(self: &mut Self, clip: Rect) -> PushedState
Pushes a clip rectangle.
push_geometry_clip
fn push_geometry_clip(self: &mut Self, clip: &Ref<Geometry>) -> PushedState
Pushes a clip geometry.
push_opacity
fn push_opacity(self: &mut Self, opacity: f64) -> PushedState
Pushes an opacity value.
try_push_compositing_layer
fn try_push_compositing_layer(self: &mut Self, blend: BitmapBlendingMode, opacity: f64, bounds: Rect) -> Option<PushedState>
Draws subsequent vectors, text and images into one isolated group, then blends that group with the content beneath it when the state is popped. Opacity applies once to the complete group, including overlapping draws.
bounds is a conservative content/effect bound in the current coordinate
space. It is an allocation hint, not a clip. Blend modes reuse the same
enumeration as bitmap compositing but apply here to the entire group.
Returns None without pushing a state when the backend lacks compositing layers or arguments are non-finite/invalid. Recording contexts consult the registered backend capability; a caller can choose an explicit bitmap fallback instead of silently accepting a different blend mode.
push_opacity_mask
fn push_opacity_mask(self: &mut Self, mask: &Rc<dyn IBrush>, bounds: Rect) -> PushedState
Pushes an opacity mask.
bounds are the bounds of the control, used to place brushes
correctly.
push_transform
fn push_transform(self: &mut Self, matrix: Matrix) -> PushedState
Pushes a matrix transformation.
push_render_options
fn push_render_options(self: &mut Self, render_options: RenderOptions) -> PushedState
Pushes render options.
push_text_options
fn push_text_options(self: &mut Self, text_options: TextOptions) -> PushedState
Pushes text options.
push_effect
fn push_effect(self: &mut Self, effect: &Rc<dyn IEffect>, bounds: Rect) -> PushedState
Pushes an effect applied to everything drawn until the state is
popped. bounds are the bounds of the affected content.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherITextDrawingSinkDrop
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.