X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=bigscreen%2Ftinyptc%2Fpython_test.py;fp=bigscreen%2Ftinyptc%2Fpython_test.py;h=6e9d08ef84d105b45928525ceda7bb4686fe883a;hp=0000000000000000000000000000000000000000;hb=140a0aae7299d15459fe9ec74ad5020887e0a960;hpb=fd56777b1051147ba14850b72f1f959cd82a1827 diff --git a/bigscreen/tinyptc/python_test.py b/bigscreen/tinyptc/python_test.py new file mode 100644 index 0000000..6e9d08e --- /dev/null +++ b/bigscreen/tinyptc/python_test.py @@ -0,0 +1,51 @@ +#! /usr/bin/env python + +# TinyPTC x11 v0.7.3 Python example +# Copyright (C) 2002 Alessandro Gatti +# +# http://www.sourceforge.net/projects/tinyptc/ +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +# for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import TinyPTC + +WIDTH = 320 +HEIGHT = 200 +SIZE = (WIDTH * HEIGHT) +noise = None +carry = None +counter = None +pixel = None +seed = 0x12345 + +if not TinyPTC.ptc_open("Test", 320, 200): + raise Exception, "Can't open window!" + +pixel = TinyPTC.pixel_array(SIZE) + +while True: + for counter in range(SIZE): + noise = seed + noise = noise >> 3 + noise = noise ^ seed + carry = noise & 1 + noise = noise >> 1 + seed = seed >> 1 + seed = seed | (carry << 30) + noise = noise & 0xFF + pixel[counter] = (noise << 16) | (noise << 8) | noise + TinyPTC.ptc_update(pixel) + +TinyPTC.ptc_close()