Implement transform method for Geometry
This commit is contained in:
parent
5467c19c80
commit
9b8614a4e2
3 changed files with 29 additions and 13 deletions
|
|
@ -7,4 +7,4 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
iced.workspace = true
|
||||
iced.features = ["canvas"]
|
||||
iced.features = ["canvas", "debug"]
|
||||
|
|
|
|||
|
|
@ -4,20 +4,9 @@ pub use cache::Cache;
|
|||
|
||||
use crate::core::{Point, Rectangle, Size, Vector};
|
||||
use crate::graphics::geometry::{Fill, Path, Stroke, Text};
|
||||
use crate::graphics::Transformation;
|
||||
use crate::Renderer;
|
||||
|
||||
pub enum Frame {
|
||||
TinySkia(iced_tiny_skia::geometry::Frame),
|
||||
#[cfg(feature = "wgpu")]
|
||||
Wgpu(iced_wgpu::geometry::Frame),
|
||||
}
|
||||
|
||||
pub enum Geometry {
|
||||
TinySkia(iced_tiny_skia::Primitive),
|
||||
#[cfg(feature = "wgpu")]
|
||||
Wgpu(iced_wgpu::Primitive),
|
||||
}
|
||||
|
||||
macro_rules! delegate {
|
||||
($frame:expr, $name:ident, $body:expr) => {
|
||||
match $frame {
|
||||
|
|
@ -28,6 +17,32 @@ macro_rules! delegate {
|
|||
};
|
||||
}
|
||||
|
||||
pub enum Geometry {
|
||||
TinySkia(iced_tiny_skia::Primitive),
|
||||
#[cfg(feature = "wgpu")]
|
||||
Wgpu(iced_wgpu::Primitive),
|
||||
}
|
||||
|
||||
impl Geometry {
|
||||
pub fn transform(self, transformation: Transformation) -> Self {
|
||||
match self {
|
||||
Self::TinySkia(primitive) => {
|
||||
Self::TinySkia(primitive.transform(transformation))
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
Self::Wgpu(primitive) => {
|
||||
Self::Wgpu(primitive.transform(transformation))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Frame {
|
||||
TinySkia(iced_tiny_skia::geometry::Frame),
|
||||
#[cfg(feature = "wgpu")]
|
||||
Wgpu(iced_wgpu::geometry::Frame),
|
||||
}
|
||||
|
||||
impl Frame {
|
||||
pub fn new(renderer: &Renderer, size: Size) -> Self {
|
||||
match renderer {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub use event::Event;
|
|||
pub use program::Program;
|
||||
|
||||
pub use crate::graphics::geometry::*;
|
||||
pub use crate::graphics::Transformation;
|
||||
pub use crate::renderer::geometry::*;
|
||||
|
||||
use crate::core;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue