Split `Fill` and `Stroke` into their own modules
This commit is contained in:
parent
1beeaf9db5
commit
de8f06b512
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue