diff options
author | 2022-12-02 18:53:21 +0100 | |
---|---|---|
committer | 2022-12-02 18:53:21 +0100 | |
commit | 4029a1cdaaac1abbdcc141b20469a49670cd99b6 (patch) | |
tree | 71fa9d9c4aa1f02ce05771db43a4bb7bc6570e77 /graphics/src/triangle.rs | |
parent | 676d8efe03ebdbeeb95aef96b8097395b788b1ab (diff) | |
parent | 8b55e9b9e6ba0b83038dd491dd34d95b4f9a381b (diff) | |
download | iced-4029a1cdaaac1abbdcc141b20469a49670cd99b6.tar.gz iced-4029a1cdaaac1abbdcc141b20469a49670cd99b6.tar.bz2 iced-4029a1cdaaac1abbdcc141b20469a49670cd99b6.zip |
Merge branch 'master' into non-uniform-border-radius-for-quads
Diffstat (limited to 'graphics/src/triangle.rs')
-rw-r--r-- | graphics/src/triangle.rs | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/graphics/src/triangle.rs b/graphics/src/triangle.rs index 04ff6d21..f52b2339 100644 --- a/graphics/src/triangle.rs +++ b/graphics/src/triangle.rs @@ -1,13 +1,12 @@ //! Draw geometry using meshes of triangles. -use crate::{Color, 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. @@ -22,23 +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), - /// 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], -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], } |