andrewgjohnson / imagegradientrectangle
imagegradientrectangle is a function that will draw a gradient filled rectangle on your PHP GD images
Package info
github.com/andrewgjohnson/imagegradientrectangle
pkg:composer/andrewgjohnson/imagegradientrectangle
Requires
- php: >=8.0.0
- ext-gd: *
- andrewgjohnson/agjgd: ^2.0
Requires (Dev)
- phpunit/phpunit: ^12.5
- squizlabs/php_codesniffer: ^3.13
README
Description
imagegradientrectangle is a function that will draw a gradient filled rectangle on your PHP GD images.
As of v2.0.0 imagegradientrectangle is part of AgjGd. The implementation now lives in the \AndrewGJohnson\AgjGd class provided by the andrewgjohnson/agjgd package, and this package provides the standalone imagegradientrectangle() function as a thin reverse-compatibility wrapper around it.
New code should call \AndrewGJohnson\AgjGd::imagegradientrectangle() directly.
imagegradientrectangle is an agjgd project.
Examples
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$blue = imagecolorallocate($im, 0x00, 0x00, 0xFF);
// Standard method to draw solid filled rectangles
imagefilledrectangle($im, 10, 10, 100, 100, $red);
imagefilledrectangle($im, 10, 10, 100, 100, $blue);
// This will draw a red-to-blue gradient filled rectangle (vertical gradient)
imagegradientrectangle($im, 10, 10, 100, 100, $red, $blue);
// This will draw a red-to-blue gradient filled rectangle (horizontal gradient)
imagegradientrectangle($im, 10, 10, 100, 100, $red, $blue, true);
There are other examples included in the GitHub repository and on imagegradientrectangle.agjgd.org.
Usage
With Composer
This project offers support for the Composer dependency manager. You can find the imagegradientrectangle package online on packagist.org.
Install using Composer
Either run this command:
composer require andrewgjohnson/imagegradientrectangle
or add this to the require section of your composer.json file:
"andrewgjohnson/imagegradientrectangle": "^2.0"
This package requires PHP 8.0 or newer, the GD extension and the andrewgjohnson/agjgd package, which Composer installs automatically.
Without Composer
Because imagegradientrectangle() now forwards to the \AndrewGJohnson\AgjGd class, you need both this wrapper and AgjGd. Composer is the recommended way to install them, but you can also require both source files directly:
require_once 'path/to/agjgd/source/AndrewGJohnson/AgjGd.php';
require_once 'source/imagegradientrectangle.php';
Dependencies
As of v2.0.0 this project has a single dependency, andrewgjohnson/agjgd, which provides the \AndrewGJohnson\AgjGd class this wrapper forwards to. Prior to v2.0.0 this project depended on imageblendedcolorallocate, which AgjGd now supersedes.
Help Requests
Please post any questions in the discussions area on GitHub if you need help.
If you discover a bug please enter an issue on GitHub. When submitting an issue please use our issue templates.
Contributing
Please read our contributing guidelines if you want to contribute.
You can contribute financially by becoming a patron at patreon.com/agjopensource to support imagegradientrectangle and other agjgd.org projects.
Acknowledgements
This project was started by Andrew G. Johnson (@andrewgjohnson).
Full list of contributors:
Our security policies and procedures come via the atomist/samples project. Our issue templates come via the tensorflow/tensorflow project. Our pull request template comes via the stevemao/github-issue-templates project. The Jekyll theme was released by Andrew G. Johnson.
Changelog
You can find all notable changes in the changelog.
