Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

polyline.php 926 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/php5
  2. <?php
  3. function transform($tbl, $tx, $ty, $sx, $sy) {
  4. $result = array();
  5. foreach($tbl as $pt)
  6. $result[] = array($pt[0] * $sx + $tx, $pt[1] * $sy + $ty);
  7. return $result;
  8. }
  9. $canvas = caca_create_canvas(0, 0);
  10. $display = caca_create_display($canvas);
  11. if (!$display) {
  12. die("Error while attaching canvas to display\n");
  13. }
  14. $tbl = array(
  15. array(5, 2),
  16. array(15, 2),
  17. array(20, 4),
  18. array(25, 2),
  19. array(34, 2),
  20. array(37, 4),
  21. array(36, 9),
  22. array(20, 16),
  23. array(3, 9),
  24. array(2, 4),
  25. array(5, 2)
  26. );
  27. for ($i = 0; $i < 10; $i++) {
  28. caca_set_color_ansi($canvas, 1 + (($color += 4) % 15), CACA_TRANSPARENT);
  29. $scale = caca_rand(4, 10) / 10;
  30. $translate = array(caca_rand(-5, 55), caca_rand(-2, 25));
  31. $pts = transform($tbl, $translate[0], $translate[1], $scale, $scale);
  32. caca_draw_thin_polyline($canvas, $pts);
  33. }
  34. caca_put_str($canvas, 1, 1, "Caca forever...");
  35. caca_refresh_display($display);
  36. sleep(5);
  37. ?>