定制 malenki/alpha-background 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

malenki/alpha-background

Composer 安装命令:

composer require malenki/alpha-background

包简介

README 文档

README

Alpha background are difficult with IE6, IE7 and IE8… So this is one of the solutions using PHP.

My little class allows you to generate small PNG image (1px×1px) to have background with alpha transparency, for IE7 and IE8.

To use it, many options are available for you:

  • use the class to include it into your source code. I provide for you composer.json file to make this easy
  • use a server script, I have written a little one for you
  • use a CLI script, to generate images by other way.

If you have some scruples to use an image for IE, I provide some features into my class to generate good line of CSS hacked for this browser of stone's age, so, IE6 is in this family too.

How to install it?

Composer

For custom use, by using my class to do what you want, use composer to include it into your project. In your composer.json file, include this:

"require": {
       "malenki/alpha-background": "*"
   }

Then, you can instanciate it by new \Malenki\AlphaBackground().

Taking source code

For a quick use, download the source, take CLI or server version of script, chaned it to create image like you want.

For custom use

Examples are better than long blahblah so, I start by showing you how to display at the browser the image:

$rgba = new AlphaBackground();
$rgba->red(255);
$rgba->green(150);
$rgba->blue(42);
$rgba->alpha(0.8);
$rgba->display();

You can do it in one line too:

$rgba = new AlphaBackground();
$rgba->red(255)->green(150)->blue(42)->alpha(0.8)->display();

You can use hexadecimal string too :

$rgba = new AlphaBackground();
$rgba->hex('#ff962acc')->display();

The hexadecimal string can be without alpha:

$rgba = new AlphaBackground();
$rgba->hex('#ff962a')->alpha(0.8)->display();

You can use CSS color name too:

$rgba = new AlphaBackground();
$rgba->name('orange')->alpha(0.7)->display();

If you want save the image, into all previous example, replace the last used method by save(), this method take one argument, the file's name:

$rgba = new AlphaBackground();
$rgba->name('orange')->alpha(0.7)->save('some_file.png');

For server

I have written a little script to put on a server to display background image. To use it, simply use the following lines into your CSS file.

background-image: url("/rgba-server.php?color=255,150,42,0.8");
background-image: url("/rgba-server.php?color=red,0.5");

The script is simple, but it works, you can changed it to deserve your own need.

For CLI

You can create background image by using a little CLI script I have written for you.

Following lines show you how to use it.

./rgba-cli -r 255 -g 150 -b 42 -a 0.8 -o image.png
./rgba-cli -n red -a 0.5 -o image.png
./rgba-cli --red 255 --green 150 --blue 42 --alpha 0.8 --output image.png
./rgba-cli --name red --alpha 0.5 --output image.png
./rgba-cli --hex ff962a --alpha 0.8 --output image.png
./rgba-cli --hex ff962acc --output image.png

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-11-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固