sabi / spritesheet-generator
There is no license information available for the latest version (dev-main) of this package.
Simple php library that combine seperated images(png) to one spritesheet image and replace background color with transparent and generate css
dev-main
2023-06-05 06:10 UTC
This package is auto-updated.
Last update: 2025-01-05 09:33:29 UTC
README
Simple php library that combine seperated images(png) to one spritesheet image and replace background color with transparent and generate css
Installation
Install with composer
composer require sabi/spritesheet-generator
Tech Stack
Server: PHP
Methods
__constructor
SpritesheetGenerator(tileWidth, tileHeight)
add images paths
->addImagesPaths(imagesPaths)
save generated spritesheet image
->saveSpritesheetTo(srcSpritesheetPath)
save css stylesheet
->saveStyleSheetTo(srcStylesheetPath, cssClassPrefix)
generate images sprite sheet and css stylesheet
->generateSheet()
Usage/Examples
<?php require '../vendor/autoload.php'; use Saber\SpritesheetGenerator\SpritesheetGenerator; $sg = new SpritesheetGenerator(48,48); $sg->addImagesPaths([ __DIR__.'/imgs/1.png', __DIR__.'/imgs/2.png', __DIR__.'/imgs/3.png', __DIR__.'/imgs/4.png' ]) ->generateSheet() ->saveSpritesheetTo('./menu-icons.png') ->saveStyleSheetTo('./menu-icons.css');