ucscode / php-svg-piano
A PHP library for generating SVG representations of a piano keyboard with customizable styles and note highlights.
Requires
- php: >=8.2
- ucscode/uss-element: ^3.5
Requires (Dev)
- phpunit/phpunit: ^10
- symfony/var-dumper: ^7.2
README
PhpSvgPiano is a PHP library for generating SVG representations of a piano keyboard with customizable styles and note highlights.
PhpSvgPiano was inspired by the Svguitar library and brings a similar SVG-based approach to piano visualization.
Features
- Generate a scalable SVG piano keyboard
- Highlight pressed keys
- Customize key colors and text styles
- Define octave range and accidental preferences
- Object-oriented and easy to extend
Installation
Install via Composer:
composer require ucscode/php-svg-piano
Usage
Basic Example
use Ucscode\PhpSvgPiano\Piano; $piano = new Piano("C4 E4 G4"); echo $piano->render();
This will generate an SVG with C4, E4, and G4 pressed.
Documentation
The documentation covers basic information from installation and usage to advanced configuration and customization options.
For detailed information, visit the documentation page.
Contributing
Contributions are welcome. Feel free to:
- Report issues
- Submit feature requests
- Fork and improve the library
License
This project is licensed under the MIT License. See the LICENSE file for details.
Inspiration
PhpSvgPiano was inspired by the Svguitar library, which provides an SVG-based approach for rendering guitar chord diagrams. This project extends the concept to the piano, offering a flexible and object-oriented solution for generating customizable SVG piano keyboards.