pub enum Shape {
    Noop,
    Vec(Vec<Shape>),
    Circle(CircleShape),
    LineSegment {
        points: [Pos2; 2],
        stroke: Stroke,
    },
    Path(PathShape),
    Rect(RectShape),
    Text(TextShape),
    Mesh(Mesh),
    QuadraticBezier(QuadraticBezierShape),
    CubicBezier(CubicBezierShape),
    Callback(PaintCallback),
}
Expand description

A paint primitive such as a circle or a piece of text. Coordinates are all screen space points (not physical pixels).

You should generally recreate your Shapes each frame, but storing them should also be fine with one exception: Shape::Text depends on the current pixels_per_point (dpi scale) and so must be recreated every time pixels_per_point changes.

Variants

Noop

Paint nothing. This can be useful as a placeholder.

Vec(Vec<Shape>)

Recursively nest more shapes - sometimes a convenience to be able to do. For performance reasons it is better to avoid it.

Circle(CircleShape)

Circle with optional outline and fill.

LineSegment

Fields

points: [Pos2; 2]
stroke: Stroke

A line between two points.

Path(PathShape)

A series of lines between points. The path can have a stroke and/or fill (if closed).

Rect(RectShape)

Rectangle with optional outline and fill.

Text(TextShape)

Text.

This needs to be recreated if pixels_per_point (dpi scale) changes.

Mesh(Mesh)

A general triangle mesh.

Can be used to display images.

QuadraticBezier(QuadraticBezierShape)

A quadratic Bézier Curve.

CubicBezier(CubicBezierShape)

A cubic Bézier Curve.

Callback(PaintCallback)

Backend-specific painting.

Implementations

A line between two points. More efficient than calling Self::line.

A horizontal line.

A vertical line.

A line through many points.

Use Self::line_segment instead if your line only connects two points.

A line that closes back to the start point again.

Turn a line into equally spaced dots.

Turn a line into dashes.

Turn a line into dashes. If you need to create many dashed lines use this instead of Self::dashed_line

A convex polygon with a fill and optional stroke.

The most performant winding order is clockwise.

The text color in the Galley will be replaced with the given color.

The visual bounding rectangle (includes stroke widths)

Move the shape by this many points, in-place.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.