File: example.5.inc

package info (click to toggle)
php-imlib 0.7-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,020 kB
  • ctags: 817
  • sloc: php: 2,464; ansic: 1,324; xml: 94; makefile: 67; sh: 12
file content (65 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<? if ($i != 5) { ?>
The image created by this script is available
<a href="examples.php?i=5">here</a>.
<hr size="1" width="70%" align="left" noshade>
<? } ?>

<pre>
&lt;?php

/*
 * This example is mostly for playing with color ranges (gradients)
 * and alpha channels.
 */

require './package.Imlib.php';

$red = Array(255,35,35,255);
$blue = Array(35,65,255,255);
$text = Array(200,220,255,255);
$shadow = Array(10,10,10,100);

// Create objects
$im = new ImlibImage;
$cr = new ImlibColorRange;
$d = new ImlibDraw;
$t = new ImlibText;

// Set up objects
$im-&gt;create(250,150);
$cr-&gt;create();
$cr-&gt;set_image($im-&gt;get_id());
$d-&gt;set_image($im-&gt;get_id());
$t-&gt;set_image($im-&gt;get_id());
$t-&gt;load('','banco.ttf','25');

// Large blue rectangle and gradient
$d-&gt;set_color(22,28,235,255);
$d-&gt;fill_rectangle(10,10,210,110);
$cr-&gt;add_color_array(0, $red);
$cr-&gt;add_color(0,0,225,225,255);
$cr-&gt;add_color_array(0, $blue);
$cr-&gt;fill_rectangle(15,15,200,100,125);

// Text with semitransparent shadow
$t-&gt;set_color_array($shadow);
$t-&gt;draw(43,48,'Showing off.');
$t-&gt;set_color_array($text);
$t-&gt;draw(40,45,'Showing off.');

// Purple semitransparent square
$d-&gt;set_color(195,105,195,127);
$d-&gt;fill_rectangle(30,90,50,50);

// Green-to-transparent gradient square
$cr-&gt;free();
$cr-&gt;create();
$cr-&gt;add_color(0,0,255,0,0);
$cr-&gt;add_color(0,0,255,0,50);
$cr-&gt;add_color(0,0,255,0,255);
$cr-&gt;fill_rectangle(90,90,50,50,235);

$im-&gt;save('testdraw.png',50);

?&gt;
</pre>