Making Gradient Jpgs.,


This script has two parts. The first is class.php. It must be in the same directory as the script to output the gradient. Class php is not used by you and not edited by you. It must be there for the script to work. The other script is what you will edit. This script does not disappear when the gradients are may be renamed to preserve the script before or simply changed to produce a new gradient. When viewing the gradient produced by the php script upload/transload to your webspace changing the extension to JPG.

Gradient Background

Gradients can be created with as many colors as you want and any size. In the gradient-1.php script we have a simple three color blended background.

Go into edit; these are the only lines of code you need to change:

//$gradient->addcolor(230,220,20,0); //$gradient->addcolor(240,170,20,50); //$gradient->addcolor(220,120,20,100);
//$display = $gradient->buildgradient(100,100);

The three gradient lines are your colors.....The first three numbers the RBG color. and the last number is the percentage each color has of the matter what the width is...In this case the center color is 50% of the width fading to 0 and fading to 100 with the colors on each side. The display line is the size. Here's what the above makes:

Tubular Gradients

To make tubular gradients the first and last color should be the same as the bgcolor it will be used on...In this case we'll use black.

NOTE: Color numbers below use Hex. It is just another way to define colors. Most people are more familiar with Hex and so it can save time. 0xNumbers 1&2; 0xNumbers 3&4, and 0xNumbers 5&6. Both ways will work inside the script simultaneously.

//$gradient->addcolor(00,00,00,0); //$gradient->addcolor(0x99,0x00,0xcc,50); //$gradient->addcolor(00,00,00,100);
//$display = $gradient->buildgradient(100,100);

The above makes this:

This is 0, 80,100. This is 0, 20,100


The following has many colors all separated by black.

addcolor(0x00,0x00,0x00,0); $gradient->addcolor(0x99, 0x00,0xcc,10); $gradient->addcolor(0x00,0x00,0x00,20); $gradient->addcolor(0x00, 0x00,0xff,30); $gradient->addcolor(0x00,0x00,0x00,40); $gradient->addcolor(0x00, 0x80,0x00,50); $gradient->addcolor(0x00,0x00,0x00,60); $gradient->addcolor(0x80, 0x00,0x00,70); $gradient->addcolor(0x00,0x00,0x00,80); $gradient->addcolor(0xff, 0x33,0x33,90); $gradient->addcolor(0x00,0x00,0x00,100);
$display = $gradient->buildgradient(100,30);

Each color is displayed in an increment of ten %. of the width, no matter how wide it is. The above is 100x30, and makes this:

This is exactly the same but the size has been changed to 300x200.

And this one is 150x300:

This zip file contains the class.php sript and all the scripts shown here, plus a text file of the two basic scripts...

GD BasicsHome