Skip to content

Commit

Permalink
hex color constructor updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ynunez committed Jun 13, 2014
1 parent 22d7b0e commit 95f9017
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/JuiceLib/Color/Hex.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ public function __construct($color)
throw new \Exception("Invalid color range.");
}
$this->hex = $color;
} else if ($color[0] == "#") {
$color = \substr($color, 1, \strlen($color) - 1);
}
} else {
if ($color[0] == "#") {
$color = \substr($color, 1, \strlen($color) - 1);
}

if (\strlen($color) != 3 && \strlen($color) != 6) {
throw new \Exception("Hex color length is either 3 or 6.");
} else if (\strlen($color) == 3) {
$color = \sprintf("%s%s%s", $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
}

if (\strlen($color) != 3 && \strlen($color) != 6) {
throw new \Exception("Hex color length is either 3 or 6.");
} else if (\strlen($color) == 3) {
$color = \sprintf("%s%s%s", $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
$this->hex = base_convert($color, 16, 10);
}

$this->hex = base_convert($color, 16, 10);
}

public function toCMYK()
Expand Down

0 comments on commit 95f9017

Please sign in to comment.