Changeset 3105 for libcaca/trunk/caca-php/examples
- Timestamp:
- Oct 26, 2008, 1:40:00 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca-php/examples/example1.php
r3104 r3105 35 35 36 36 37 caca_set_color_ansi($pig, CACA_LIGHT RED, CACA_WHITE);37 caca_set_color_ansi($pig, CACA_LIGHTMAGENTA, CACA_TRANSPARENT); 38 38 caca_import_memory($pig, $pig_str, "text"); 39 caca_blit($canvas, caca_get_canvas_width($canvas) / 2 - 20, caca_get_canvas_height($canvas) /2 - 7, $pig); 40 caca_refresh_display($display); 39 caca_set_display_time($display, 30000); 41 40 42 sleep(5); 41 $x = $y = 0; 42 $ix = $iy = 1; 43 43 44 while (caca_get_event($display, CACA_EVENT_KEY_PRESS)) { 45 // In case of resize ... 46 if ($x + caca_get_canvas_width($pig) - 1 >= caca_get_canvas_width($canvas) || $x < 0 ) 47 $x = 0; 48 if ($y + caca_get_canvas_height($pig) - 1 >= caca_get_canvas_height($canvas) || $y < 0 ) 49 $y = 0; 44 50 51 caca_clear_canvas($canvas); 52 53 // Draw pig 54 caca_blit($canvas, $x, $y, $pig); 55 caca_refresh_display($display); 56 57 $x += $ix; 58 $y += $iy; 59 60 if ($x + caca_get_canvas_width($pig) >= caca_get_canvas_width($canvas) || $x < 0 ) 61 $ix = -$ix; 62 if ($y + caca_get_canvas_height($pig) >= caca_get_canvas_height($canvas) || $y < 0 ) 63 $iy = -$iy; 64 } 65
Note: See TracChangeset
for help on using the changeset viewer.