Skip to content

Commit

Permalink
Merge pull request #7 from alchemy-fr/PHRAS-3520_stamper-on-top
Browse files Browse the repository at this point in the history
PHRAS-3520_stamper-on-top
  • Loading branch information
jygaulier authored Oct 2, 2023
2 parents 9435c17 + 72ec084 commit 7ac6a20
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/Imagine/Image/Palette/Color/CMYK.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ public function lighten($shade)
);
}

public function invert()
{
return $this->palette->color(
array(
255 - $this->c,
255 - $this->m,
255 - $this->y,
255 - $this->k,
)
);
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 5 additions & 0 deletions lib/Imagine/Image/Palette/Color/ColorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public function dissolve($alpha);
*/
public function lighten($shade);

/**
* @return ColorInterface
*/
public function invert();

/**
* Returns a copy of the current color, darkened by the specified number of
* shades
Expand Down
5 changes: 5 additions & 0 deletions lib/Imagine/Image/Palette/Color/Gray.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public function lighten($shade)
return $this->palette->color(array(min(255, $this->gray + $shade)), $this->alpha);
}

public function invert()
{
return $this->palette->color(array(255 - $this->gray), $this->alpha);
}

/**
* {@inheritdoc}
*/
Expand Down
11 changes: 11 additions & 0 deletions lib/Imagine/Image/Palette/Color/RGB.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ public function lighten($shade)
);
}

public function invert()
{
return $this->palette->color(
array(
255 - $this->r,
255 - $this->g,
255 - $this->b,
), $this->alpha
);
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Imagine/Imagick/Imagine.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function create(BoxInterface $size, ColorInterface $color = null)
$color = null !== $color ? $color : $palette->color('fff');

try {
$pixel = new \ImagickPixel((string) $color);
$pixel = new \ImagickPixel((string) $color . 'FF');
$pixel->setColorValue(\Imagick::COLOR_ALPHA, $color->getAlpha() / 100);

$imagick = new \Imagick();
Expand Down

0 comments on commit 7ac6a20

Please sign in to comment.