#!/usr/bin/env python3 import pyglet import glooey import run_demos from vecrec import Rect from pyglet.image import load window = pyglet.window.Window() batch = pyglet.graphics.Batch() rect = Rect.from_size(64 * 8, 64 * 6) rect.center = Rect.from_pyglet_window(window).center bg = glooey.drawing.Background(rect=rect, batch=batch) @run_demos.on_space(window, batch) def test_background(): # Make sure colors can be set, updated, and removed. bg.set_appearance(color='green') yield "Show a solid green background." bg.set_appearance(color='orange') yield "Change to a solid orange background." # Make sure outlines can be set, updated, and removed. bg.set_appearance(outline='green') yield "Show a solid green outline." bg.set_appearance(outline='orange') yield "Change to a solid orange outline."
import run_demos from vecrec import Vector, Rect window = pyglet.window.Window() batch = pyglet.graphics.Batch() rects = { # 'big': Rect.from_size(64*8, 64*6), 'small': Rect.from_size(64*4, 64*3), } images = { # 'green': pyglet.image.load('assets/64x64/green.png'), 'orange': pyglet.image.load('assets/64x64/orange.png'), } window_rect = Rect.from_pyglet_window(window) for rect in rects.values(): rect.center = window_rect.center artist = glooey.drawing.Tile(rects['big'], images['green'], vtile=True, htile=True, batch=batch) @run_demos.on_space(window, batch) def test_tile(): yield "Show a green pattern." artist.image = images['orange'] yield "Change to an orange pattern."
def get_territory(self): return Rect.from_pyglet_window(self.window)
#!/usr/bin/env python3 import pyglet import glooey import run_demos from vecrec import Vector, Rect window = pyglet.window.Window() batch = pyglet.graphics.Batch() full = Rect.from_pyglet_window(window) left = Rect(full.left, full.bottom, full.width/2, full.height) right = Rect(full.left, full.bottom, full.width/2, full.height) right.left = left.right left.shrink(50) right.shrink(50) @run_demos.on_space(window, batch) def test_outline(): a = glooey.drawing.Outline(left, batch=batch) b = glooey.drawing.Outline(right, batch=batch) yield "Show two unconnected outlines." a.hide() b.hide() c = glooey.drawing.Outline(full, batch=batch) yield "Put an outline just inside the window." c.hide() @window.event
def on_resize(self, width, height): rect = Rect.from_pyglet_window(self.window) self.resize(rect)
def __init__(self, window, batch=None, group=None): rect = Rect.from_pyglet_window(window) super().__init__(rect, window, batch, group)
#!/usr/bin/env python3 import pyglet import glooey import run_demos from vecrec import Rect from pyglet.image import load window = pyglet.window.Window() batch = pyglet.graphics.Batch() rect = Rect.from_size(64*8, 64*6) rect.center = Rect.from_pyglet_window(window).center bg = glooey.drawing.Background(rect=rect, batch=batch) @run_demos.on_space(window, batch) def test_background(): # Make sure colors can be set, updated, and removed. bg.set_appearance(color='green') yield "Show a solid green background." bg.set_appearance(color='orange') yield "Change to a solid orange background." # Make sure outlines can be set, updated, and removed. bg.set_appearance(outline='green') yield "Show a solid green outline." bg.set_appearance(outline='orange') yield "Change to a solid orange outline." # Make sure non-tiled images can be set, updated, and removed.
import run_demos from vecrec import Vector, Rect window = pyglet.window.Window() batch = pyglet.graphics.Batch() rects = { # 'big': Rect.from_size(64*8, 64*6), 'small': Rect.from_size(64*4, 64*3), } images = { # 'green': pyglet.image.load('assets/64x64/green.png'), 'orange': pyglet.image.load('assets/64x64/orange.png'), } window_rect = Rect.from_pyglet_window(window) for rect in rects.values(): rect.center = window_rect.center artist = glooey.drawing.Tile( rects['big'], images['green'], vtile=True, htile=True, batch=batch) @run_demos.on_space(window, batch) def test_tile(): yield "Show a green pattern." artist.image = images['orange'] yield "Change to an orange pattern." artist.image = images['green'] artist.rect = rects['small'] yield "Make the rect smaller."