mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
ComputedDistance for IntermediateColor.
This commit is contained in:
parent
486578fe74
commit
09e728b43d
1 changed files with 17 additions and 0 deletions
|
@ -2389,6 +2389,23 @@ impl ComputeDistance for IntermediateRGBA {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ComputeDistance for IntermediateColor {
|
||||||
|
#[inline]
|
||||||
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
self.compute_squared_distance(other).map(|sq| sq.sqrt())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
match (*self, *other) {
|
||||||
|
(IntermediateColor::IntermediateRGBA(ref this), IntermediateColor::IntermediateRGBA(ref other)) => {
|
||||||
|
this.compute_squared_distance(other)
|
||||||
|
},
|
||||||
|
_ => Ok(0.0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ComputeDistance for CalcLengthOrPercentage {
|
impl ComputeDistance for CalcLengthOrPercentage {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue