Commit 96b9ef85 authored by targoo's avatar targoo

Fix opacity in formatter

parent 36e3167f
......@@ -45,7 +45,17 @@ abstract class ColorBase implements ColorInterface {
* The opacity value between 0 and 1.
*/
public function getOpacity() {
return $this->opacity | 1;
return $this->opacity;;
}
/**
* Set the opacity
*
* @return float
* The opacity value between 0 and 1.
*/
public function setOpacity($opacity) {
$this->opacity = $opacity;
}
static $patterns = array(
......
......@@ -45,7 +45,7 @@ class ColorHex extends ColorBase {
}
$this->color = hexdec($color);
$this->opacity = floatval($opacity);
$this->setOpacity(floatval($opacity));
return $this;
}
......@@ -85,7 +85,8 @@ class ColorHex extends ColorBase {
$red = (($this->color & 0xFF0000) >> 16);
$green = (($this->color & 0x00FF00) >> 8);
$blue = (($this->color & 0x0000FF));
return new ColorRGB($red, $green, $blue, $this->getOpacity());
$opacity = $this->getOpacity();
return new ColorRGB($red, $green, $blue, $opacity);
}
}
......@@ -128,15 +128,17 @@ class ColorFormatterText extends FormatterBase {
switch ($settings['format']) {
case 'hex':
$output = $color_hex->toString(FALSE);
if ($opacity && $settings['opacity']) {
$output = $color_hex->toString(TRUE);
} else {
$output = $color_hex->toString(FALSE);
}
break;
case 'rgb':
$output = $color_hex->toRGB()->toString(FALSE);
if ($opacity && $settings['opacity']) {
$output = $color_hex->toRGB()->toString(TRUE);
} else {
$output = $color_hex->toRGB()->toString(FALSE);
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment