From 750d220bb080be077cd7ede6d18d485b1c3fb0c9 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 27 Dec 2020 19:23:26 +0100 Subject: =?UTF-8?q?Add=20color=20enum=20=F0=9F=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/library/style.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/library') diff --git a/src/library/style.rs b/src/library/style.rs index 43380249..8b8d9f26 100644 --- a/src/library/style.rs +++ b/src/library/style.rs @@ -2,9 +2,9 @@ use std::rc::Rc; use fontdock::{FontStretch, FontStyle, FontWeight}; -use crate::color::RgbaColor; use crate::eval::StringLike; use crate::geom::Linear; +use crate::color::{Color, RgbaColor}; use crate::prelude::*; /// `font`: Configure the font. @@ -152,22 +152,19 @@ pub fn rgb(mut args: Args, ctx: &mut EvalContext) -> Value { let a = args.get::<_, Spanned>(ctx, 3); args.done(ctx); - let mut healed = r.is_none() || g.is_none() || b.is_none(); let mut clamp = |component: Option>, default| { component.map_or(default, |c| { if c.v < 0.0 || c.v > 1.0 { ctx.diag(error!(c.span, "should be between 0.0 and 1.0")); - healed = true; } (c.v.max(0.0).min(1.0) * 255.0).round() as u8 }) }; - Value::Color(RgbaColor::with_healed( + Value::Color(Color::Rgba(RgbaColor::new( clamp(r, 0), clamp(g, 0), clamp(b, 0), clamp(a, 255), - healed, - )) + ))) } -- cgit v1.2.3