summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas
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/canvas
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/canvas')
-rw-r--r--wgpu/src/widget/canvas/fill.rs12
-rw-r--r--wgpu/src/widget/canvas/stroke.rs66
2 files changed, 78 insertions, 0 deletions
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,
+ }
+ }
+}