You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

115 lines
3.5 KiB

  1. #!/usr/bin/python2.4
  2. import caca
  3. import math
  4. from random import Random
  5. from math import *
  6. ret = caca.init()
  7. print "caca.init() returned ", ret
  8. print "Window size is ",caca.get_window_width(),"x",caca.get_window_height()
  9. print "Buffer size is ",caca.get_width(),"x",caca.get_height()
  10. caca.set_size(80,25)
  11. print "Buffer size is now",caca.get_width(),"x",caca.get_height()
  12. print "Feature name for CACA_DITHERING_FSTEIN is "+caca.get_feature_name(caca.CACA_DITHERING_FSTEIN)
  13. sprite = int(caca.load_sprite("./caca.txt"))
  14. rand = Random()
  15. i = 0
  16. while caca.get_event(caca.CACA_EVENT_KEY_PRESS) != caca.CACA_EVENT_KEY_PRESS|caca.CACA_KEY_ESCAPE:
  17. i=i+1;
  18. caca.clear();
  19. caca.set_color(caca.CACA_COLOR_YELLOW, caca.CACA_COLOR_BLACK);
  20. xo = caca.get_width() / 4;
  21. yo = caca.get_height() / 4 + 5 * sin(0.03*i);
  22. for j in range(0,16):
  23. xa = xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + 3.1415*j/8);
  24. ya = yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + 3.1415*j/8);
  25. caca.draw_thin_line(int(xo), int(yo), int(xa), int(ya));
  26. j = 15 + sin(0.03*i) * 8;
  27. caca.set_color(caca.CACA_COLOR_WHITE, caca.CACA_COLOR_BLACK);
  28. caca.fill_ellipse(int(xo), int(yo), int(j), int(j / 2), '#');
  29. caca.set_color(caca.CACA_COLOR_YELLOW, caca.CACA_COLOR_BLACK);
  30. caca.draw_ellipse(xo, yo, j, j / 2, '0');
  31. xo = caca.get_width() * 5 / 8;
  32. yo = 2;
  33. xa = caca.get_width() / 8 + sin(0.03*i) * 5;
  34. ya = caca.get_height() / 2 + cos(0.03*i) * 5;
  35. xb = caca.get_width() - 10 - cos(0.02*i) * 10;
  36. yb = caca.get_height() * 3 / 4 - 5 + sin(0.02*i) * 5;
  37. xc = caca.get_width() / 4 - sin(0.02*i) * 5;
  38. yc = caca.get_height() * 3 / 4 + cos(0.02*i) * 5;
  39. caca.set_color(caca.CACA_COLOR_GREEN, caca.CACA_COLOR_BLACK);
  40. caca.fill_triangle(xo, yo, xb, yb, xa, ya, '%');
  41. caca.set_color(caca.CACA_COLOR_YELLOW, caca.CACA_COLOR_BLACK);
  42. caca.draw_thin_triangle(xo, yo, xb, yb, xa, ya);
  43. caca.set_color(caca.CACA_COLOR_RED, caca.CACA_COLOR_BLACK);
  44. caca.fill_triangle(xa, ya, xb, yb, xc, yc, ' ');
  45. caca.set_color(caca.CACA_COLOR_YELLOW, caca.CACA_COLOR_BLACK);
  46. caca.draw_thin_triangle(xa, ya, xb, yb, xc, yc);
  47. caca.set_color(caca.CACA_COLOR_BLUE, caca.CACA_COLOR_BLACK);
  48. caca.fill_triangle(xo, yo, xb, yb, xc, yc, '%');
  49. caca.set_color(caca.CACA_COLOR_YELLOW, caca.CACA_COLOR_BLACK);
  50. caca.draw_thin_triangle(xo, yo, xb, yb, xc, yc);
  51. xa = 2;
  52. ya = 2;
  53. xb = caca.get_width() - 3;
  54. yb = caca.get_height() / 2;
  55. xc = caca.get_width() / 3;
  56. yc = caca.get_height() - 3;
  57. caca.set_color(caca.CACA_COLOR_CYAN, caca.CACA_COLOR_BLACK);
  58. caca.draw_thin_triangle(xa, ya, xb, yb, xc, yc);
  59. xo = caca.get_width() / 2 + cos(0.027*i) * caca.get_width() / 3;
  60. yo = caca.get_height() / 2 - sin(0.027*i) * caca.get_height() / 2;
  61. caca.draw_thin_line(xa, ya, xo, yo);
  62. caca.draw_thin_line(xb, yb, xo, yo);
  63. caca.draw_thin_line(xc, yc, xo, yo);
  64. caca.draw_sprite(xo, yo, sprite, 0);
  65. for j in range(i - 60, i):
  66. delta = (rand.random()*10)-5;
  67. caca.set_color(rand.random()*15, rand.random()*15);
  68. caca.putchar(caca.get_width() / 2
  69. + cos(0.02*j) * (delta + caca.get_width() / 4),
  70. caca.get_height() / 2
  71. + sin(0.02*j) * (delta + caca.get_height() / 3),
  72. ' ');
  73. caca.draw_sprite(caca.get_width() / 2 + cos(0.02*i) * caca.get_width() / 4,
  74. caca.get_height() / 2 + sin(0.02*i) * caca.get_height() / 3,
  75. int(sprite), int(0));
  76. caca.refresh();
  77. caca.end()