File tree Expand file tree Collapse file tree 9 files changed +49
-15
lines changed
Expand file tree Collapse file tree 9 files changed +49
-15
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Intervention \Image \Colors ;
6+
7+ use Intervention \Image \Interfaces \ColorspaceInterface ;
8+
9+ abstract class AbstractColorspace implements ColorspaceInterface
10+ {
11+ /**
12+ * Channel class names of colorspace.
13+ *
14+ * @var array<string>
15+ */
16+ protected static array $ channels = [];
17+
18+ /**
19+ * {@inheritdoc}
20+ *
21+ * @see ColorspaceInterface::channels()
22+ */
23+ public static function channels (): array
24+ {
25+ return static ::$ channels ;
26+ }
27+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ abstract class AlphaColorChannel extends AbstractColorChannel
1616 /**
1717 * @throws InvalidArgumentException
1818 */
19- final public function __construct (float $ value )
19+ final public function __construct (float $ value = 1 )
2020 {
2121 if ($ value < 0 || $ value > 1 ) {
2222 throw new InvalidArgumentException (
Original file line number Diff line number Diff line change 44
55namespace Intervention \Image \Colors \Cmyk ;
66
7+ use Intervention \Image \Colors \AbstractColorspace ;
78use Intervention \Image \Colors \Cmyk \Color as CmykColor ;
89use Intervention \Image \Colors \Hsl \Color as HslColor ;
910use Intervention \Image \Colors \Hsv \Color as HsvColor ;
1516use Intervention \Image \Exceptions \InvalidArgumentException ;
1617use Intervention \Image \Exceptions \NotSupportedException ;
1718use Intervention \Image \Interfaces \ColorInterface ;
18- use Intervention \Image \Interfaces \ColorspaceInterface ;
1919use TypeError ;
2020
21- class Colorspace implements ColorspaceInterface
21+ class Colorspace extends AbstractColorspace
2222{
2323 /**
2424 * Channel class names of colorspace.
Original file line number Diff line number Diff line change 44
55namespace Intervention \Image \Colors \Hsl ;
66
7+ use Intervention \Image \Colors \AbstractColorspace ;
78use Intervention \Image \Colors \Cmyk \Color as CmykColor ;
89use Intervention \Image \Colors \Hsl \Color as HslColor ;
910use Intervention \Image \Colors \Hsv \Color as HsvColor ;
1617use Intervention \Image \Exceptions \NotSupportedException ;
1718use Intervention \Image \Interfaces \ColorChannelInterface ;
1819use Intervention \Image \Interfaces \ColorInterface ;
19- use Intervention \Image \Interfaces \ColorspaceInterface ;
2020use TypeError ;
2121
22- class Colorspace implements ColorspaceInterface
22+ class Colorspace extends AbstractColorspace
2323{
2424 /**
2525 * Channel class names of colorspace.
Original file line number Diff line number Diff line change 44
55namespace Intervention \Image \Colors \Hsv ;
66
7+ use Intervention \Image \Colors \AbstractColorspace ;
78use Intervention \Image \Colors \Cmyk \Color as CmykColor ;
89use Intervention \Image \Colors \Hsl \Color as HslColor ;
910use Intervention \Image \Colors \Hsv \Color as HsvColor ;
1617use Intervention \Image \Exceptions \NotSupportedException ;
1718use Intervention \Image \Interfaces \ColorChannelInterface ;
1819use Intervention \Image \Interfaces \ColorInterface ;
19- use Intervention \Image \Interfaces \ColorspaceInterface ;
2020use TypeError ;
2121
22- class Colorspace implements ColorspaceInterface
22+ class Colorspace extends AbstractColorspace
2323{
2424 /**
2525 * Channel class names of colorspace.
Original file line number Diff line number Diff line change 44
55namespace Intervention \Image \Colors \Oklab ;
66
7+ use Intervention \Image \Colors \AbstractColorspace ;
78use Intervention \Image \Colors \Cmyk \Color as CmykColor ;
89use Intervention \Image \Colors \Hsl \Color as HslColor ;
910use Intervention \Image \Colors \Hsv \Color as HsvColor ;
1516use Intervention \Image \Exceptions \InvalidArgumentException ;
1617use Intervention \Image \Exceptions \NotSupportedException ;
1718use Intervention \Image \Interfaces \ColorInterface ;
18- use Intervention \Image \Interfaces \ColorspaceInterface ;
1919use TypeError ;
2020
21- class Colorspace implements ColorspaceInterface
21+ class Colorspace extends AbstractColorspace
2222{
2323 /**
2424 * Channel class names of colorspace.
Original file line number Diff line number Diff line change 44
55namespace Intervention \Image \Colors \Oklch ;
66
7+ use Intervention \Image \Colors \AbstractColorspace ;
78use Intervention \Image \Colors \Cmyk \Color as CmykColor ;
89use Intervention \Image \Colors \Hsl \Color as HslColor ;
910use Intervention \Image \Colors \Hsv \Color as HsvColor ;
2021use Intervention \Image \Exceptions \InvalidArgumentException ;
2122use Intervention \Image \Exceptions \NotSupportedException ;
2223use Intervention \Image \Interfaces \ColorInterface ;
23- use Intervention \Image \Interfaces \ColorspaceInterface ;
2424use TypeError ;
2525
26- class Colorspace implements ColorspaceInterface
26+ class Colorspace extends AbstractColorspace
2727{
2828 /**
2929 * Channel class names of colorspace.
Original file line number Diff line number Diff line change 44
55namespace Intervention \Image \Colors \Rgb ;
66
7+ use Intervention \Image \Colors \AbstractColorspace ;
78use Intervention \Image \Colors \Cmyk \Color as CmykColor ;
89use Intervention \Image \Colors \Hsl \Color as HslColor ;
910use Intervention \Image \Colors \Hsv \Color as HsvColor ;
1617use Intervention \Image \Exceptions \NotSupportedException ;
1718use Intervention \Image \Interfaces \ColorChannelInterface ;
1819use Intervention \Image \Interfaces \ColorInterface ;
19- use Intervention \Image \Interfaces \ColorspaceInterface ;
2020use TypeError ;
2121
22- class Colorspace implements ColorspaceInterface
22+ class Colorspace extends AbstractColorspace
2323{
2424 /**
2525 * Channel class names of colorspace.
Original file line number Diff line number Diff line change 77interface ColorspaceInterface
88{
99 /**
10- * Convert given color to the format of the current colorspace.
10+ * Return array of all color channel classnames of the colorspace.
11+ *
12+ * @return array<string>
1113 */
12- public function importColor ( ColorInterface $ color ): ColorInterface ;
14+ public static function channels ( ): array ;
1315
1416 /**
1517 * Create new color in colorspace from given normalized (0-1) channel values.
1618 *
1719 * @param array<float> $normalized
1820 */
1921 public static function colorFromNormalized (array $ normalized ): ColorInterface ;
22+
23+ /**
24+ * Convert given color to the format of the current colorspace.
25+ */
26+ public function importColor (ColorInterface $ color ): ColorInterface ;
2027}
You can’t perform that action at this time.
0 commit comments