|
.g.e.n.e.r.a.l.
.p.h.p. .c.o.d.e.
.j.a.v.a.s.c.r.i.p.t. .c.o.d.e.
Modified in < 3 days.
Misc. Stats For This Page
Operating Systems
Browsers
|
.t.r.a.n.s.p.a.r.e.n.t. .i.m.a.g.e.s.
Creating transparent images on the fly with php is actually rather easy. At first it
may look difficult but if you have ever created an image on the fly with php you will
see that it's not much different.
The best way for me to learn anything new is with an example. Let's start with an array of values that we want to put in a line graph. The array keys will be our X-axis and their corresponding values will be our Y-axis.
$my_values = array (
Here's the code to create the image:
<?php The important things to notice are
$transparent_color = imagecolorallocate($image, 255, 0, 0); In the first line we are allocating a color that we will use as the transparent color, in this case red. The second line actually sets the transparent color. Anything that we "paint" red will be considered transparent later on. This color can be anything you wish but you must make sure that it is not a color that you will need in your image! The third line fills our entire image with the transparent color. This makes the entire image transparent. Now all we have to do is add the items on top of that that are not transparent. What makes this cool is that we can now change the background of the graph rather easily. You could use an image, change the color, anything you wish with out ever having to go back and modify the actual php code. This also makes it much easier to port to other projects since you no longer have to consider what or where the image will be placed. Now for the final results!Click any of the following to change the background of the image. |
||||||||||||||||||||||||||||||||||||||||||||
|
The trademarks, logos and service marks ("Marks") displayed on this Web site are the property of cKorp or other third parties.
You are not permitted to use these Marks without the prior written consent of cKorp or such third party which may own the Mark.
Use of cKorp trademarks almost always requires written permission or a license.
|
|||||||||||||||||||||||||||||||||||||||||||||