Skip to content

Commit

Permalink
Allow user settable weights for CIEDE2000 (#12)
Browse files Browse the repository at this point in the history
* Allow user settable weights for CIEDE2000

* Response to change request

Typehint new parameter. Ensure weights are padded to three entries.
  • Loading branch information
chamby authored and TorbenKoehn committed Nov 12, 2018
1 parent eb51278 commit 3275e11
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Phim/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -1618,13 +1618,17 @@ public static function fade(ColorInterface $color, $ratio)
}

//http://www.easyrgb.com/index.php?X=DELT&H=05#text5
public static function getDifference(ColorInterface $color, ColorInterface $compareColor)
public static function getDifference(ColorInterface $color, ColorInterface $compareColor, array $weights = [1,1,1])
{

$color = $color->toLab();
$compareColor = $compareColor->toLab();

$kl = $kc = $kh = 1;
$weights = array_pad($weights, 3, 1);

$kl = $weights[0];
$kc = $weights[1];
$kh = $weights[2];

$l1 = $color->getL();
$a1 = $color->getA();
Expand Down

0 comments on commit 3275e11

Please sign in to comment.