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 Shape
s 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
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§
Source§impl Shape
§Constructors
impl Shape
§Constructors
Sourcepub fn line_segment(points: [Pos2; 2], stroke: impl Into<Stroke>) -> Shape
pub fn line_segment(points: [Pos2; 2], stroke: impl Into<Stroke>) -> Shape
A line between two points.
More efficient than calling Self::line
.
Sourcepub fn hline(x: RangeInclusive<f32>, y: f32, stroke: impl Into<Stroke>) -> Shape
pub fn hline(x: RangeInclusive<f32>, y: f32, stroke: impl Into<Stroke>) -> Shape
A horizontal line.
Sourcepub fn vline(x: f32, y: RangeInclusive<f32>, stroke: impl Into<Stroke>) -> Shape
pub fn vline(x: f32, y: RangeInclusive<f32>, stroke: impl Into<Stroke>) -> Shape
A vertical line.
Sourcepub fn line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Shape
pub fn line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Shape
A line through many points.
Use Self::line_segment
instead if your line only connects two points.
Sourcepub fn closed_line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Shape
pub fn closed_line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Shape
A line that closes back to the start point again.
Sourcepub fn dotted_line(
path: &[Pos2],
color: impl Into<Color32>,
spacing: f32,
radius: f32,
) -> Vec<Shape>
pub fn dotted_line( path: &[Pos2], color: impl Into<Color32>, spacing: f32, radius: f32, ) -> Vec<Shape>
Turn a line into equally spaced dots.
Sourcepub fn dashed_line(
path: &[Pos2],
stroke: impl Into<Stroke>,
dash_length: f32,
gap_length: f32,
) -> Vec<Shape>
pub fn dashed_line( path: &[Pos2], stroke: impl Into<Stroke>, dash_length: f32, gap_length: f32, ) -> Vec<Shape>
Turn a line into dashes.
Sourcepub fn dashed_line_many(
points: &[Pos2],
stroke: impl Into<Stroke>,
dash_length: f32,
gap_length: f32,
shapes: &mut Vec<Shape>,
)
pub fn dashed_line_many( points: &[Pos2], stroke: impl Into<Stroke>, dash_length: f32, gap_length: f32, shapes: &mut Vec<Shape>, )
Turn a line into dashes. If you need to create many dashed lines use this instead of
Self::dashed_line
Sourcepub fn convex_polygon(
points: Vec<Pos2>,
fill: impl Into<Color32>,
stroke: impl Into<Stroke>,
) -> Shape
pub fn convex_polygon( points: Vec<Pos2>, fill: impl Into<Color32>, stroke: impl Into<Stroke>, ) -> Shape
A convex polygon with a fill and optional stroke.
The most performant winding order is clockwise.
pub fn circle_filled( center: Pos2, radius: f32, fill_color: impl Into<Color32>, ) -> Shape
pub fn circle_stroke( center: Pos2, radius: f32, stroke: impl Into<Stroke>, ) -> Shape
pub fn rect_filled( rect: Rect, rounding: impl Into<Rounding>, fill_color: impl Into<Color32>, ) -> Shape
pub fn rect_stroke( rect: Rect, rounding: impl Into<Rounding>, stroke: impl Into<Stroke>, ) -> Shape
pub fn text( fonts: &Fonts, pos: Pos2, anchor: Align2, text: impl ToString, font_id: FontId, color: Color32, ) -> Shape
pub fn galley(pos: Pos2, galley: Arc<Galley>) -> Shape
Sourcepub fn galley_with_color(
pos: Pos2,
galley: Arc<Galley>,
text_color: Color32,
) -> Shape
pub fn galley_with_color( pos: Pos2, galley: Arc<Galley>, text_color: Color32, ) -> Shape
The text color in the Galley
will be replaced with the given color.
pub fn mesh(mesh: Mesh) -> Shape
pub fn image( texture_id: TextureId, rect: Rect, uv: Rect, tint: Color32, ) -> Shape
Sourcepub fn visual_bounding_rect(&self) -> Rect
pub fn visual_bounding_rect(&self) -> Rect
The visual bounding rectangle (includes stroke widths)
Trait Implementations§
Source§impl From<CircleShape> for Shape
impl From<CircleShape> for Shape
Source§fn from(shape: CircleShape) -> Shape
fn from(shape: CircleShape) -> Shape
Source§impl From<CubicBezierShape> for Shape
impl From<CubicBezierShape> for Shape
Source§fn from(shape: CubicBezierShape) -> Shape
fn from(shape: CubicBezierShape) -> Shape
Source§impl From<PaintCallback> for Shape
impl From<PaintCallback> for Shape
Source§fn from(shape: PaintCallback) -> Shape
fn from(shape: PaintCallback) -> Shape
Source§impl From<QuadraticBezierShape> for Shape
impl From<QuadraticBezierShape> for Shape
Source§fn from(shape: QuadraticBezierShape) -> Shape
fn from(shape: QuadraticBezierShape) -> Shape
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl !RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl !UnwindSafe for Shape
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters
when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters
when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more