Last change
on this file since 3135 was
3135,
checked in by nico, 14 years ago
|
- Close php blocks in samples programs (add "?>")
|
-
Property svn:executable set to
*
|
File size:
926 bytes
|
Line | |
---|
1 | #!/usr/bin/php5 |
---|
2 | <?php |
---|
3 | |
---|
4 | function transform($tbl, $tx, $ty, $sx, $sy) { |
---|
5 | $result = array(); |
---|
6 | foreach($tbl as $pt) |
---|
7 | $result[] = array($pt[0] * $sx + $tx, $pt[1] * $sy + $ty); |
---|
8 | return $result; |
---|
9 | } |
---|
10 | |
---|
11 | $canvas = caca_create_canvas(0, 0); |
---|
12 | $display = caca_create_display($canvas); |
---|
13 | if (!$display) { |
---|
14 | die("Error while attaching canvas to display\n"); |
---|
15 | } |
---|
16 | |
---|
17 | $tbl = array( |
---|
18 | array(5, 2), |
---|
19 | array(15, 2), |
---|
20 | array(20, 4), |
---|
21 | array(25, 2), |
---|
22 | array(34, 2), |
---|
23 | array(37, 4), |
---|
24 | array(36, 9), |
---|
25 | array(20, 16), |
---|
26 | array(3, 9), |
---|
27 | array(2, 4), |
---|
28 | array(5, 2) |
---|
29 | ); |
---|
30 | |
---|
31 | for ($i = 0; $i < 10; $i++) { |
---|
32 | caca_set_color_ansi($canvas, 1 + (($color += 4) % 15), CACA_TRANSPARENT); |
---|
33 | $scale = caca_rand(4, 10) / 10; |
---|
34 | $translate = array(caca_rand(-5, 55), caca_rand(-2, 25)); |
---|
35 | $pts = transform($tbl, $translate[0], $translate[1], $scale, $scale); |
---|
36 | caca_draw_thin_polyline($canvas, $pts); |
---|
37 | } |
---|
38 | |
---|
39 | caca_put_str($canvas, 1, 1, "Caca forever..."); |
---|
40 | caca_refresh_display($display); |
---|
41 | sleep(5); |
---|
42 | |
---|
43 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.