code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/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, 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 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 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/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 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
import unittest from pyglet.text.formats.attributed import AttributedTextDecoder class AttributedTextDecoderTests(unittest.TestCase): __noninteractive = True def testOneNewlineBecomesSpace(self): doc = AttributedTextDecoder().decode('one\ntwo') self.assertEqual(u'one two', doc.text) ...
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 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 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 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 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 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 load using the Python PNG loader. You should see the rgb_8bpp_trans.png image with a hole on it on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.png import PNGImageDecoder c...
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 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 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 '''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 pyg...
Python
#!/usr/bin/env python '''Test load using the Python gdkpixbuf2 GIF loader. You should see the 8bpp.gif image on a checkboard background. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest import base_load from pyglet.image.codecs.gdkpixbuf2 import GdkPixbuf2ImageDecoder clas...
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. ''' from __future__ import print_function __docformat__...
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 '''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
import sys def colorbyte(color): if sys.version.startswith('2'): return '%c' % color else: return bytes((color,))
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 '''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 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 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 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 RGB save using PIL with no PNG encode available, next available encoder will be used. 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__ ...
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 from pyglet import compat_platform if compat_...
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/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_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 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 '''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 '''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 load using the Python PNG loader. You should see the rgb_8bpp.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_INDEXED_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 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 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 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 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 '''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 ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from pyglet.gl import * from pyglet.image import * from pyglet.window import * from texture_base import colorbyte __noninteractive = True class TestTexture3D(unittest.TestCase): def create_image(self, widt...
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 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 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. ''' from __future__ import print_function __docformat_...
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 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 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 from pyglet import compat_platform if compat_platfo...
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 RGB load using PIL, decoder is not available and PYPNG decoder is used. 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 Image, PI...
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.startswith('linux'):...
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 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 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 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 from pyglet import compat_platform if compat_platform...
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 ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import unittest from pyglet.gl import * from pyglet.image import * from pyglet.window import * from texture_base import colorbyte __noninteractive = True class TestTextureGrid(unittest.TestCase): def set_grid_image(self, ...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest from pyglet.image import get_buffer_manager class ImageRegressionTestCase(unittest.TestCase): _enable_regression_image = False _enable_interactive = True _captured_image = None def capture_regress...
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 '''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 # 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
"""Tests clock timing between frames and estimations of frames per second. """ __docformat__ = 'restructuredtext' __version__ = '$Id$' import time import unittest from pyglet import clock __noninteractive = True class ClockTimingTestCase(unittest.TestCase): def setUp(self): # since clock is global, ...
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
import math import random from pyglet.gl import * import euclid M_2PI = math.pi * 2.0 class DisplayList(int): def draw(self): glCallList(self) def _TRI((v1, n1, t1, b1), (v2, n2, t2, b2), (v3, n3, t3, b3)): glNormal3f(n1[0], n1[1], n1[2]); glVertex3f(v1[0], v1[1], v1[2]) glNormal3f(n2[0], n2[1],...
Python
import os import warnings from pyglet.gl import * from pyglet import image class Material(object): diffuse = [.8, .8, .8] ambient = [.2, .2, .2] specular = [0., 0., 0.] emission = [0., 0., 0.] shininess = 0. opacity = 1. texture = None def __init__(self, name): self.name = nam...
Python
""" Wavefront OBJ renderer using pyglet's Batch class. Based on obj.py but this should be more efficient and uses VBOs when available instead of the deprecated display lists. First load the object: obj = OBJ("object.obj") Alternatively you can use `OBJ.from_resource(filename)` to load the object, materials and ...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: obj_test.py 111 2006-10-20 06:39:12Z r1chardj0n3s $' import sys import os import ctypes import pyglet from pyglet.gl import * from model import obj, geometric w = pyglet.window.Window() fourfv = ctypes.c_float * 4 glLightfv(GL_LI...
Python
#!/usr/bin/env python # # euclid graphics maths module # # Copyright (c) 2006 Alex Holkner # Alex.Holkner@mail.google.com # # 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 ...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id: gl_tree_test.py 114 2006-10-22 09:46:11Z r1chardj0n3s $' import math import random from pyglet.window import * from pyglet.window import mouse from pyglet import clock from ctypes import * from pyglet.window.event import * from pygl...
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/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/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_ORTHO(unittest.TestCase): def te...
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
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 ''' 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
#!/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 ''' ''' __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 ''' 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 ''' 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 ''' 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
#!/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
""" """ 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 ''' 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 '''Example of simple text wrapping without using layout. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' from pyglet.gl import * from pyglet.window import Window from pyglet.window import key from pyglet import clock from pyglet import font from scene2d.textsprite import * window =...
Python
import os import math import pyglet.window from resource import * from pyglet.window import key from pyglet import clock from scene2d import * class PlayerSprite(Sprite): bullets = [] def update(self, dt): self.x += (keyboard[key.RIGHT] - keyboard[key.LEFT]) * 200 * dt if self.left < 0: self.l...
Python
# Lots Of Sprites ''' Results (us per sprite per frame): sprites AMD64/mesa AMD64/nv6.6k MacBook Pro AMD/nv7.8k 2000 28.3 29.3 20.6 22.0 after __slots__ removal sprites AMD64/mesa AMD64/nv6.6k MacBook Pro AMD/nv7.8k 2000 ''' import os import sys import random from pyglet ...
Python
import os import math import pyglet.window from pyglet.window.event import * from pyglet.window import key from pyglet import clock from euclid import Vector2, Matrix3 from scene2d import * class CarSprite(RotatableSprite): def update(self, dt): # handle input and move the car self.angle += (keybo...
Python
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' from pyglet.window import Window from pyglet import clock from scene2d.textsprite import * from pyglet import font width, height = 640, 480 window = Window(width=width, height=height) arial = font.load('Arial', 500, bold=True) co...
Python
import sys sys.path.insert(0, '/home/richard/src/pyglet.googlecode.com/trunk') import os import math import pyglet.window from resource import * from pyglet.window import key from pyglet import clock from scene2d import * from scene2d.textsprite import * from pyglet import font from layout import * class RocketSpri...
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
#!/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 the sprite model. This test should just run without failing. ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' import unittest from pyglet.window import Window from pyglet.image import SolidColorImagePattern from scene2d import Sprite, Image2d class SpriteModelTest(unitt...
Python
#!/usr/bin/env python '''Testing flat map allow_oob enforcement. Press arrow keys to move view focal point (little ball) around map. Press "o" to turn allow_oob on and off. You should see no black border with allow_oob=False. Press escape or close the window to finish the test. ''' __docformat__ = 'restructuredtex...
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 flat map allow_oob enforcement. Press 0-9 to set the size of the view in the window (1=10%, 0=100%) Press arrow keys to move view focal point (little ball) around map. Press "o" to turn allow_oob on and off. You should see no black border with allow_oob=False. Press escape or close...
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 pygle...
Python