Skip to content

Commit 2c71a6b

Browse files
mreidenksubileau
authored andcommitted
Small performance improvement
1 parent 5b205ad commit 2c71a6b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/ColorThief/VBox.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@ public function contains(array $rgbValue, $rshift = ColorThief::RSHIFT)
168168
*/
169169
public function longestAxis()
170170
{
171-
$colorWidth['r'] = $this->r2 - $this->r1;
172-
$colorWidth['g'] = $this->g2 - $this->g1;
173-
$colorWidth['b'] = $this->b2 - $this->b1;
171+
// Color-Width for RGB
172+
$red = $this->r2 - $this->r1;
173+
$green = $this->g2 - $this->g1;
174+
$blue = $this->b2 - $this->b1;
174175

175-
return array_search(max($colorWidth), $colorWidth);
176+
return $red >= $green && $red >= $blue ? 'r' : ($green >= $red && $green >= $blue ? 'g' : 'b');
176177
}
177178
}

0 commit comments

Comments
 (0)