pub struct Graphics {
pub container: Container,
current_fill: Fill,
current_stroke: Option<Stroke>,
pub(crate) primitives: Vec<Primitive>,
}Expand description
Vector-primitive node. Holds an ordered list of primitives sharing the node’s container transform.
Fields§
§container: ContainerTransform / visibility container.
current_fill: Fill§current_stroke: Option<Stroke>§primitives: Vec<Primitive>Implementations§
Source§impl Graphics
impl Graphics
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an empty Graphics with default (white solid) fill and no stroke.
Sourcepub fn stroke(&mut self, stroke: Option<Stroke>) -> &mut Self
pub fn stroke(&mut self, stroke: Option<Stroke>) -> &mut Self
Set the stroke used by subsequent fillable draw_* calls.
Pass None to clear; pass Some(...) to enable an outline.
Sourcepub fn draw_rect(&mut self, rect: Rect) -> &mut Self
pub fn draw_rect(&mut self, rect: Rect) -> &mut Self
Append a filled (and optionally stroked) rectangle primitive.
Sourcepub fn draw_rounded_rect(&mut self, rect: Rect, radius: f32) -> &mut Self
pub fn draw_rounded_rect(&mut self, rect: Rect, radius: f32) -> &mut Self
Append a filled (and optionally stroked) rounded rectangle primitive.
Sourcepub fn draw_ellipse(&mut self, center: Vec2, radii: Vec2) -> &mut Self
pub fn draw_ellipse(&mut self, center: Vec2, radii: Vec2) -> &mut Self
Append a filled (and optionally stroked) ellipse primitive.
Sourcepub fn draw_line(&mut self, from: Vec2, to: Vec2, width: f32) -> &mut Self
pub fn draw_line(&mut self, from: Vec2, to: Vec2, width: f32) -> &mut Self
Append a line segment of the given width, colored with the current fill. Strokes do not apply to lines.
Sourcepub fn draw_annular_sector(
&mut self,
center: Vec2,
r_inner: f32,
r_outer: f32,
start_angle: f32,
end_angle: f32,
) -> &mut Self
pub fn draw_annular_sector( &mut self, center: Vec2, r_inner: f32, r_outer: f32, start_angle: f32, end_angle: f32, ) -> &mut Self
Append a filled (and optionally stroked) annular sector —
a pie slice (when r_inner = 0) or donut slice. Angles in
radians, 0 = +x axis, CCW positive. The angular span is
end_angle - start_angle; values are clamped to
[0, 2π].
Sourcepub fn draw_arc(
&mut self,
center: Vec2,
radius: f32,
start_angle: f32,
end_angle: f32,
stroke_width: f32,
) -> &mut Self
pub fn draw_arc( &mut self, center: Vec2, radius: f32, start_angle: f32, end_angle: f32, stroke_width: f32, ) -> &mut Self
Append a stroked arc — circular segment of the given
radius, drawn with stroke_width band thickness from
start_angle to end_angle. Internally an annular sector
with r_inner = radius - stroke_width / 2,
r_outer = radius + stroke_width / 2.
Sourcepub fn draw_polygon(&mut self, vertices: &[Vec2]) -> &mut Self
pub fn draw_polygon(&mut self, vertices: &[Vec2]) -> &mut Self
Append a filled convex polygon. Vertices listed in CCW winding order; the polygon is implicitly closed.
Non-convex input is undefined behaviour for v1 — fan
triangulation from the first vertex produces visible
overlap when the polygon isn’t convex. Strokes do not
apply to polygons in v1; outline a polygon with draw_line
segments along the perimeter when an outline is needed.
Sourcepub fn primitive_count(&self) -> usize
pub fn primitive_count(&self) -> usize
Number of primitives currently buffered.
Sourcepub fn append(&mut self, other: &Graphics) -> &mut Self
pub fn append(&mut self, other: &Graphics) -> &mut Self
Append all primitives from other onto this Graphics,
preserving each primitive’s captured fill/stroke. The
current node’s current_fill / current_stroke state is
unchanged — subsequent draw_* calls keep using the
existing state.
Composing two Graphics is the idiomatic way for higher
layers (e.g. wisp-chart’s axis renderer) to splice
independently-built primitive lists into a single node so
the whole chart submits as one draw batch.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graphics
impl RefUnwindSafe for Graphics
impl Send for Graphics
impl Sync for Graphics
impl Unpin for Graphics
impl UnsafeUnpin for Graphics
impl UnwindSafe for Graphics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().