mirror of
https://github.com/Intervention/image.git
synced 2025-08-21 21:15:11 +02:00
Rename methods
This commit is contained in:
@@ -75,7 +75,7 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate
|
|||||||
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
|
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
|
||||||
{
|
{
|
||||||
if ($frame = $this->getFrame($frame_key)) {
|
if ($frame = $this->getFrame($frame_key)) {
|
||||||
return $this->colorFromInteger(
|
return $this->integerToColor(
|
||||||
imagecolorat($frame->getCore(), $x, $y)
|
imagecolorat($frame->getCore(), $x, $y)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ trait CanHandleColors
|
|||||||
* @param int $value
|
* @param int $value
|
||||||
* @return Color
|
* @return Color
|
||||||
*/
|
*/
|
||||||
public function colorFromInteger(int $value): Color
|
public function integerToColor(int $value): Color
|
||||||
{
|
{
|
||||||
$a = ($value >> 24) & 0xFF;
|
$a = ($value >> 24) & 0xFF;
|
||||||
$r = ($value >> 16) & 0xFF;
|
$r = ($value >> 16) & 0xFF;
|
||||||
|
@@ -131,7 +131,7 @@ class Image extends AbstractImage implements ImageInterface, Iterator
|
|||||||
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
|
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
|
||||||
{
|
{
|
||||||
if ($frame = $this->getFrame($frame_key)) {
|
if ($frame = $this->getFrame($frame_key)) {
|
||||||
return $this->colorFromPixel(
|
return $this->pixelToColor(
|
||||||
$frame->getCore()->getImagePixelColor($x, $y),
|
$frame->getCore()->getImagePixelColor($x, $y),
|
||||||
$this->getColorspace()
|
$this->getColorspace()
|
||||||
);
|
);
|
||||||
|
@@ -27,7 +27,7 @@ trait CanHandleColors
|
|||||||
* @param ColorspaceInterface $colorspace
|
* @param ColorspaceInterface $colorspace
|
||||||
* @return ColorInterface
|
* @return ColorInterface
|
||||||
*/
|
*/
|
||||||
public function colorFromPixel(ImagickPixel $pixel, ColorspaceInterface $colorspace): ColorInterface
|
public function pixelToColor(ImagickPixel $pixel, ColorspaceInterface $colorspace): ColorInterface
|
||||||
{
|
{
|
||||||
return match (get_class($colorspace)) {
|
return match (get_class($colorspace)) {
|
||||||
CmykColorspace::class => $colorspace->colorFromNormalized([
|
CmykColorspace::class => $colorspace->colorFromNormalized([
|
||||||
|
@@ -28,16 +28,16 @@ class CanHandleColorsTest extends TestCase
|
|||||||
public function testColorFromPixel(): void
|
public function testColorFromPixel(): void
|
||||||
{
|
{
|
||||||
$result = $this->getAnonymousTrait()
|
$result = $this->getAnonymousTrait()
|
||||||
->colorFromPixel(new ImagickPixel(), new RgbColorspace());
|
->pixelToColor(new ImagickPixel(), new RgbColorspace());
|
||||||
$this->assertInstanceOf(RgbColor::class, $result);
|
$this->assertInstanceOf(RgbColor::class, $result);
|
||||||
|
|
||||||
$result = $this->getAnonymousTrait()
|
$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->assertInstanceOf(RgbColor::class, $result);
|
||||||
$this->assertEquals([10, 20, 30, 51], $result->toArray());
|
$this->assertEquals([10, 20, 30, 51], $result->toArray());
|
||||||
|
|
||||||
$result = $this->getAnonymousTrait()
|
$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->assertInstanceOf(CmykColor::class, $result);
|
||||||
$this->assertEquals([10, 20, 30, 40], $result->toArray());
|
$this->assertEquals([10, 20, 30, 40], $result->toArray());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user