diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-07 14:32:35 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-07 16:19:51 +0200 |
| commit | 1192132dc0a9e991953fd29e93f87c8437a53ea0 (patch) | |
| tree | 67061e75a5a15c7997a3ac2de349b5e9ce234434 /src/library/utility | |
| parent | eb22eed31b08874fbbbee68d2ae59f0d02f9e95d (diff) | |
Rename length-related types
`Fractional` => `Fraction`
`Relative` => `Ratio`
`Linear` => `Relative`
Diffstat (limited to 'src/library/utility')
| -rw-r--r-- | src/library/utility/color.rs | 8 | ||||
| -rw-r--r-- | src/library/utility/math.rs | 8 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/library/utility/color.rs b/src/library/utility/color.rs index df24f615..409af177 100644 --- a/src/library/utility/color.rs +++ b/src/library/utility/color.rs @@ -15,12 +15,12 @@ pub fn rgb(_: &mut Context, args: &mut Args) -> TypResult<Value> { castable! { Component, - Expected: "integer or relative", + Expected: "integer or ratio", Value::Int(v) => match v { 0 ..= 255 => Self(v as u8), _ => Err("must be between 0 and 255")?, }, - Value::Relative(v) => if (0.0 ..= 1.0).contains(&v.get()) { + Value::Ratio(v) => if (0.0 ..= 1.0).contains(&v.get()) { Self((v.get() * 255.0).round() as u8) } else { Err("must be between 0% and 100%")? @@ -42,8 +42,8 @@ pub fn cmyk(_: &mut Context, args: &mut Args) -> TypResult<Value> { castable! { Component, - Expected: "relative", - Value::Relative(v) => if (0.0 ..= 1.0).contains(&v.get()) { + Expected: "ratio", + Value::Ratio(v) => if (0.0 ..= 1.0).contains(&v.get()) { Self((v.get() * 255.0).round() as u8) } else { Err("must be between 0% and 100%")? diff --git a/src/library/utility/math.rs b/src/library/utility/math.rs index 0aebc573..272ececa 100644 --- a/src/library/utility/math.rs +++ b/src/library/utility/math.rs @@ -39,9 +39,11 @@ pub fn abs(_: &mut Context, args: &mut Args) -> TypResult<Value> { Value::Float(v) => Value::Float(v.abs()), Value::Length(v) => Value::Length(v.abs()), Value::Angle(v) => Value::Angle(v.abs()), - Value::Relative(v) => Value::Relative(v.abs()), - Value::Fractional(v) => Value::Fractional(v.abs()), - Value::Linear(_) => bail!(span, "cannot take absolute value of a linear"), + Value::Ratio(v) => Value::Ratio(v.abs()), + Value::Fraction(v) => Value::Fraction(v.abs()), + Value::Relative(_) => { + bail!(span, "cannot take absolute value of a relative length") + } v => bail!(span, "expected numeric value, found {}", v.type_name()), }) } |
