Skip to content

Commit 3275e11

Browse files
chambyTorbenKoehn
authored andcommitted
Allow user settable weights for CIEDE2000 (#12)
* Allow user settable weights for CIEDE2000 * Response to change request Typehint new parameter. Ensure weights are padded to three entries.
1 parent eb51278 commit 3275e11

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Phim/Color.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,13 +1618,17 @@ public static function fade(ColorInterface $color, $ratio)
16181618
}
16191619

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

16241624
$color = $color->toLab();
16251625
$compareColor = $compareColor->toLab();
16261626

1627-
$kl = $kc = $kh = 1;
1627+
$weights = array_pad($weights, 3, 1);
1628+
1629+
$kl = $weights[0];
1630+
$kc = $weights[1];
1631+
$kh = $weights[2];
16281632

16291633
$l1 = $color->getL();
16301634
$a1 = $color->getA();

0 commit comments

Comments
 (0)