Readjusted namespaces, removed Geometry example as it's no longer relevant.
This commit is contained in:
parent
6e7b3ced0b
commit
30432cbade
27 changed files with 394 additions and 625 deletions
39
graphics/src/layer/mesh.rs
Normal file
39
graphics/src/layer/mesh.rs
Normal file
|
|
@ -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<f32>,
|
||||
|
||||
/// 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<Style> for Gradient {
|
||||
fn into(self) -> Style {
|
||||
match self {
|
||||
Gradient::Linear(linear) => {
|
||||
Style::Gradient(Gradient::Linear(linear))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue