File: test2.py

package info (click to toggle)
libcaca 0.99.beta14-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 6,720 kB
  • ctags: 2,334
  • sloc: ansic: 18,652; cs: 1,171; objc: 835; cpp: 741; makefile: 446; sh: 289; python: 215; ruby: 190; asm: 93
file content (56 lines) | stat: -rwxr-xr-x 1,103 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python2.3

import caca
import math
from random import Random
from math import *
import Numeric as N

ret = caca.init()

r = N.zeros(256)
g = N.zeros(256)
b = N.zeros(256)
a = N.zeros(256)

rand = Random()

# Our pixel array
pixels = N.zeros(32*32*4)
#pixels = pixelst.tolist()

for i in range(0,256):
    r[i] = i
    g[i] = i
    b[i] = i
    a[i] = 128

        
bitmap = caca.create_bitmap(32,32,32,32*4,0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)
#caca.set_bitmap_palette(bitmap, r, g, b, a)


color = 0

while caca.get_event(caca.CACA_EVENT_KEY_PRESS) != caca.CACA_EVENT_KEY_PRESS|caca.CACA_KEY_ESCAPE:

    for y in range(0,32):
         for x in range(0,(32*4), 4):
            offset = x + y * (32*4)
            pixels[offset]   = rand.random()*256
            pixels[offset+1] = rand.random()*256
            pixels[offset+2] = rand.random()*256
            pixels[offset+3] = 128
            

        
    color = color + 1

    caca.draw_bitmap(0,0,caca.get_width() - 1, caca.get_height() - 1,
                     bitmap, pixels)
        
    caca.refresh();



caca.end();