summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-12-27 19:23:26 +0100
committerLaurenz <laurmaedje@gmail.com>2020-12-27 19:23:26 +0100
commit750d220bb080be077cd7ede6d18d485b1c3fb0c9 (patch)
tree741bcbf9e286de6433a0677d4bcf8b93d70fb806 /src/eval
parentc44ebf876f6ab09fe1629d980efc5c4878a6a5a5 (diff)
Add color enum 🎨
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/mod.rs3
-rw-r--r--src/eval/value.rs7
2 files changed, 6 insertions, 4 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index c2b80b68..ed73b07c 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -20,6 +20,7 @@ use fontdock::FontStyle;
use crate::diag::Diag;
use crate::diag::{Deco, Feedback, Pass};
+use crate::color::Color;
use crate::env::SharedEnv;
use crate::geom::{BoxAlign, Dir, Flow, Gen, Length, Linear, Relative, Sides, Size};
use crate::layout::{
@@ -436,7 +437,7 @@ impl Eval for Lit {
Lit::Float(v) => Value::Float(v),
Lit::Length(v, unit) => Value::Length(Length::with_unit(v, unit)),
Lit::Percent(v) => Value::Relative(Relative::new(v / 100.0)),
- Lit::Color(v) => Value::Color(v),
+ Lit::Color(v) => Value::Color(Color::Rgba(v)),
Lit::Str(ref v) => Value::Str(v.clone()),
Lit::Dict(ref v) => Value::Dict(v.eval(ctx)),
Lit::Content(ref v) => Value::Content(v.clone()),
diff --git a/src/eval/value.rs b/src/eval/value.rs
index 8c98257e..a27e9aa9 100644
--- a/src/eval/value.rs
+++ b/src/eval/value.rs
@@ -7,7 +7,7 @@ use std::rc::Rc;
use fontdock::{FontStretch, FontStyle, FontWeight};
use super::{Args, Dict, Eval, EvalContext, SpannedEntry};
-use crate::color::RgbaColor;
+use crate::color::Color;
use crate::diag::Diag;
use crate::geom::{Dir, Length, Linear, Relative};
use crate::paper::Paper;
@@ -32,8 +32,8 @@ pub enum Value {
Relative(Relative),
/// A combination of an absolute length and a relative value: `20% + 5cm`.
Linear(Linear),
- /// A color value with alpha channel: `#f79143ff`.
- Color(RgbaColor),
+ /// A color value: `#f79143ff`.
+ Color(Color),
/// A string: `"string"`.
Str(String),
/// A dictionary value: `(false, 12cm, greeting="hi")`.
@@ -285,6 +285,7 @@ try_from_match!(Linear["linear"]:
Value::Length(v) => v.into(),
Value::Relative(v) => v.into(),
);
+try_from_match!(Color["color"]: Value::Color(v) => v);
try_from_match!(String["string"]: Value::Str(v) => v);
try_from_match!(SynTree["tree"]: Value::Content(v) => v);
try_from_match!(ValueDict["dictionary"]: Value::Dict(v) => v);