1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-21 13:11:18 +02:00

Rename methods

This commit is contained in:
Oliver Vogel
2023-10-22 15:12:04 +02:00
parent 9ba015742d
commit 6cff224934
5 changed files with 7 additions and 7 deletions

View File

@@ -75,7 +75,7 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
{
if ($frame = $this->getFrame($frame_key)) {
return $this->colorFromInteger(
return $this->integerToColor(
imagecolorat($frame->getCore(), $x, $y)
);
}

View File

@@ -12,7 +12,7 @@ trait CanHandleColors
* @param int $value
* @return Color
*/
public function colorFromInteger(int $value): Color
public function integerToColor(int $value): Color
{
$a = ($value >> 24) & 0xFF;
$r = ($value >> 16) & 0xFF;

View File

@@ -131,7 +131,7 @@ class Image extends AbstractImage implements ImageInterface, Iterator
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
{
if ($frame = $this->getFrame($frame_key)) {
return $this->colorFromPixel(
return $this->pixelToColor(
$frame->getCore()->getImagePixelColor($x, $y),
$this->getColorspace()
);

View File

@@ -27,7 +27,7 @@ trait CanHandleColors
* @param ColorspaceInterface $colorspace
* @return ColorInterface
*/
public function colorFromPixel(ImagickPixel $pixel, ColorspaceInterface $colorspace): ColorInterface
public function pixelToColor(ImagickPixel $pixel, ColorspaceInterface $colorspace): ColorInterface
{
return match (get_class($colorspace)) {
CmykColorspace::class => $colorspace->colorFromNormalized([

View File

@@ -28,16 +28,16 @@ class CanHandleColorsTest extends TestCase
public function testColorFromPixel(): void
{
$result = $this->getAnonymousTrait()
->colorFromPixel(new ImagickPixel(), new RgbColorspace());
->pixelToColor(new ImagickPixel(), new RgbColorspace());
$this->assertInstanceOf(RgbColor::class, $result);
$result = $this->getAnonymousTrait()
->colorFromPixel(new ImagickPixel('rgba(10, 20, 30, .2)'), new RgbColorspace());
->pixelToColor(new ImagickPixel('rgba(10, 20, 30, .2)'), new RgbColorspace());
$this->assertInstanceOf(RgbColor::class, $result);
$this->assertEquals([10, 20, 30, 51], $result->toArray());
$result = $this->getAnonymousTrait()
->colorFromPixel(new ImagickPixel('cmyk(10%, 20%, 30%, 40%)'), new CmykColorspace());
->pixelToColor(new ImagickPixel('cmyk(10%, 20%, 30%, 40%)'), new CmykColorspace());
$this->assertInstanceOf(CmykColor::class, $result);
$this->assertEquals([10, 20, 30, 40], $result->toArray());
}