cschoenfeld / colorizer
该软件包最新版本(dev-master)没有可用的许可证信息。
通过CSS生成SVG过滤器以着色图像。
dev-master
2016-03-18 16:05 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-26 00:24:49 UTC
README
Color helper classes.
Generate SVG filters that can be used to apply color overlays
to images in a web page via CSS.
@author Charles Schoenfeld
STEP 1:
To write an SVG filter definition into your HTML, do the following.
<?php
use CSchoenfeld\ColorSpec;
use CSchoenfeld\Colorizer;
try {
/*
In this example, you're trying to apply a 60% tint of orange
to some of the images in your page.
*/
$filterName = 'colorizeOrange';
$colorOrange = new CSchoenfeld\ColorSpec();
$colorOrange->setHex('f16234');
$colorStrength = 60;
$orangeFilter = CSchoenfeld\Colorizer::makeFilter($filterName, $colorOrange, $colorStrength);
echo $orangeFilter;
} catch (Exception $ex) {
// Handle any exceptions here.
}
?>
STEP 2:
Reference this filter in your CSS, for browsers that support it.
.orangeImage {
filter: url(#colorizeOrange);
-webkit-filter: url(#colorizeOrange);
}
And apply that CSS class to the image in your HTML.
<img src="myimage.png" class="orangeImage" alt="orange image">