25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test2.py 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/python2.3
  2. import caca
  3. import math
  4. from random import Random
  5. from math import *
  6. import Numeric as N
  7. ret = caca.init()
  8. r = N.zeros(256)
  9. g = N.zeros(256)
  10. b = N.zeros(256)
  11. a = N.zeros(256)
  12. rand = Random()
  13. # Our pixel array
  14. pixels = N.zeros(32*32*4)
  15. #pixels = pixelst.tolist()
  16. for i in range(0,256):
  17. r[i] = i
  18. g[i] = i
  19. b[i] = i
  20. a[i] = 128
  21. bitmap = caca.create_bitmap(32,32,32,32*4,0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)
  22. #caca.set_bitmap_palette(bitmap, r, g, b, a)
  23. color = 0
  24. while caca.get_event(caca.CACA_EVENT_KEY_PRESS) != caca.CACA_EVENT_KEY_PRESS|caca.CACA_KEY_ESCAPE:
  25. for y in range(0,32):
  26. for x in range(0,(32*4), 4):
  27. offset = x + y * (32*4)
  28. pixels[offset] = rand.random()*256
  29. pixels[offset+1] = rand.random()*256
  30. pixels[offset+2] = rand.random()*256
  31. pixels[offset+3] = 128
  32. color = color + 1
  33. caca.draw_bitmap(0,0,caca.get_width() - 1, caca.get_height() - 1,
  34. bitmap, pixels)
  35. caca.refresh();
  36. caca.end();