Last change
on this file since 3132 was
3132,
checked in by nico, 14 years ago
|
- Change type of the last argument of drawing function (from string to long)
- Adapt sample programs
|
-
Property svn:executable set to
*
|
File size:
923 bytes
|
Rev | Line | |
---|
[3131] | 1 | #!/usr/bin/php5 |
---|
| 2 | <?php |
---|
| 3 | |
---|
[3132] | 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 | |
---|
[3131] | 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; |
---|
[3132] | 34 | $translate = array(caca_rand(-5, 55), caca_rand(-2, 25)); |
---|
[3131] | 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); |
---|
[3132] | 42 | |
---|
Note: See
TracBrowser
for help on using the repository browser.