import math import pyglet # Set Size of Window WinWidth = 320 WinHeight = 240 window = pyglet.window.Window(WinWidth, WinHeight) GFXbatch = pyglet.graphics.Batch() background = pyglet.graphics.OrderedGroup(0) foreground = pyglet.graphics.OrderedGroup(1) # Calculate path for the flying text p = [] index=0 m=(WinWidth*1.5)/360.0 h=WinHeight/2 for l in range(360): p.extend((int(m*l), h + int(h*math.sin(math.radians(l))))) # Calculate tree pattern treeheight = WinHeight /3 treewidth = WinWidth /4 ox=0 oy=0 for ytree in range(3): oy = ytree * treeheight for xtree in range(4): ox = xtree * treewidth GFXbatch.add_indexed(3, pyglet.gl.GL_TRIANGLES, background, [0, 1, 2], ('v2i', (ox, oy, ox + int(treewidth/2), oy + treeheight, ox + treewidth, oy)), ('c3B', (0, 255, 42 + (50*xtree))*3 ) ) # Create text label label = pyglet.text.Label('Merry Christmas!', font_name='Arial', font_size=int(WinHeight/10), x=window.width//2, y=window.height//2, anchor_x='center', anchor_y='center', batch=GFXbatch, group=foreground) # Move on the text along the path def update(ts): global index index += 2 if index+1>len(p): index = 0 pyglet.clock.schedule_interval(update, 1/100.0) @window.event def on_draw(): global GFXbatch global label window.clear() label.x = p[index] label.y = p[index+1] GFXbatch.draw() pyglet.app.run()