mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-15 04:43:29 +00:00
Color palette support in byos_laravel
This commit is contained in:
parent
c157dcf3b6
commit
9ee7bc1aac
7 changed files with 236 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ enum ImageFormat: string
|
|||
case BMP3_1BIT_SRGB = 'bmp3_1bit_srgb';
|
||||
case PNG_8BIT_256C = 'png_8bit_256c';
|
||||
case PNG_2BIT_4C = 'png_2bit_4c';
|
||||
case PNG_INDEXED = 'png_indexed';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
|
|
@ -18,6 +19,7 @@ enum ImageFormat: string
|
|||
self::BMP3_1BIT_SRGB => 'BMP3 1-bit sRGB 2c',
|
||||
self::PNG_8BIT_256C => 'PNG 8-bit Grayscale Gray 256c',
|
||||
self::PNG_2BIT_4C => 'PNG 2-bit Grayscale 4c',
|
||||
self::PNG_INDEXED => 'PNG indexed',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
31
app/Enums/PaletteName.php
Normal file
31
app/Enums/PaletteName.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Bnussbau\TrmnlPipeline\Data\RgbColor;
|
||||
use InvalidArgumentException;
|
||||
|
||||
enum PaletteName: string
|
||||
{
|
||||
case SPECTRA_6 = 'spectra_6';
|
||||
|
||||
/**
|
||||
* @return RgbColor[]
|
||||
*/
|
||||
public static function getPalette(PaletteName $palette): array
|
||||
{
|
||||
switch ($palette) {
|
||||
case PaletteName::SPECTRA_6:
|
||||
return [
|
||||
RgbColor::fromComponents(0, 0, 0),
|
||||
RgbColor::fromComponents(255, 255, 255),
|
||||
RgbColor::fromComponents(255, 255, 0),
|
||||
RgbColor::fromComponents(255, 0, 0),
|
||||
RgbColor::fromComponents(0, 255, 0),
|
||||
RgbColor::fromComponents(0, 0, 255),
|
||||
];
|
||||
default:
|
||||
throw new InvalidArgumentException('Invalid palette name');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue