
import pyglet
import glooey
import vecrec
from glooey.drawing import green, orange

print(__doc__)

window = pyglet.window.Window()
batch = pyglet.graphics.Batch()

rect_1 = vecrec.Rect.from_pyglet_window(window)
rect_1.shrink(50)
rect_2 = rect_1 + (10,-10)

bg = pyglet.graphics.OrderedGroup(0)
fg = pyglet.graphics.OrderedGroup(1)

artist_1 = glooey.drawing.Rectangle(rect_1, color=green, batch=batch, group=bg)
artist_2 = glooey.drawing.Rectangle(rect_2, color=orange, batch=batch, group=fg)

@window.event
def on_draw():
    print('(draw)')
    window.clear()
    batch.draw()

@window.event
def on_mouse_press(self, *args):
    print("- green in front")
    artist_1.group = fg
    artist_2.group = bg

@window.event
def on_mouse_release(self, *args):
    print("- orange in front")
    artist_1.group = bg
    artist_2.group = fg


pyglet.app.run()



import pyglet
import glooey
import vecrec
from glooey.drawing import green, orange

print(__doc__)

window = pyglet.window.Window()
batch = pyglet.graphics.Batch()

rect_1 = vecrec.Rect.from_pyglet_window(window)
rect_1.shrink(50)
rect_2 = rect_1 + (10,-10)

bg = pyglet.graphics.OrderedGroup(0)
fg = pyglet.graphics.OrderedGroup(1)

artist_1 = glooey.drawing.Rectangle(rect_1, color=green, batch=batch, group=bg)
artist_2 = glooey.drawing.Rectangle(rect_2, color=orange, batch=batch, group=fg)

@window.event
def on_draw():
    window.clear()
    batch.draw()

@window.event
def on_mouse_press(self, *args):
    print("- green in front")
    artist_1.group = fg
    artist_2.group = bg

@window.event
def on_mouse_release(self, *args):
    print("- orange in front")
    artist_1.group = bg
    artist_2.group = fg


pyglet.app.run()


Make the test a bit more verbose.
Make the test a bit more verbose.

  
  import pyglet
  import glooey
  import vecrec
  from glooey.drawing import green, orange
  
  print(__doc__)
  
  window = pyglet.window.Window()
  batch = pyglet.graphics.Batch()
  
  rect_1 = vecrec.Rect.from_pyglet_window(window)
  rect_1.shrink(50)
  rect_2 = rect_1 + (10,-10)
  
  bg = pyglet.graphics.OrderedGroup(0)
  fg = pyglet.graphics.OrderedGroup(1)
  
  artist_1 = glooey.drawing.Rectangle(rect_1, color=green, batch=batch, group=bg)
  artist_2 = glooey.drawing.Rectangle(rect_2, color=orange, batch=batch, group=fg)
  
  @window.event
  def on_draw():
-     print('(draw)')
      window.clear()
      batch.draw()
  
  @window.event
  def on_mouse_press(self, *args):
      print("- green in front")
      artist_1.group = fg
      artist_2.group = bg
  
  @window.event
  def on_mouse_release(self, *args):
      print("- orange in front")
      artist_1.group = bg
      artist_2.group = fg
  
  
  pyglet.app.run()
  
  
Make the test a bit more verbose.
## Code Before:

import pyglet
import glooey
import vecrec
from glooey.drawing import green, orange

print(__doc__)

window = pyglet.window.Window()
batch = pyglet.graphics.Batch()

rect_1 = vecrec.Rect.from_pyglet_window(window)
rect_1.shrink(50)
rect_2 = rect_1 + (10,-10)

bg = pyglet.graphics.OrderedGroup(0)
fg = pyglet.graphics.OrderedGroup(1)

artist_1 = glooey.drawing.Rectangle(rect_1, color=green, batch=batch, group=bg)
artist_2 = glooey.drawing.Rectangle(rect_2, color=orange, batch=batch, group=fg)

@window.event
def on_draw():
    print('(draw)')
    window.clear()
    batch.draw()

@window.event
def on_mouse_press(self, *args):
    print("- green in front")
    artist_1.group = fg
    artist_2.group = bg

@window.event
def on_mouse_release(self, *args):
    print("- orange in front")
    artist_1.group = bg
    artist_2.group = fg


pyglet.app.run()


## Instruction:
Make the test a bit more verbose.
## Code After:

import pyglet
import glooey
import vecrec
from glooey.drawing import green, orange

print(__doc__)

window = pyglet.window.Window()
batch = pyglet.graphics.Batch()

rect_1 = vecrec.Rect.from_pyglet_window(window)
rect_1.shrink(50)
rect_2 = rect_1 + (10,-10)

bg = pyglet.graphics.OrderedGroup(0)
fg = pyglet.graphics.OrderedGroup(1)

artist_1 = glooey.drawing.Rectangle(rect_1, color=green, batch=batch, group=bg)
artist_2 = glooey.drawing.Rectangle(rect_2, color=orange, batch=batch, group=fg)

@window.event
def on_draw():
    window.clear()
    batch.draw()

@window.event
def on_mouse_press(self, *args):
    print("- green in front")
    artist_1.group = fg
    artist_2.group = bg

@window.event
def on_mouse_release(self, *args):
    print("- orange in front")
    artist_1.group = bg
    artist_2.group = fg


pyglet.app.run()

