~ubuntu-branches/ubuntu/raring/libcaca/raring

« back to all changes in this revision

Viewing changes to python/test2.py

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2007-11-25 19:08:40 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071125190840-3r4k9nkxsyo7m3ck
Tags: 0.99.beta13b-1
* New upstream release.

* debian/control:
  + Do not build-depend on the whole texlive suite, but on more fine-grained
    packages. Thanks to Norbert Preining for the hints (latex -recorder, then
    inspect the .fls file).
* Ship libcaca++, libcucul++ and their development files.

Show diffs side-by-side

added added

removed removed

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