]> git.sesse.net Git - ccbs/blob - bigscreen/tinyptc/python_test.py
Import TinyPTC 0.7.3 sources, switch from OpenGL to TinyPTC for now.
[ccbs] / bigscreen / tinyptc / python_test.py
1 #! /usr/bin/env python
2
3 # TinyPTC x11 v0.7.3 Python example
4 # Copyright (C) 2002 Alessandro Gatti <a.gatti@tiscali.it>
5 #
6 # http://www.sourceforge.net/projects/tinyptc/
7 #
8 # This library is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or (at your
11 # option) any later version.
12 #
13 # This library is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 # for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 import TinyPTC
23
24 WIDTH       = 320
25 HEIGHT      = 200
26 SIZE        = (WIDTH * HEIGHT)
27 noise       = None
28 carry       = None
29 counter     = None
30 pixel       = None
31 seed        = 0x12345
32
33 if not TinyPTC.ptc_open("Test", 320, 200):
34         raise Exception, "Can't open window!"
35
36 pixel = TinyPTC.pixel_array(SIZE)
37
38 while True:
39         for counter in range(SIZE):
40                 noise = seed
41                 noise = noise >> 3
42                 noise = noise ^ seed
43                 carry = noise & 1
44                 noise = noise >> 1
45                 seed = seed >> 1
46                 seed = seed | (carry << 30)
47                 noise = noise & 0xFF
48                 pixel[counter] = (noise << 16) | (noise << 8) | noise
49         TinyPTC.ptc_update(pixel)
50
51 TinyPTC.ptc_close()