summaryrefslogtreecommitdiffstats
path: root/core/src/renderer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-02-02 14:54:56 +0100
committerLibravatar GitHub <noreply@github.com>2024-02-02 14:54:56 +0100
commitaea172543cb49f1f1e3625f60b49336f59e26c00 (patch)
treee99e7a55873678ac37fd695a0f46c1350b30dd2f /core/src/renderer.rs
parent759f0e922598504705b543185bc7140a652b726a (diff)
parentb3adf3184594c9bf60e0548a0362d30c512f3966 (diff)
downloadiced-aea172543cb49f1f1e3625f60b49336f59e26c00.tar.gz
iced-aea172543cb49f1f1e3625f60b49336f59e26c00.tar.bz2
iced-aea172543cb49f1f1e3625f60b49336f59e26c00.zip
Merge pull request #2120 from iced-rs/transform-primitive
`Transform` primitive
Diffstat (limited to 'core/src/renderer.rs')
-rw-r--r--core/src/renderer.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/core/src/renderer.rs b/core/src/renderer.rs
index 0af74bb3..1139b41c 100644
--- a/core/src/renderer.rs
+++ b/core/src/renderer.rs
@@ -5,7 +5,9 @@ mod null;
#[cfg(debug_assertions)]
pub use null::Null;
-use crate::{Background, Border, Color, Rectangle, Shadow, Size, Vector};
+use crate::{
+ Background, Border, Color, Rectangle, Shadow, Size, Transformation, Vector,
+};
/// A component that can be used by widgets to draw themselves on a screen.
pub trait Renderer: Sized {
@@ -14,12 +16,24 @@ pub trait Renderer: Sized {
/// The layer will clip its contents to the provided `bounds`.
fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self));
- /// Applies a `translation` to the primitives recorded in the given closure.
+ /// Applies a [`Transformation`] to the primitives recorded in the given closure.
+ fn with_transformation(
+ &mut self,
+ transformation: Transformation,
+ f: impl FnOnce(&mut Self),
+ );
+
+ /// Applies a translation to the primitives recorded in the given closure.
fn with_translation(
&mut self,
translation: Vector,
f: impl FnOnce(&mut Self),
- );
+ ) {
+ self.with_transformation(
+ Transformation::translate(translation.x, translation.y),
+ f,
+ );
+ }
/// Fills a [`Quad`] with the provided [`Background`].
fn fill_quad(&mut self, quad: Quad, background: impl Into<Background>);