code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/env python '''Test that text events work correctly. Expected behaviour: One window will be opened. Type into this window and check the console output for text events. - Repeated when keys are held down - Motion events (e.g., arrow keys, HOME/END, etc) are reported - Select events ...
Python
#!/usr/bin/env python '''Test that a non-resizable window's size can be set. Expected behaviour: One window will be opened. The window's dimensions will be printed to the terminal. - press "x" to increase the width - press "X" to decrease the width - press "y" to increase the height - ...
Python
#!/usr/bin/env python '''Test that mouse enter and leave events work correctly. Expected behaviour: One window will be opened. Move the mouse in and out of this window and ensure the events displayed are correct. Close the window or press ESC to end the test. ''' __docformat__ = 'restructuredtext' __ve...
Python
#!/usr/bin/python # $Id:$ from pyglet.gl import * def draw_client_border(window): glClearColor(0, 0, 0, 1) glClear(GL_COLOR_BUFFER_BIT) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0, window.width, 0, window.height, -1, 1) glMatrixMode(GL_MODELVIEW) glLoadIdentity()...
Python
#!/usr/bin/env python '''Test that a window can be opened fullscreen. Expected behaviour: A fullscreen window will be created, with a flat purple colour. - Press 'g' to leave fullscreen mode and create a window. - Press 'f' to re-enter fullscreen mode. - All events will be printed to the console. ...
Python
#!/usr/bin/env python '''Test that resize event works correctly. Expected behaviour: One window will be opened. Resize the window and ensure that the dimensions printed to the terminal are correct. You should see a green border inside the window but no red. Close the window or press ESC to end the ...
Python
#!/usr/bin/env python '''Test that window can be resized. Expected behaviour: One window will be opened. It should be resizable by the user. Close the window or press ESC to end the test. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: WINDOW_SET_MOUSE_CURSOR.py 717 2007-03-03 07:04:10Z Alex.Ho...
Python
#!/usr/bin/env python '''Test that mouse cursor can be set to a platform-dependent image. Expected behaviour: One window will be opened. Press the left and right arrow keys to cycle through the system mouse cursors. The current cursor selected will be printed to the terminal. Note that not all curs...
Python
#!/usr/bin/env python '''Test that multiple windows can be opened. Expected behaviour: Two small windows will be opened, one coloured yellow and the other purple. Close either window or press ESC to end the test. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from pyglet...
Python
#!/usr/bin/python # $Id:$ import unittest import time class BaseEventSequence(unittest.TestCase): next_sequence = 0 last_sequence = 0 finished = False timeout = 2 start_time = time.time() def check_sequence(self, sequence, name): if self.next_sequence == 0 and sequence != 0: ...
Python
#!/usr/bin/env python '''Test that window can be set fullscreen and back again. Expected behaviour: One window will be opened. - press "f" to enter fullscreen mode. - press "g" to leave fullscreen mode. All events will be printed to the terminal. Close the window or press ESC to end the tes...
Python
#!/usr/bin/env python '''Test that the window caption can be set. Expected behaviour: Two windows will be opened, one with the caption "Window caption 1" counting up every second; the other with a Unicode string including some non-ASCII characters. Press escape or close either window to finished the ...
Python
#!/usr/bin/env python '''Test that all public modules are accessible after importing just 'pyglet'. This _must_ be the first test run. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: TICK.py 310 2006-12-23 15:56:35Z Alex.Holkner $' import unittest import pyglet __noninteractive = True modules = [ ...
Python
#!/usr/bin/env python '''Test load using the Python BMP loader. You should see the rgb_24bpp.bmp image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.bmp import BMPImageDecoder class TEST_SUITE(base_lo...
Python
#!/usr/bin/env python '''Test DXT1 compressed RGBA load from a DDS file. You should see the rgba_dxt1.dds image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.dds import DDSImageDecoder class TEST_DDS_...
Python
#!/usr/bin/env python '''Test RGBA save using PyPNG. You should see rgba.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest...
Python
#!/usr/bin/env python '''Test LA load using PyPNG. You should see the la.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.png import PNGImageDecoder class TEST_PNG_LA_LOAD(base_load.TestLoad):...
Python
#!/usr/bin/env python '''Test LA load using PIL. You should see the la.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.pil import * class TEST_PNG_LA(base_load.TestLoad): texture_file = ...
Python
#!/usr/bin/env python '''Test rearrangement of color components using the OpenGL color matrix. The test will be skipped if the GL_ARB_imaging extension is not present. You should see the RGBA test image correctly rendered. Press ESC to end the test. ''' __docformat__ = 'restructuredtext' __version__ = '$I...
Python
#!/usr/bin/env python '''Test LA load using the platform decoder (QuickTime, Quartz, GDI+ or Gdk). You should see the la.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load import sys if sys.platform == 'linux2': from p...
Python
#!/usr/bin/env python '''Test RGB load using PyPNG. You should see the rgb.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import base_load from pyglet.image.codecs.png import PNGImageDecoder class TEST_PNG_RGB_LOAD(base_load.TestL...
Python
#!/usr/bin/env python '''Test DXT3 compressed RGBA load from a DDS file. You should see the rgba_dxt3.dds image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.dds import DDSImageDecoder class TEST_DDS_...
Python
#!/usr/bin/env python '''Test rearrangement of color components using the OpenGL color matrix. The test will be skipped if the GL_ARB_imaging extension is not present. You should see the RGB test image correctly rendered. Press ESC to end the test. ''' __docformat__ = 'restructuredtext' __version__ = '$Id...
Python
#!/usr/bin/env python '''Test load using the Python BMP loader. You should see the rgb_32bpp.bmp image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.bmp import BMPImageDecoder class TEST_SUITE(base_lo...
Python
#!/usr/bin/python # $Id:$ import unittest from pyglet.image import atlas __noninteractive = True class Rect(object): def __init__(self, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 def __repr__(self): return 'Rect(%d, %d to %d, %d)' % ( ...
Python
#!/usr/bin/env python '''Test RGB load using the platform decoder (QuickTime, Quartz, GDI+ or Gdk). You should see the rgb.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import base_load import sys if sys.platform == 'linux2': fr...
Python
#!/usr/bin/env python '''Test load using the Python BMP loader. You should see the rgba_32bpp.bmp image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.bmp import BMPImageDecoder class TEST_SUITE(base_l...
Python
#!/usr/bin/env python '''Test L load using PyPNG. You should see the l.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.png import PNGImageDecoder class TEST_PNG_L_LOAD(base_load.TestLoad): ...
Python
#!/usr/bin/env python '''Test RGB load using PIL. You should see the rgb.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import base_load from pyglet.image.codecs.pil import * class TEST_PIL_RGB_LOAD(base_load.TestLoad): textu...
Python
#!/usr/bin/env python '''Test load using the Python BMP loader. You should see the rgb_4bpp.bmp image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.bmp import BMPImageDecoder class TEST_SUITE(base_loa...
Python
#!/usr/bin/env python '''Test RGBA save using PIL. You should see rgba.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest ...
Python
#!/usr/bin/env python '''Test RGBA load using PIL. You should see the rgba.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import base_load from pyglet.image.codecs.pil import * class TEST_PIL_RGBA_LOAD(base_load.TestLoad): te...
Python
#!/usr/bin/env python '''Test DXT5 compressed RGBA load from a DDS file. You should see the rgba_dxt5.dds image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.dds import DDSImageDecoder class TEST_DDS_...
Python
#!/usr/bin/env python '''Test colour buffer save. A scene consisting of a single coloured triangle will be rendered. The colour buffer will then be saved to a stream and loaded as a texture. You will see the original scene first for up to several seconds before the buffer image appears (because retrieving...
Python
#!/usr/bin/env python '''Test DXT1 compressed RGB load from a DDS file. You should see the rgb_dxt1.dds image. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.dds import DDSImageDecoder class TEST_DDS_RGB_DXT1(base_load.TestLoad):...
Python
#!/usr/bin/env python '''Test load using the Python BMP loader. You should see the rgb_1bpp.bmp image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.bmp import BMPImageDecoder class TEST_SUITE(base_loa...
Python
#!/usr/bin/env python '''Base class for image tests. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from StringIO import StringIO from os.path import dirname, join from pyglet.gl import * from pyglet import image from pyglet.image import codecs from pyglet.window import * from pyglet....
Python
#!/usr/bin/env python '''Test RGBA load using PyPNG. You should see the rgba.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import base_load from pyglet.image.codecs.png import PNGImageDecoder class TEST_PNG_RGBA_LOAD(base_load.Te...
Python
#!/usr/bin/env python '''Test L load using PIL. You should see the la.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.pil import * class TEST_PIL_L(base_load.TestLoad): texture_file = 'l...
Python
#!/usr/bin/env python '''Test RGB save using PIL. You should see rgb.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest im...
Python
#!/usr/bin/env python '''Test colour buffer copy to texture. A scene consisting of a single coloured triangle will be rendered. The colour buffer will then be saved to a stream and loaded as a texture. You will see the original scene first for up to several seconds before the buffer image appears (because r...
Python
#!/usr/bin/env python '''Base class for image tests. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from os.path import dirname, join from pyglet.gl import * from pyglet import image from pyglet.image import codecs from pyglet.window import * from pyglet.window.event import * from te...
Python
#!/usr/bin/env python '''Test LA save using PyPNG. You should see la.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest impo...
Python
#!/usr/bin/env python '''Test L load using the platform decoder (QuickTime, Quartz, GDI+ or Gdk). You should see the l.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load import sys if sys.platform == 'linux2': from pyg...
Python
#!/usr/bin/env python '''Test LA save using PIL. You should see la.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import...
Python
#!/usr/bin/env python '''Test L save using PIL. You should see l.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import b...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from pyglet.gl import * from pyglet.image import * from pyglet.window import * __noninteractive = True class TestTextureGrid(unittest.TestCase): def set_grid_image(self, itemwidth, itemheight, rows, cols, r...
Python
#!/usr/bin/env python '''Test depth buffer save. A scene consisting of a single coloured triangle will be rendered. The depth buffer will then be saved to a stream and loaded as a texture. You will see the original scene first for up to several seconds before the depth buffer image appears (because retrie...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from pyglet.gl import * from pyglet.image import * from pyglet.window import * __noninteractive = True class TestTexture3D(unittest.TestCase): def create_image(self, width, height, color): data = ('...
Python
#!/usr/bin/env python '''Test that the checkerboard pattern looks correct. One window will open, it should show one instance of the checkerboard pattern in two levels of grey. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from pyglet.gl import * from pyglet import image from pyglet....
Python
#!/usr/bin/env python '''Test load using the Python BMP loader. You should see the rgb_16bpp.bmp image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.bmp import BMPImageDecoder class TEST_SUITE(base_lo...
Python
#!/usr/bin/env python '''Test L save using PyPNG. You should see l.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import...
Python
#!/usr/bin/env python '''Test RGB save using PyPNG. You should see rgb.png reference image on the left, and saved (and reloaded) image on the right. The saved image may have larger dimensions due to texture size restrictions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest ...
Python
#!/usr/bin/env python '''Test load using the Python BMP loader. You should see the rgb_8bpp.bmp image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.bmp import BMPImageDecoder class TEST_SUITE(base_loa...
Python
#!/usr/bin/env python '''Test RGBA load using the platform decoder (QuickTime, Quartz, GDI+ or Gdk). You should see the rgba.png image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import base_load import sys if sys.platform == 'linux2': ...
Python
#!/usr/bin/env python '''Test framework for pyglet. Reads details of components and capabilities from a requirements document, runs the appropriate unit tests. Overview -------- First, some definitions: Test case: A single test, implemented by a Python module in the tests/ directory. Tests can be interacti...
Python
#!/usr/bin/env python '''Test that inline elements can have their style changed, even after text has been deleted before them. [This triggers bug 538 if it has not yet been fixed.] To run the test, delete the first line, one character at a time, verifying that the element remains visible and no tracebacks are printed...
Python
#!/usr/bin/env python '''Test that HTML data is decoded into a formatted document. Press ESC to exit the test. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: ELEMENT.py 1764 2008-02-16 05:24:46Z Alex.Holkner $' import unittest import pyglet from pyglet.text import caret, document, layout doctext = ''' ...
Python
#!/usr/bin/env python '''Test that an empty document doesn't break, even when its (nonexistent) text is set to bold. ''' __docformat__ = 'restructuredtext' __noninteractive = True import unittest from pyglet import gl from pyglet import graphics from pyglet.text import document from pyglet.text import layout from ...
Python
#!/usr/bin/env python '''Test that character and paragraph-level style is adhered to correctly in incremental layout. Examine and type over the text in the window that appears. The window contents can be scrolled with the mouse wheel. There are no formatting commands, however formatting should be preserved as expec...
Python
#!/usr/bin/python # $Id:$ from pyglet.text import runlist import unittest __noninteractive = True class TestStyleRuns(unittest.TestCase): def check_value(self, runs, value): for i, style in enumerate(value): self.assertTrue(runs[i] == style, repr(runs.runs)) self.check_optimal(runs) ...
Python
#!/usr/bin/env python '''Test that an empty document doesn't break. ''' __docformat__ = 'restructuredtext' __noninteractive = True import unittest from pyglet import gl from pyglet import graphics from pyglet.text import document from pyglet.text import layout from pyglet import window class TestWindow(window.Win...
Python
#!/usr/bin/env python '''Test that the code snippets mentioned in issue 471 (and related issues 241 and 429) don't have exceptions. (Most of them delete all text in a formatted document with some styles set; one of them (like the test in EMPTY_BOLD.py) sets style on a 0-length range of text in an empty document.) '''...
Python
#!/usr/bin/env python '''Test an unformatted document is editable. Examine and type over the text in the window that appears. The window contents can be scrolled with the mouse wheel. Press ESC to exit the test. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: STYLE.py 1754 2008-02-10 13:26:52Z Alex.Holk...
Python
#!/usr/bin/env python '''Test that inline elements are positioned correctly and are repositioned within an incremental layout. Examine and type over the text in the window that appears. There are several elements drawn with grey boxes. These should maintain their sizes and relative document positions as the text is...
Python
#!/usr/bin/env python '''Test content_valign = 'center' property of IncrementalTextLayout. Examine and type over the text in the window that appears. The window contents can be scrolled with the mouse wheel. When the content height is less than the window height, the content should be aligned to the center of the w...
Python
#!/usr/bin/env python '''Test content_valign = 'bottom' property of IncrementalTextLayout. Examine and type over the text in the window that appears. The window contents can be scrolled with the mouse wheel. When the content height is less than the window height, the content should be aligned to the bottom of the w...
Python
#!/usr/bin/env python '''Test that a scheduled function gets called every interval with the correct time delta. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: TICK.py 310 2006-12-23 15:56:35Z Alex.Holkner $' import time import unittest from pyglet import clock __noninteractive = True class SCHEDULE_IN...
Python
#!/usr/bin/env python '''Test that the clock effectively limits the FPS to 20 Hz when requested. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import time import unittest from pyglet import clock __noninteractive = True class FPS_LIMIT(unittest.TestCase): def test_fps_limit(self): clock....
Python
#!/usr/bin/env python '''Test that a scheduled function gets called every tick with the correct time delta. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: TICK.py 310 2006-12-23 15:56:35Z Alex.Holkner $' import time import unittest from pyglet import clock __noninteractive = True class SCHEDULE(unitte...
Python
#!/usr/bin/env python # Contributed by Claudio Canepa # Integrated by Ben Smith """ There is the possibility that time.clock be non monotonic in multicore hardware, due to the underlaying use of win32 QueryPerformanceCounter. If your update is seeing a negative dt, then time.clock is probably the culprit. AM...
Python
#!/usr/bin/env python '''Test that the clock returns a reasonable average FPS calculation when stimulated at 5 Hz. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import time import unittest from pyglet import clock __noninteractive = True class FPS(unittest.TestCase): def test_fps(self): ...
Python
#!/usr/bin/env python '''Test that the clock tick function returns the elaspsed time between frames, in seconds. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import time import unittest from pyglet import clock __noninteractive = True class TICK(unittest.TestCase): def test_tick(self): ...
Python
#!/usr/bin/env python '''Test that a scheduled function gets called every once with the correct time delta. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: TICK.py 310 2006-12-23 15:56:35Z Alex.Holkner $' import time import unittest from pyglet import clock __noninteractive = True class SCHEDULE_ONCE(u...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import pyglet from graphics_common import * __noninteractive = True class TEST_CASE(unittest.TestCase): def check(self, expected, result, dimensions): if len(expected) != len(result) * dimensions /...
Python
#!/usr/bin/python # $Id:$ import random import unittest from pyglet.graphics import allocation __noninteractive = True class Region(object): def __init__(self, start, size): self.start = start self.size = size def __repr__(self): return 'Region(%r, %r)' % (self.start, self.size) cl...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest import pyglet from graphics_common import * __noninteractive = True class TEST_CASE(unittest.TestCase): def check(self, expected, result, dimensions): if len(expected) != len(result) * dimensions /...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' from operator import add import random from pyglet.gl import * n_vertices = 42 v3f_data = [v/float(n_vertices*3 + 10) for v in range(n_vertices * 3)] v2f_data = reduce(add, zip(v3f_data[::3], v3f_data[1::3])) c4f_data = [v/floa...
Python
#!/usr/bin/python # $Id:$ import unittest import pyglet from graphics_common import * __noninteractive = True class TEST_CASE(unittest.TestCase): def check(self, expected, result, dimensions): if len(expected) != len(result) * dimensions / 4: self.fail('Incorrect number of vertices in feedb...
Python
#!/usr/bin/python # $Id:$ import unittest import pyglet from graphics_common import * __noninteractive = True class TEST_CASE(unittest.TestCase): def check(self, expected, result, dimensions): if len(expected) != len(result) * dimensions / 4: self.fail('Incorrect number of vertices in feedb...
Python
#!/usr/bin/env python '''Draws a full-window quad with two texture units enabled and multi texcoords. Texture unit 0 is a checker pattern of yellow and cyan with env mode replace. Texture unit 1 is a checker pattern of cyan and yellow, with env mode modulate. The result should be flat green (with some variation in ...
Python
#!/usr/bin/python # $Id:$ '''OpenGL viewports and projections. This is a simplified interface for setting up projections, and viewports within projections. A `Viewport` is a rectangular area in space that can be rendered into. Most viewports, with the exception of the top-level viewport, belong to an owning project...
Python
#!/usr/bin/python # $Id:$ from pyglet.gl import * def fillrect(x, y, width, height): glBegin(GL_QUADS) glVertex2f(x, y) glVertex2f(x + width, y) glVertex2f(x + width, y + height) glVertex2f(x, y + height) glEnd() def rect(x, y, width, height): glBegin(GL_LINE_LOOP) glVertex2f(x, y) ...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: WINDOW_OPEN.py 750 2007-03-17 01:16:12Z Alex.Holkner $' import unittest from pyglet.gl import * from pyglet.ext import projection from pyglet import window import base_projection class VIEWPORT_CLIP(unittest.TestCase): def tes...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: WINDOW_OPEN.py 750 2007-03-17 01:16:12Z Alex.Holkner $' import unittest from pyglet.gl import * from pyglet.ext import projection from pyglet import window import base_projection class VIEWPORT_ORTHO(unittest.TestCase): def te...
Python
#!/usr/bin/env python ''' Model code for managing sprites =============================== ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' from pyglet.gl import * from scene2d.drawable import * class SpriteLayer(object): '''Represents a group of sprites at the same z depth. ''' def __init__...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' from ctypes import * from pyglet.gl import * from scene2d.sprite import Sprite from pyglet.font import GlyphString # TODO: inherit from Sprite class TextSprite(object): _layout_width = None # Width to layout text to _tex...
Python
#!/usr/bin/env python ''' Simple images etc. to aid debugging =================================== ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import math from scene2d import * from pyglet import image from scene2d.drawable import * from pyglet.gl import * def brensenham_line(x, y, x2, y2): '''...
Python
from pyglet.gl import * class DrawEnv(object): '''Sets up drawing environment. My have either or both of a "before" and "after" method. ''' pass class DrawBlended(DrawEnv): '''Sets up texture env for an alpha-blended draw. ''' def before(self): glPushAttrib(GL_ENABLE_BIT | GL_CO...
Python
#!/usr/bin/env python ''' Management of tile sets ======================= ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import os import xml.dom import xml.dom.minidom from scene2d.image import Image2d, Drawable from resource import Resource, register_factory from scene2d.drawable import * @registe...
Python
#!/usr/bin/env python ''' Model code for managing rectangular and hexagonal maps ====================================================== This module provides classes for managing rectangular and hexagonal maps. --------------- Getting Started --------------- You may create a map interactively and query it: TBD '''...
Python
#!/usr/bin/env python ''' View code for displaying 2d scenes of maps and sprites ====================================================== --------------- Getting Started --------------- Creating a simple scene and displaying it: >>> import pyglet.window >>> import scene2d >>> m = scene2d.RectMap(32, 32, c...
Python
""" """ from scene2d.map import RectMap, HexMap, RectCell, HexCell from scene2d.camera import FlatCamera from scene2d.view import FlatView, ViewScrollHandler from scene2d.sprite import Sprite, RotatableSprite, SpriteLayer from scene2d.image import Image2d from scene2d.tile import TileSet, Tile __all__ = [ 'RectMap', ...
Python
#!/usr/bin/env python ''' Draw OpenGL textures in 2d scenes ================================= --------------- Getting Started --------------- You may create a drawable image with: >>> from scene2d import * >>> i = Image2d.load('kitten.jpg') >>> i.draw() ''' __docformat__ = 'restructuredtext' __version...
Python
#!/usr/bin/env python ''' Camera for projecting 2d flat scenes ==================================== ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' from pyglet.gl import * from pyglet.event import * class Camera(object): def project(self): '''Set up the GL projection matrix. Leave us in GL_...
Python
#!/usr/bin/env python ''' Support for loading XML resource files ====================================== This module provides the Resource class which loads XML resource files which may contain scene2d image files, atlases, tile sets and maps. --------------- Getting Started --------------- Assuming the following XM...
Python
#!/usr/bin/env python '''Testing a sprite. The ball should bounce off the sides of the window. You may resize the window. This test should just run without failing. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import os import unittest from pyglet.gl import glClear import pyglet.window import pygl...
Python
#!/usr/bin/env python '''Testing hex map debug rendering. You should see a checkered hex map. Press escape or close the window to finish the test. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest from render_base import RenderBase import scene2d from scene2d.debug import gen_hex_map cla...
Python
#!/usr/bin/env python '''Testing loading of a map. You should see a simple map with a circular road on it. The tiles are not well-designed :) Press escape or close the window to finish the test. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import os import unittest from render_base import RenderBase...
Python
#!/usr/bin/env python '''Testing mouse interaction The cell the mouse is hovering over should highlight in red. Clicking in a cell should highliht that cell green. Clicking again will clear the highlighting. Clicking on the ball sprite should highlight it and not underlying cells. You may press the arrow keys to s...
Python