summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-12 09:12:35 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-12 09:12:35 +0100
commitde8f06b512ec65f625417e334dca30990248c968 (patch)
tree5052783dd721cdb31585bdb7c3fb049c8bce4cda /wgpu/src/widget
parent1beeaf9db5e4d9bcf9c1fce89463ad47c708b07d (diff)
downloadiced-de8f06b512ec65f625417e334dca30990248c968.tar.gz
iced-de8f06b512ec65f625417e334dca30990248c968.tar.bz2
iced-de8f06b512ec65f625417e334dca30990248c968.zip
Split `Fill` and `Stroke` into their own modules
Diffstat (limited to 'wgpu/src/widget')
-rw-r--r--wgpu/src/widget/canvas.rs83
-rw-r--r--wgpu/src/widget/canvas/fill.rs12
-rw-r--r--wgpu/src/widget/canvas/stroke.rs66
3 files changed, 83 insertions, 78 deletions
diff --git a/wgpu/src/widget/canvas.rs b/wgpu/src/widget/canvas.rs
index c984fee9..1fc3ff01 100644
--- a/wgpu/src/widget/canvas.rs
+++ b/wgpu/src/widget/canvas.rs
@@ -2,8 +2,7 @@
use crate::{Defaults, Primitive, Renderer};
use iced_native::{
- layout, Color, Element, Hasher, Layout, Length, MouseCursor, Point, Size,
- Widget,
+ layout, Element, Hasher, Layout, Length, MouseCursor, Point, Size, Widget,
};
use std::hash::Hash;
@@ -11,12 +10,16 @@ pub mod layer;
pub mod path;
mod data;
+mod fill;
mod frame;
+mod stroke;
pub use data::Data;
+pub use fill::Fill;
pub use frame::Frame;
pub use layer::Layer;
pub use path::Path;
+pub use stroke::{LineCap, LineJoin, Stroke};
/// A 2D drawable region.
#[derive(Debug)]
@@ -115,79 +118,3 @@ where
Element::new(canvas)
}
}
-
-#[derive(Debug, Clone, Copy)]
-pub struct Stroke {
- pub color: Color,
- pub width: f32,
- pub line_cap: LineCap,
- pub line_join: LineJoin,
-}
-
-impl Default for Stroke {
- fn default() -> Stroke {
- Stroke {
- color: Color::BLACK,
- width: 1.0,
- line_cap: LineCap::default(),
- line_join: LineJoin::default(),
- }
- }
-}
-
-#[derive(Debug, Clone, Copy)]
-pub enum LineCap {
- Butt,
- Square,
- Round,
-}
-
-impl Default for LineCap {
- fn default() -> LineCap {
- LineCap::Butt
- }
-}
-
-impl From<LineCap> for lyon::tessellation::LineCap {
- fn from(line_cap: LineCap) -> lyon::tessellation::LineCap {
- match line_cap {
- LineCap::Butt => lyon::tessellation::LineCap::Butt,
- LineCap::Square => lyon::tessellation::LineCap::Square,
- LineCap::Round => lyon::tessellation::LineCap::Round,
- }
- }
-}
-
-#[derive(Debug, Clone, Copy)]
-pub enum LineJoin {
- Miter,
- Round,
- Bevel,
-}
-
-impl Default for LineJoin {
- fn default() -> LineJoin {
- LineJoin::Miter
- }
-}
-
-impl From<LineJoin> for lyon::tessellation::LineJoin {
- fn from(line_join: LineJoin) -> lyon::tessellation::LineJoin {
- match line_join {
- LineJoin::Miter => lyon::tessellation::LineJoin::Miter,
- LineJoin::Round => lyon::tessellation::LineJoin::Round,
- LineJoin::Bevel => lyon::tessellation::LineJoin::Bevel,
- }
- }
-}
-
-#[derive(Debug, Clone, Copy)]
-pub enum Fill {
- Color(Color),
-}
-
-impl Default for Fill {
- fn default() -> Fill {
- Fill::Color(Color::BLACK)
- }
-}
diff --git a/wgpu/src/widget/canvas/fill.rs b/wgpu/src/widget/canvas/fill.rs
new file mode 100644
index 00000000..9c23f997
--- /dev/null
+++ b/wgpu/src/widget/canvas/fill.rs
@@ -0,0 +1,12 @@
+use iced_native::Color;
+
+#[derive(Debug, Clone, Copy)]
+pub enum Fill {
+ Color(Color),
+}
+
+impl Default for Fill {
+ fn default() -> Fill {
+ Fill::Color(Color::BLACK)
+ }
+}
diff --git a/wgpu/src/widget/canvas/stroke.rs b/wgpu/src/widget/canvas/stroke.rs
new file mode 100644
index 00000000..9bb260b2
--- /dev/null
+++ b/wgpu/src/widget/canvas/stroke.rs
@@ -0,0 +1,66 @@
+use iced_native::Color;
+
+#[derive(Debug, Clone, Copy)]
+pub struct Stroke {
+ pub color: Color,
+ pub width: f32,
+ pub line_cap: LineCap,
+ pub line_join: LineJoin,
+}
+
+impl Default for Stroke {
+ fn default() -> Stroke {
+ Stroke {
+ color: Color::BLACK,
+ width: 1.0,
+ line_cap: LineCap::default(),
+ line_join: LineJoin::default(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, Copy)]
+pub enum LineCap {
+ Butt,
+ Square,
+ Round,
+}
+
+impl Default for LineCap {
+ fn default() -> LineCap {
+ LineCap::Butt
+ }
+}
+
+impl From<LineCap> for lyon::tessellation::LineCap {
+ fn from(line_cap: LineCap) -> lyon::tessellation::LineCap {
+ match line_cap {
+ LineCap::Butt => lyon::tessellation::LineCap::Butt,
+ LineCap::Square => lyon::tessellation::LineCap::Square,
+ LineCap::Round => lyon::tessellation::LineCap::Round,
+ }
+ }
+}
+
+#[derive(Debug, Clone, Copy)]
+pub enum LineJoin {
+ Miter,
+ Round,
+ Bevel,
+}
+
+impl Default for LineJoin {
+ fn default() -> LineJoin {
+ LineJoin::Miter
+ }
+}
+
+impl From<LineJoin> for lyon::tessellation::LineJoin {
+ fn from(line_join: LineJoin) -> lyon::tessellation::LineJoin {
+ match line_join {
+ LineJoin::Miter => lyon::tessellation::LineJoin::Miter,
+ LineJoin::Round => lyon::tessellation::LineJoin::Round,
+ LineJoin::Bevel => lyon::tessellation::LineJoin::Bevel,
+ }
+ }
+}