2020-04-19 21:55:23 +02:00
|
|
|
use crate::Primitive;
|
|
|
|
|
|
2020-04-30 07:38:46 +02:00
|
|
|
/// A bunch of shapes that can be drawn.
|
|
|
|
|
///
|
|
|
|
|
/// [`Geometry`] can be easily generated with a [`Frame`] or stored in a
|
|
|
|
|
/// [`Cache`].
|
|
|
|
|
///
|
|
|
|
|
/// [`Geometry`]: struct.Geometry.html
|
|
|
|
|
/// [`Frame`]: struct.Frame.html
|
|
|
|
|
/// [`Cache`]: struct.Cache.html
|
2020-04-28 03:18:31 +02:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct Geometry(Primitive);
|
2020-04-19 21:55:23 +02:00
|
|
|
|
|
|
|
|
impl Geometry {
|
2020-04-28 03:18:31 +02:00
|
|
|
pub(crate) fn from_primitive(primitive: Primitive) -> Self {
|
2020-04-19 21:55:23 +02:00
|
|
|
Self(primitive)
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 07:38:46 +02:00
|
|
|
/// Turns the [`Geometry`] into a [`Primitive`].
|
|
|
|
|
///
|
|
|
|
|
/// This can be useful if you are building a custom widget.
|
|
|
|
|
///
|
|
|
|
|
/// [`Geometry`]: struct.Geometry.html
|
|
|
|
|
/// [`Primitive`]: ../enum.Primitive.html
|
2020-04-28 03:18:31 +02:00
|
|
|
pub fn into_primitive(self) -> Primitive {
|
2020-04-19 21:55:23 +02:00
|
|
|
self.0
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-28 03:18:31 +02:00
|
|
|
|
|
|
|
|
impl From<Geometry> for Primitive {
|
|
|
|
|
fn from(geometry: Geometry) -> Primitive {
|
|
|
|
|
geometry.0
|
|
|
|
|
}
|
|
|
|
|
}
|