From 30432cbade3d9b25c4df62656a7494db3f4ea82a Mon Sep 17 00:00:00 2001 From: shan Date: Wed, 5 Oct 2022 10:49:58 -0700 Subject: Readjusted namespaces, removed Geometry example as it's no longer relevant. --- graphics/src/layer/mesh.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 graphics/src/layer/mesh.rs (limited to 'graphics/src/layer/mesh.rs') diff --git a/graphics/src/layer/mesh.rs b/graphics/src/layer/mesh.rs new file mode 100644 index 00000000..a025675a --- /dev/null +++ b/graphics/src/layer/mesh.rs @@ -0,0 +1,39 @@ +//! A collection of triangle primitives. + +use crate::{Color, Point, Rectangle, triangle}; +use crate::gradient::Gradient; + +/// A mesh of triangles. +#[derive(Debug, Clone, Copy)] +pub struct Mesh<'a> { + /// The origin of the vertices of the [`Mesh`]. + pub origin: Point, + + /// The vertex and index buffers of the [`Mesh`]. + pub buffers: &'a triangle::Mesh2D, + + /// The clipping bounds of the [`Mesh`]. + pub clip_bounds: Rectangle, + + /// The shader of the [`Mesh`]. + pub style: &'a Style, +} + +#[derive(Debug, Clone)] +/// Supported shaders for primitives. +pub enum Style { + /// Fill a primitive with a solid color. + Solid(Color), + /// Fill a primitive with an interpolated color. + Gradient(Gradient) +} + +impl <'a> Into