Skip to content

Commit 6908112

Browse files
committed
formatting
1 parent 7e97100 commit 6908112

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

src/MischiefCollective/ColorJizz/ColorJizz.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ public function distance(ColorJizz $destinationColor)
100100
$a = $this->toCIELab();
101101
$b = $destinationColor->toCIELab();
102102

103-
return sqrt(pow(($a->lightness - $b->lightness), 2) + pow(($a->a_dimension - $b->a_dimension), 2) + pow(($a->b_dimension - $b->b_dimension), 2));
103+
$lightness_pow = pow(($a->lightness - $b->lightness), 2);
104+
$a_dimension_pow = pow(($a->a_dimension - $b->a_dimension), 2);
105+
$b_dimension_pow = pow(($a->b_dimension - $b->b_dimension), 2);
106+
107+
return sqrt($lightness_pow + $a_dimension_pow + $b_dimension_pow);
104108
}
105109

106110
/**

src/MischiefCollective/ColorJizz/Formats/CIELCh.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,10 @@ public function toCMYK()
133133
*/
134134
public function toCIELab()
135135
{
136-
$l = $this->lightness;
137136
$hradi = $this->hue * (pi() / 180);
138-
$a = cos($hradi) * $this->chroma;
139-
$b = sin($hradi) * $this->chroma;
140-
return new CIELab($l, $a, $b);
137+
$a_dimension = cos($hradi) * $this->chroma;
138+
$b_dimension = sin($hradi) * $this->chroma;
139+
return new CIELab($this->lightness, $a_dimension, $b_dimension);
141140
}
142141

143142
/**

src/MischiefCollective/ColorJizz/Formats/Hex.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ public function toHex()
299299
*/
300300
public function toRGB()
301301
{
302-
$r = (($this->hex & 0xFF0000) >> 16);
303-
$g = (($this->hex & 0x00FF00) >> 8);
304-
$b = (($this->hex & 0x0000FF));
305-
return new RGB($r, $g, $b);
302+
$red = (($this->hex & 0xFF0000) >> 16);
303+
$green = (($this->hex & 0x00FF00) >> 8);
304+
$blue = (($this->hex & 0x0000FF));
305+
return new RGB($red, $green, $blue);
306306
}
307307

308308
/**

tests/unit/complementTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace MischiefCollective\ColorJizz\Tests;
4+
5+
use MischiefCollective\ColorJizz\Formats\Hex;
6+
7+
class complementTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testWebsafe()
10+
{
11+
$this->assertEquals(Hex::fromString('FFFFFF')->complement()->__toString(), 'FFFFFF');
12+
$this->assertEquals(Hex::fromString('FF0000')->complement()->__toString(), '00A1F3');
13+
}
14+
}

0 commit comments

Comments
 (0)