summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas/geometry.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-05-05 00:05:47 +0200
committerLibravatar GitHub <noreply@github.com>2020-05-05 00:05:47 +0200
commit7dc02a5e16a3143b7c3ba9270207e3ebda71d567 (patch)
treedd727f138641fbda008af8e7827369cc99420749 /wgpu/src/widget/canvas/geometry.rs
parent27aad74a32fd8ac2b12f9d32df8a3b61a3175457 (diff)
parent93c6be5eef577f0778b5787dac37351c035ed471 (diff)
downloadiced-7dc02a5e16a3143b7c3ba9270207e3ebda71d567.tar.gz
iced-7dc02a5e16a3143b7c3ba9270207e3ebda71d567.tar.bz2
iced-7dc02a5e16a3143b7c3ba9270207e3ebda71d567.zip
Merge pull request #325 from hecrj/feature/canvas-interaction
Canvas interactivity and Game of Life example
Diffstat (limited to 'wgpu/src/widget/canvas/geometry.rs')
-rw-r--r--wgpu/src/widget/canvas/geometry.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/wgpu/src/widget/canvas/geometry.rs b/wgpu/src/widget/canvas/geometry.rs
new file mode 100644
index 00000000..4cadee39
--- /dev/null
+++ b/wgpu/src/widget/canvas/geometry.rs
@@ -0,0 +1,34 @@
+use crate::Primitive;
+
+/// 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
+#[derive(Debug, Clone)]
+pub struct Geometry(Primitive);
+
+impl Geometry {
+ pub(crate) fn from_primitive(primitive: Primitive) -> Self {
+ Self(primitive)
+ }
+
+ /// 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
+ pub fn into_primitive(self) -> Primitive {
+ self.0
+ }
+}
+
+impl From<Geometry> for Primitive {
+ fn from(geometry: Geometry) -> Primitive {
+ geometry.0
+ }
+}