Replace Primitive::Translate with Transform
This commit is contained in:
parent
759f0e9225
commit
5467c19c80
11 changed files with 205 additions and 133 deletions
|
|
@ -1,14 +1,15 @@
|
|||
//! A collection of triangle primitives.
|
||||
use crate::core::{Point, Rectangle};
|
||||
use crate::core::Rectangle;
|
||||
use crate::graphics::mesh;
|
||||
use crate::graphics::Transformation;
|
||||
|
||||
/// A mesh of triangles.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Mesh<'a> {
|
||||
/// A mesh of triangles with a solid color.
|
||||
Solid {
|
||||
/// The origin of the vertices of the [`Mesh`].
|
||||
origin: Point,
|
||||
/// The [`Transformation`] for the vertices of the [`Mesh`].
|
||||
transformation: Transformation,
|
||||
|
||||
/// The vertex and index buffers of the [`Mesh`].
|
||||
buffers: &'a mesh::Indexed<mesh::SolidVertex2D>,
|
||||
|
|
@ -18,8 +19,8 @@ pub enum Mesh<'a> {
|
|||
},
|
||||
/// A mesh of triangles with a gradient color.
|
||||
Gradient {
|
||||
/// The origin of the vertices of the [`Mesh`].
|
||||
origin: Point,
|
||||
/// The [`Transformation`] for the vertices of the [`Mesh`].
|
||||
transformation: Transformation,
|
||||
|
||||
/// The vertex and index buffers of the [`Mesh`].
|
||||
buffers: &'a mesh::Indexed<mesh::GradientVertex2D>,
|
||||
|
|
@ -31,11 +32,10 @@ pub enum Mesh<'a> {
|
|||
|
||||
impl Mesh<'_> {
|
||||
/// Returns the origin of the [`Mesh`].
|
||||
pub fn origin(&self) -> Point {
|
||||
pub fn transformation(&self) -> Transformation {
|
||||
match self {
|
||||
Self::Solid { origin, .. } | Self::Gradient { origin, .. } => {
|
||||
*origin
|
||||
}
|
||||
Self::Solid { transformation, .. }
|
||||
| Self::Gradient { transformation, .. } => *transformation,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ pub enum Text<'a> {
|
|||
position: Point,
|
||||
color: Color,
|
||||
clip_bounds: Rectangle,
|
||||
scale: f32,
|
||||
},
|
||||
/// An editor.
|
||||
#[allow(missing_docs)]
|
||||
|
|
@ -23,6 +24,7 @@ pub enum Text<'a> {
|
|||
position: Point,
|
||||
color: Color,
|
||||
clip_bounds: Rectangle,
|
||||
scale: f32,
|
||||
},
|
||||
/// Some cached text.
|
||||
Cached(Cached<'a>),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue