Laratone is a comprehensive Laravel package for managing color libraries and swatches in your applications. It provides an easy-to-use API for storing, retrieving, and managing color data, with built-in support for various color formats (HEX, RGB, CMYK, LAB) and popular color libraries., (*3)
Features
๐จ Multiple built-in color libraries (Pantone, GuangShun Thread, HC Twill)
๐ Automatic color data caching for improved performance
๐ฆ Easy color book management and seeding
๐ Flexible API for color searching and filtering
๐ ๏ธ Simple integration with Laravel applications
The published config file (config/laratone.php) contains the following options:, (*7)
return [
// Table prefix for Laratone tables
'table_prefix' => 'laratone_',
// Cache duration in seconds for color books and colors
'cache_time' => 3600,
];
Usage
Seeding Color Books
Laratone comes with several pre-built color libraries:, (*8)
{
"name": "My Custom Color Book",
"data": [
{
"name": "Custom Color 1",
"lab": "88.19,-6.97,111.73",
"hex": "FEDD00",
"rgb": "254,221,0",
"cmyk": "0,1,100,0"
}
]
}
API
Color Books
List all available color books:, (*10)
GET /api/laratone/colorbooks
Parameter
Required
Description
Default
sort
No
Sort by name (asc/desc)
asc
Colors
Get colors from a specific color book:, (*11)
GET /api/laratone/colorbook/{color-book-slug}
Parameter
Required
Description
Default
sort
No
Sort by name (asc/desc)
asc
limit
No
Limit number of results
-
random
No
Randomize results
false
Color Management
Laratone provides a simple API for managing colors programmatically:, (*12)
use Daikazu\Laratone\Laratone;
// Get all color books
$colorBooks = Laratone::colorBooks();
// Get a specific color book
$colorBook = Laratone::colorBookBySlug('color-book-plus-solid-coated');
// Create a new color book
$newColorBook = Laratone::createColorBook('My New Color Book');
// Add colors to a color book
$color = Laratone::addColorToBook($colorBook, [
'name' => 'New Color',
'hex' => 'FF0000',
'rgb' => '255,0,0'
]);
// Update a color
Laratone::updateColor($color, ['name' => 'Updated Color Name']);
// Delete a color
Laratone::deleteColor($color);
Caching
Laratone automatically caches color book and color data to improve performance. The cache duration can be configured in the config file. To clear the cache:, (*13)