summaryrefslogtreecommitdiffstats
path: root/graphics/src/triangle.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-11-28 20:29:01 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-28 20:29:01 +0100
commit8d67e21d48dcefbbb675cfad07849607ce0fe1b7 (patch)
tree58072c44539d4b7009fff3defe97834438234b1b /graphics/src/triangle.rs
parent457d0560caf91884b148422e1ace3d64a38e0e33 (diff)
parentbb2bf063b472396d44f9f3114a87ba79dfd5f62e (diff)
downloadiced-8d67e21d48dcefbbb675cfad07849607ce0fe1b7.tar.gz
iced-8d67e21d48dcefbbb675cfad07849607ce0fe1b7.tar.bz2
iced-8d67e21d48dcefbbb675cfad07849607ce0fe1b7.zip
Merge pull request #1538 from iced-rs/group-solid-triangles
Group all solid triangles independently of color
Diffstat (limited to '')
-rw-r--r--graphics/src/triangle.rs37
1 files changed, 11 insertions, 26 deletions
diff --git a/graphics/src/triangle.rs b/graphics/src/triangle.rs
index 8b41bfc4..f52b2339 100644
--- a/graphics/src/triangle.rs
+++ b/graphics/src/triangle.rs
@@ -1,15 +1,12 @@
//! Draw geometry using meshes of triangles.
-use crate::Color;
-#[cfg(not(target_arch = "wasm32"))]
-use crate::Gradient;
-
use bytemuck::{Pod, Zeroable};
/// A set of [`Vertex2D`] and indices representing a list of triangles.
#[derive(Clone, Debug)]
-pub struct Mesh2D {
+pub struct Mesh2D<T> {
/// The vertices of the mesh
- pub vertices: Vec<Vertex2D>,
+ pub vertices: Vec<T>,
+
/// The list of vertex indices that defines the triangles of the mesh.
///
/// Therefore, this list should always have a length that is a multiple of 3.
@@ -24,25 +21,13 @@ pub struct Vertex2D {
pub position: [f32; 2],
}
-#[derive(Debug, Clone, PartialEq)]
-/// Supported shaders for triangle primitives.
-pub enum Style {
- /// Fill a primitive with a solid color.
- Solid(Color),
- #[cfg(not(target_arch = "wasm32"))]
- /// Fill a primitive with an interpolated color.
- Gradient(Gradient),
-}
-
-impl From<Color> for Style {
- fn from(color: Color) -> Self {
- Self::Solid(color)
- }
-}
+/// A two-dimensional vertex with a color.
+#[derive(Copy, Clone, Debug, Zeroable, Pod)]
+#[repr(C)]
+pub struct ColoredVertex2D {
+ /// The vertex position in 2D space.
+ pub position: [f32; 2],
-#[cfg(not(target_arch = "wasm32"))]
-impl From<Gradient> for Style {
- fn from(gradient: Gradient) -> Self {
- Self::Gradient(gradient)
- }
+ /// The color of the vertex in __linear__ RGBA.
+ pub color: [f32; 4],
}