Skip to content

Commit

Permalink
Fix typo in Distance::CIE76.
Browse files Browse the repository at this point in the history
Correct CIE76 distance between rgb(55,155,255) and #2d78c8 is something about 16.35.
  • Loading branch information
Angel5a committed Jun 24, 2022
1 parent 2bfbf08 commit 1883fcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Distance.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function CIE76($color1, $color2): float

$sum = 0;
$sum += pow($lab1->l() - $lab2->l(), 2);
$sum += pow($lab1->a() - $lab2->b(), 2);
$sum += pow($lab1->a() - $lab2->a(), 2);
$sum += pow($lab1->b() - $lab2->b(), 2);

return max(min(sqrt($sum), 100), 0);
Expand Down
4 changes: 2 additions & 2 deletions tests/DistanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public function it_can_compare_distance_using_CIE76()
$color2 = Hex::fromString('#2d78c8');
$distance = Distance::CIE76($color1, $color2);

$this->assertSame(55.89468042667388, $distance);
$this->assertSame(16.35058714542080, $distance);
}

/** @test */
public function it_can_compare_distance_using_CIE76_and_string_colors()
{
$distance = Distance::CIE76('rgb(55,155,255)', '#2d78c8');

$this->assertSame(55.89468042667388, $distance);
$this->assertSame(16.35058714542080, $distance);
}

/** @test */
Expand Down

0 comments on commit 1883fcc

Please sign in to comment.