FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    DrawingContext

    struct · ferroui-base · v0.5.0

    struct DrawingContext<'a>
    

    The surface a visual draws itself onto during rendering.

    View source

    Members

    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.

    Source

    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.

    Source

    dispose

    fn dispose(self: Self)
    

    Pops every state still pushed and releases the context (and the core, if the context owns it).

    Source

    draw_image

    fn draw_image(self: &mut Self, source: &dyn IImage, rect: Rect)
    

    Draws an image into rect.

    Source

    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.

    Source

    draw_line

    fn draw_line(self: &mut Self, pen: &Rc<dyn IPen>, p1: Point, p2: Point)
    

    Draws a line.

    Source

    draw_geometry

    fn draw_geometry(self: &mut Self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, geometry: &Ref<Geometry>)
    

    Draws a geometry.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    fill_rectangle

    fn fill_rectangle(self: &mut Self, brush: &Rc<dyn IBrush>, rect: Rect, corner_radius: f32)
    

    Draws a filled rectangle.

    Source

    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.

    Source

    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.

    Source

    custom

    fn custom(self: &mut Self, custom: &std::sync::Arc<dyn ICustomDrawOperation>)
    

    Draws a custom drawing operation.

    Source

    draw_text

    fn draw_text(self: &mut Self, text: &FormattedText, origin: Point)
    

    Draws text. origin is the upper-left corner of the text.

    Source

    draw_glyph_run

    fn draw_glyph_run(self: &mut Self, foreground: Option<&Rc<dyn IBrush>>, glyph_run: &Rc<GlyphRun>)
    

    Draws a glyph run.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    push_rounded_clip

    fn push_rounded_clip(self: &mut Self, clip: RoundedRect) -> PushedState
    

    Pushes a rounded clip rectangle.

    Source

    push_clip

    fn push_clip(self: &mut Self, clip: Rect) -> PushedState
    

    Pushes a clip rectangle.

    Source

    push_geometry_clip

    fn push_geometry_clip(self: &mut Self, clip: &Ref<Geometry>) -> PushedState
    

    Pushes a clip geometry.

    Source

    push_opacity

    fn push_opacity(self: &mut Self, opacity: f64) -> PushedState
    

    Pushes an opacity value.

    Source

    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.

    Source

    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.

    Source

    push_transform

    fn push_transform(self: &mut Self, matrix: Matrix) -> PushedState
    

    Pushes a matrix transformation.

    Source

    push_render_options

    fn push_render_options(self: &mut Self, render_options: RenderOptions) -> PushedState
    

    Pushes render options.

    Source

    push_text_options

    fn push_text_options(self: &mut Self, text_options: TextOptions) -> PushedState
    

    Pushes text options.

    Source

    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.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither
    • ITextDrawingSink
    • Drop

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.