summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Artur Sapek <artur@lich.io>2020-01-01 15:44:32 -0700
committerLibravatar Artur Sapek <artur@lich.io>2020-01-01 22:45:29 -0700
commit0d620b7701f427ed0091f3640ab9ca0e116eb412 (patch)
tree6bd8a4cdd03643e4eca4dfe777a5e819643b1cec /core
parent26de688e68347e1f6e388d01014eac89cea71afa (diff)
downloadiced-0d620b7701f427ed0091f3640ab9ca0e116eb412.tar.gz
iced-0d620b7701f427ed0091f3640ab9ca0e116eb412.tar.bz2
iced-0d620b7701f427ed0091f3640ab9ca0e116eb412.zip
Implement Geometry2D primitive
Diffstat (limited to 'core')
-rw-r--r--core/src/geometry.rs20
-rw-r--r--core/src/lib.rs2
2 files changed, 22 insertions, 0 deletions
diff --git a/core/src/geometry.rs b/core/src/geometry.rs
new file mode 100644
index 00000000..f04ce42e
--- /dev/null
+++ b/core/src/geometry.rs
@@ -0,0 +1,20 @@
+/// A two-dimensional vertex which has a color
+#[repr(C)]
+#[derive(Copy, Clone, Debug)]
+pub struct Vertex2D {
+ /// The vertex position
+ pub position: [f32; 2],
+ /// The vertex color in rgba
+ pub color: [f32; 4],
+}
+
+/// A set of [`Vertex2D`] and indices for drawing some 2D geometry on the GPU.
+///
+/// [`Vertex2D`]: struct.Vertex2D.html
+#[derive(Clone, Debug)]
+pub struct Geometry2D {
+ /// The vertices for this geometry
+ pub vertices: Vec<Vertex2D>,
+ /// The indices for this geometry
+ pub indices: Vec<u16>,
+}
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 821b09c1..881f56c9 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -23,6 +23,7 @@ mod length;
mod point;
mod rectangle;
mod vector;
+mod geometry;
pub use align::{Align, HorizontalAlignment, VerticalAlignment};
pub use background::Background;
@@ -32,6 +33,7 @@ pub use length::Length;
pub use point::Point;
pub use rectangle::Rectangle;
pub use vector::Vector;
+pub use geometry::{Vertex2D, Geometry2D};
#[cfg(feature = "command")]
mod command;