summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2021-05-26 22:52:02 +0200
committerLaurenz <laurmaedje@gmail.com>2021-05-26 22:57:29 +0200
commite27f6c10146240a6c8b92930b27948083f08c9b5 (patch)
tree4b1d1fb574dfa164a76f758f989af04b8897cf6c /src/library
parent14f093bfee3d0871d9796a0dcaf1648b76010930 (diff)
Add hash impls for all nodes
This prepares the incremental PR. Co-Authored-By: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'src/library')
-rw-r--r--src/library/font.rs2
-rw-r--r--src/library/image.rs4
-rw-r--r--src/library/shapes.rs10
3 files changed, 9 insertions, 7 deletions
diff --git a/src/library/font.rs b/src/library/font.rs
index 33a521f5..b3b037cd 100644
--- a/src/library/font.rs
+++ b/src/library/font.rs
@@ -68,7 +68,7 @@ pub fn font(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
if let Some(linear) = size {
if linear.rel.is_zero() {
ctx.state.font.size = linear.abs;
- ctx.state.font.scale = Relative::ONE.into();
+ ctx.state.font.scale = Linear::one();
} else {
ctx.state.font.scale = linear;
}
diff --git a/src/library/image.rs b/src/library/image.rs
index 9b880d04..b73c26a9 100644
--- a/src/library/image.rs
+++ b/src/library/image.rs
@@ -32,7 +32,7 @@ pub fn image(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
}
/// An image node.
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Hash)]
struct ImageNode {
/// The id of the image file.
id: ImageId,
@@ -73,7 +73,7 @@ impl Layout for ImageNode {
};
let mut frame = Frame::new(size, size.height);
- frame.push(Point::ZERO, Element::Image(self.id, size));
+ frame.push(Point::zero(), Element::Image(self.id, size));
vec![frame]
}
}
diff --git a/src/library/shapes.rs b/src/library/shapes.rs
index ce8f634b..05cc2e2d 100644
--- a/src/library/shapes.rs
+++ b/src/library/shapes.rs
@@ -1,5 +1,7 @@
use std::f64::consts::SQRT_2;
+use decorum::NotNan;
+
use super::*;
use crate::color::Color;
use crate::layout::{BackgroundNode, BackgroundShape, Fill, FixedNode, PadNode};
@@ -47,14 +49,14 @@ pub fn square(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let height = width.is_none().then(|| args.eat_named(ctx, "height")).flatten();
let fill = args.eat_named(ctx, "fill");
let body = args.eat::<TemplateValue>(ctx).unwrap_or_default();
- rect_impl("square", width, height, Some(1.0), fill, body)
+ rect_impl("square", width, height, Some(1.0.into()), fill, body)
}
fn rect_impl(
name: &str,
width: Option<Linear>,
height: Option<Linear>,
- aspect: Option<f64>,
+ aspect: Option<NotNan<f64>>,
fill: Option<Color>,
body: TemplateValue,
) -> Value {
@@ -119,14 +121,14 @@ pub fn circle(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let height = width.is_none().then(|| args.eat_named(ctx, "height")).flatten();
let fill = args.eat_named(ctx, "fill");
let body = args.eat::<TemplateValue>(ctx).unwrap_or_default();
- ellipse_impl("circle", width, height, Some(1.0), fill, body)
+ ellipse_impl("circle", width, height, Some(1.0.into()), fill, body)
}
fn ellipse_impl(
name: &str,
width: Option<Linear>,
height: Option<Linear>,
- aspect: Option<f64>,
+ aspect: Option<NotNan<f64>>,
fill: Option<Color>,
body: TemplateValue,
) -> Value {