summaryrefslogtreecommitdiff
path: root/src/frame.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-08 17:08:30 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-09 12:02:35 +0200
commit29eb13ca6214461a4b0deb63d589cd39ad6d41c2 (patch)
treec86797d440cfcc801c87a3c64f479e39f2c068b1 /src/frame.rs
parent712c00ecb72b67da2c0788e5d3eb4dcc6366b2a7 (diff)
Sum color and length into stroke
Diffstat (limited to 'src/frame.rs')
-rw-r--r--src/frame.rs43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/frame.rs b/src/frame.rs
index a104c069..9613e485 100644
--- a/src/frame.rs
+++ b/src/frame.rs
@@ -5,7 +5,7 @@ use std::sync::Arc;
use crate::font::FaceId;
use crate::geom::{
- Align, Em, Length, Numeric, Paint, Path, Point, Size, Spec, Transform,
+ Align, Em, Length, Numeric, Paint, Path, Point, Size, Spec, Stroke, Transform,
};
use crate::image::ImageId;
@@ -223,22 +223,6 @@ pub struct Shape {
pub stroke: Option<Stroke>,
}
-impl Shape {
- /// Create a filled shape without a stroke.
- pub fn filled(geometry: Geometry, fill: Paint) -> Self {
- Self { geometry, fill: Some(fill), stroke: None }
- }
-
- /// Create a stroked shape without a fill.
- pub fn stroked(geometry: Geometry, stroke: Stroke) -> Self {
- Self {
- geometry,
- fill: None,
- stroke: Some(stroke),
- }
- }
-}
-
/// A shape's geometry.
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Geometry {
@@ -252,11 +236,22 @@ pub enum Geometry {
Path(Path),
}
-/// A stroke of a geometric shape.
-#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
-pub struct Stroke {
- /// The stroke's paint.
- pub paint: Paint,
- /// The stroke's thickness.
- pub thickness: Length,
+impl Geometry {
+ /// Fill the geometry without a stroke.
+ pub fn filled(self, fill: Paint) -> Shape {
+ Shape {
+ geometry: self,
+ fill: Some(fill),
+ stroke: None,
+ }
+ }
+
+ /// Stroke the geometry without a fill.
+ pub fn stroked(self, stroke: Stroke) -> Shape {
+ Shape {
+ geometry: self,
+ fill: None,
+ stroke: Some(stroke),
+ }
+ }
}