From 5467c19c80c992f03890264ed58156305a26b19a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 23 Oct 2023 03:13:28 +0200 Subject: Replace `Primitive::Translate` with `Transform` --- wgpu/src/layer/mesh.rs | 18 +++++++++--------- wgpu/src/layer/text.rs | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'wgpu/src/layer') diff --git a/wgpu/src/layer/mesh.rs b/wgpu/src/layer/mesh.rs index 7c6206cd..af3dc74a 100644 --- a/wgpu/src/layer/mesh.rs +++ b/wgpu/src/layer/mesh.rs @@ -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, @@ -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, @@ -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, } } diff --git a/wgpu/src/layer/text.rs b/wgpu/src/layer/text.rs index 37ee5247..2a09aecc 100644 --- a/wgpu/src/layer/text.rs +++ b/wgpu/src/layer/text.rs @@ -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>), -- cgit From f4d66486016076bb339a338bc589645119962d1e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 24 Oct 2023 05:34:03 +0200 Subject: Introduce `with_transformation` to `Renderer` trait --- wgpu/src/layer/mesh.rs | 3 +-- wgpu/src/layer/text.rs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'wgpu/src/layer') diff --git a/wgpu/src/layer/mesh.rs b/wgpu/src/layer/mesh.rs index af3dc74a..5ed7c654 100644 --- a/wgpu/src/layer/mesh.rs +++ b/wgpu/src/layer/mesh.rs @@ -1,7 +1,6 @@ //! A collection of triangle primitives. -use crate::core::Rectangle; +use crate::core::{Rectangle, Transformation}; use crate::graphics::mesh; -use crate::graphics::Transformation; /// A mesh of triangles. #[derive(Debug, Clone, Copy)] diff --git a/wgpu/src/layer/text.rs b/wgpu/src/layer/text.rs index 2a09aecc..4c2b66a4 100644 --- a/wgpu/src/layer/text.rs +++ b/wgpu/src/layer/text.rs @@ -1,6 +1,6 @@ use crate::core::alignment; use crate::core::text; -use crate::core::{Color, Font, Pixels, Point, Rectangle}; +use crate::core::{Color, Font, Pixels, Point, Rectangle, Transformation}; use crate::graphics; use crate::graphics::text::editor; use crate::graphics::text::paragraph; @@ -15,7 +15,7 @@ pub enum Text<'a> { position: Point, color: Color, clip_bounds: Rectangle, - scale: f32, + transformation: Transformation, }, /// An editor. #[allow(missing_docs)] @@ -24,7 +24,7 @@ pub enum Text<'a> { position: Point, color: Color, clip_bounds: Rectangle, - scale: f32, + transformation: Transformation, }, /// Some cached text. Cached(Cached<'a>), -- cgit From b3adf3184594c9bf60e0548a0362d30c512f3966 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 2 Feb 2024 14:43:04 +0100 Subject: Apply `Transformation` to `RawText` primitives --- wgpu/src/layer/text.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wgpu/src/layer') diff --git a/wgpu/src/layer/text.rs b/wgpu/src/layer/text.rs index 4c2b66a4..b3a00130 100644 --- a/wgpu/src/layer/text.rs +++ b/wgpu/src/layer/text.rs @@ -29,7 +29,11 @@ pub enum Text<'a> { /// Some cached text. Cached(Cached<'a>), /// Some raw text. - Raw(graphics::text::Raw), + #[allow(missing_docs)] + Raw { + raw: graphics::text::Raw, + transformation: Transformation, + }, } #[derive(Debug, Clone)] -- cgit