pub enum DrawPrimitive {
Content,
Blend {
primitive: Box<DrawPrimitive>,
blend_mode: BlendMode,
},
Rect {
rect: Rect,
brush: Brush,
stroke: Option<Stroke>,
},
RoundRect {
rect: Rect,
brush: Brush,
radii: CornerRadii,
stroke: Option<Stroke>,
},
Arc {
rect: Rect,
brush: Brush,
center: Point,
radius: f32,
start_angle: f32,
sweep_angle: f32,
stroke: Option<Stroke>,
inner_radius: f32,
},
Line {
rect: Rect,
brush: Brush,
start: Point,
end: Point,
stroke: Stroke,
},
Trapezoid {
rect: Rect,
brush: Brush,
trapezoid: Trapezoid,
},
Image {
rect: Rect,
image: ImageBitmap,
alpha: f32,
color_filter: Option<ColorFilter>,
sampling: ImageSampling,
src_rect: Option<Rect>,
},
Text(Box<TextPrimitive>),
Shadow(ShadowPrimitive),
}Expand description
One recorded draw operation, in scope coordinates. Renderers consume these in draw order.
Variants§
Content
Marker emitted by draw_content() inside draw_with_content.
This is consumed by the modifier pipeline and never rendered directly.
Blend
Wrapper to associate a draw primitive with a non-default blend mode.
Fields
primitive: Box<DrawPrimitive>The primitive drawn with blend_mode.
Rect
A rectangle, filled or stroked.
Fields
RoundRect
A rectangle with rounded corners, filled or stroked.
Fields
radii: CornerRadiiCorner radii of the rectangle, in logical pixels.
Arc
A circular band: a stroked arc, or a filled annular sector / pie wedge.
Angles are radians, 0 = +X, increasing clockwise on screen (see
crate::stroke for the full convention).
stroke = Some(_)— the band isradius ± width/2, its ends shaped by the stroke cap.inner_radiusis ignored.stroke = None— the band isinner_radius ..= radiuswith flat (butt) radial ends;inner_radius = 0is a filled pie wedge.
Fields
rect: RectTight bounding box of the rendered band, caps included. Kept as the first field (like every other variant) so bbox/culling/clip logic treats an arc exactly like any other primitive.
radius: f32Radius of the stroked centerline, or the outer radius of a filled sector, in logical pixels.
start_angle: f32Where the arc starts, in radians. 0 points along +X and angles increase clockwise on
screen.
Line
A stroked straight segment from start to end, its ends shaped by
the stroke’s cap: Compose’s drawLine.
Fields
Trapezoid
One slice of a filled path, which the draw scope cuts a fill into
so the GPU draws it: see Trapezoid.
Fields
Image
An image drawn into a destination rectangle.
Fields
image: ImageBitmapThe image to draw.
color_filter: Option<ColorFilter>Color filter applied to the image, or None for none.
sampling: ImageSamplingHow pixels are sampled when the image is scaled.
Text(Box<TextPrimitive>)
A laid-out run of text. See TextPrimitive.
Shadow(ShadowPrimitive)
Shadow that requires blur processing. The renderer decides technique (GPU blur, CPU approximation, etc.).