File: example.4.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 (77 lines) | stat: -rw-r--r-- 1,930 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
66
67
68
69
70
71
72
73
74
75
76
77
<? if ($i != 4) { ?>
The image created by this script is available
<a href="examples.php?i=4">here</a>.
<hr size="1" width="70%" align="left" noshade>
<? } ?>

<pre>
&lt;?php

/*
 * This example draws a variety of shapes on an otherwise black image.
 * Demonstrates draw/filled rectangles, polygins, cliprects, ellipses, etc.
 */

require './class.ImlibImage.php';
require './class.ImlibColor.php';
require './class.ImlibText.php';
require './class.ImlibCliprect.php';
require './class.ImlibDraw.php';
require './class.ImlibPoly.php';

$im = new ImlibImage();
$im-&gt;create(225,260);

$outlinecolor = Array(255,0,0,255);
$color = Array(255,127,0,255);

$box = new ImlibDraw();
$box-&gt;set_image($im-&gt;get_id());
$box-&gt;set_color_array($outlinecolor);
$box-&gt;draw_rectangle(7,7,106,56);
$box-&gt;set_color_array($color);
$box-&gt;fill_rectangle(10,10,100,50);

$poly = new ImlibPoly();
$poly-&gt;new_poly();
$poly-&gt;set_image($im-&gt;get_id());
$poly-&gt;set_color(255,0,255,255);
$poly-&gt;add_point(100,100);
$poly-&gt;add_point(215,110);
$poly-&gt;add_point(150,215);
$poly-&gt;add_point(102,255);

// The cliprect will leave a gap in the middle of this polygon
$poly-&gt;set_cliprect(100,50,125,110);	// Draw the top
$poly-&gt;draw();
$poly-&gt;set_cliprect(100,190,125,70);	// Draw the bottom
$poly-&gt;draw();
$poly-&gt;free();

$poly-&gt;set_cliprect(0,0,0,0);	// Turns off the clipping rectangle
$poly-&gt;new_poly();
$poly-&gt;set_color(255,255,255,255);
$poly-&gt;add_point(106,106);
$poly-&gt;add_point(205,115);
$poly-&gt;add_point(147,211);
$poly-&gt;add_point(106,245);

$poly-&gt;draw();
$poly-&gt;free();

// This will draw a few pseudo-randomly colored ellipses
$j = 30;
for ($i = 90; $i &lt; 260; $i += 20)
{
   $box-&gt;set_color($i,$i*2,255-$i*2,255);
   $box-&gt;draw_ellipse($j,$i,10,$j/2);
   $j += 20;
   if ($j &gt; 70)
      $j = 25;
}

$im-&gt;save('./draw.png');
$im-&gt;free();

?&gt;
</pre>