def __init__(self): self.win = pyglet.window.Window(800, 600) self.win.push_handlers(self) squirtle.setup_gl() #Sets up blending so we get anti-aliased edges. self.sky = squirtle.SVG( "svgs/sky.svg") #Anchors default to bottom left self.sun = squirtle.SVG("svgs/sun.svg", anchor_x='center', anchor_y='center') self.cloud = squirtle.SVG("svgs/cloud.svg", anchor_x='right', anchor_y='top') self.tile = squirtle.SVG("svgs/tile.svg", anchor_x='center', anchor_y='center') self.cloud_locs = [(random.uniform(0, 928), random.uniform(0, 728), random.uniform(1, 2)) for n in xrange(10)] self.cloud_locs = sorted(self.cloud_locs, key=lambda x: x[2]) self.time_elapsed = 0 self.fps = pyglet.clock.ClockDisplay() pyglet.clock.schedule_interval(self.tick, 1 / 60.0) pyglet.app.run()
def __init__(self, width=320, height=240, resizable=True, visible=True): super(main, self).__init__(resizable=resizable) self.svg = None self.width = width self.height = height squirtle.setup_gl() self.text = "" self.set_mouse_visible(True) self.set_caption('Labglass Prototype') icon1 = pyglet.image.load('./res/icon.png') self.set_icon(icon1) self.scrollbar = scrollbar(400, 350, 30, 200, (125, 125, 125), (255, 120, 0), (0, 120, 255), "text", True) self.savebutton = button(10, 100, 100, 30, (125, 125, 125), (255, 120, 0), "Save") self.exportbutton = button(10, 50, 100, 30, (125, 125, 125), (255, 120, 0), "Export") self.loadbutton = button(10, 200, 100, 30, (125, 125, 125), (255, 120, 0), "Load") self.ismousedown = False self.selectedelement = None self.exportimageindex = 0 self.testcontainer = glasswarecontainer(10, 300, 250, 150, 30, (200, 200, 200), (255, 120, 0), (0, 120, 255), "glass", [""]) self.linkcontainer = glasswarecontainer(10, 100, 250, 150, 30, (200, 200, 200), (255, 120, 0), (0, 120, 255), "links", ["arrow_0.svg"])
def setup_gl(self): """Configure GL properties. """ self.window.switch_to() squirtle.setup_gl() glClearColor(0.0, 0.0, 0.0, 1.0) self.window.clear() self.window.flip()
def __init__(self): self.win = pyglet.window.Window(800, 600) self.win.push_handlers(self) squirtle.setup_gl() #Sets up blending so we get anti-aliased edges. self.sky = squirtle.SVG("svgs/sky.svg") #Anchors default to bottom left self.sun = squirtle.SVG("svgs/sun.svg", anchor_x='center', anchor_y='center') self.cloud = squirtle.SVG("svgs/cloud.svg", anchor_x='right', anchor_y='top') self.cloud_locs = [(random.uniform(0, 928), random.uniform(0, 728), random.uniform(1, 2)) for n in xrange(10)] self.cloud_locs = sorted(self.cloud_locs, key=lambda x: x[2]) self.time_elapsed = 0 self.fps = pyglet.clock.ClockDisplay() pyglet.clock.schedule_interval(self.tick, 1/60.0) pyglet.app.run()
def __init__(self): mode.Mode.__init__(self) squirtle.setup_gl() self.background = squirtle.SVG("resources/backdrop.svg") self.health_bar = squirtle.SVG("resources/health_bar.svg") self.crossHair = CrossHair() self.crossHair.handler = self self.target_controller = TargetController(TargetController.MEDIUM) self._update_difficulty(TargetController.MEDIUM) self.runtime=time.time() self.timestamp=0 self.hits=0 self.miss=0 self.score=0 self.health_loss = 0 GameMode.hlaugh.play()
def __init__(self, width=1024, height=768): super(VisualizerWindow, self).__init__(width=width, height=height, resizable=False) squirtle.setup_gl() self.half_width = width / 2 self.half_height = height / 2 helv = font.load('Helvetica', width / 50.0) self.label = font.Text(helv, 'Hello, World!', x=width / 2, y=height / 2, halign=font.Text.CENTER, valign=font.Text.CENTER, color=(1, 0, 0, 1), ) pyglet.clock.schedule_interval(self.update,1/30.0) glClearColor(255,255,255,255) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) self.set_3D() self.modelViewMatrix = (GLdouble * 16)() self.projectionMatrix = (GLdouble * 16)() self.viewport = (GLint * 4)() glGetDoublev(GL_MODELVIEW_MATRIX, self.modelViewMatrix) glGetDoublev(GL_PROJECTION_MATRIX, self.projectionMatrix) glGetIntegerv(GL_VIEWPORT, self.viewport) self.buttons = Buttons(os.path.join(sys.path[0], './theme'), self) self.control_width = 0.37*width self.input_height = 0.37*width self.sun = squirtle.SVG('sun.svg', anchor_x='center', anchor_y='center') self.mouse_x = 0 self.mouse_y = 0
def draw(canvas): canvas.clear() nofill() stroke(0, 0.25) strokewidth(1) rect( 50, 50, 50, 50) rect(110, 50, 50, 50, stroke=Color(0), strokestyle=DASHED) rect(170, 50, 50, 50) glClearColor(1,1,1,1) squirtle.setup_gl() s = squirtle.SVG(filename) s.anchor_x, s.anchor_y = s.width/2, s.height/2 zoom = 1 angle = 0 draw_x = 400 draw_y = 300 s.draw(draw_x, draw_y, scale=zoom, angle=angle)
import squirtle config = pyglet.gl.Config(sample_buffers=1, samples=4) w = pyglet.window.Window(config=config, resizable=True) #w = pyglet.window.Window(800, 600) keys = pyglet.window.key.KeyStateHandler() w.push_handlers(keys) glClearColor(1,1,1,1) glEnable(GL_LINE_SMOOTH) glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glLineWidth(2) squirtle.setup_gl() filelist = [f for f in os.listdir('svgs') if f.endswith('svg') or f.endswith('svgz')] filename = None svgObj = None def nextFile(): global filename, svgObj if not filename: next = 0 else: prevFile = os.path.basename(filename) next = filelist.index(prevFile)+1 next %= len(filelist) filename = os.path.join('svgs', filelist[next])
#! usr/bin/env python import os import sys import pyglet from pyglet.gl import * import squirtle w = pyglet.window.Window(800, 600) keys = pyglet.window.key.KeyStateHandler() w.push_handlers(keys) glClearColor(1,1,1,1) glEnable(GL_LINE_SMOOTH) squirtle.setup_gl() filelist = [f for f in os.listdir('svgs') if f.endswith('svg') or f.endswith('svgz')] filename = None svgObj = None def nextFile(): global filename, svgObj if not filename: next = 0 else: prevFile = os.path.basename(filename) next = filelist.index(prevFile)+1 next %= len(filelist) filename = os.path.join('svgs', filelist[next]) print 'Parsing', filename