def main(): pygame.init() screen = pygame.display.set_mode((1000,700)) clock = pygame.time.Clock() font = pygame.font.SysFont("Arial", 16) space = pymunk.Space() captions = shapes_for_draw_demos.fill_space(space) ### Draw it screen.fill(pygame.color.THECOLORS["white"]) options = pymunk.pygame_util.DrawOptions(screen) space.debug_draw(options) #pymunk.pygame_util.draw(screen, space) # Info color = pygame.color.THECOLORS["black"] screen.blit(font.render("Demo example of pygame_util.DrawOptions()", 1, color), (205, 680)) for caption in captions: x, y = caption[0] y = 700 - y screen.blit(font.render(caption[1], 1, color), (x,y)) pygame.display.flip() while True: for event in pygame.event.get(): if event.type == QUIT or \ event.type == KEYDOWN and (event.key in [K_ESCAPE, K_q]): return elif event.type == KEYDOWN and event.key == K_p: pygame.image.save(screen, "pygame_util_demo.png") clock.tick(10)
def main(): pygame.init() screen = pygame.display.set_mode((1000, 700)) clock = pygame.time.Clock() font = pygame.font.SysFont("Arial", 16) pymunk.pygame_util.positive_y_is_up = True space = pymunk.Space() captions = shapes_for_draw_demos.fill_space(space) ### Draw it screen.fill(pygame.Color("white")) options = pymunk.pygame_util.DrawOptions(screen) space.debug_draw(options) # pymunk.pygame_util.draw(screen, space) # Info color = pygame.Color("black") screen.blit( font.render("Demo example of pygame_util.DrawOptions()", True, color), (205, 680), ) for caption in captions: x, y = caption[0] y = 700 - y screen.blit(font.render(caption[1], True, color), (x, y)) pygame.display.flip() while True: for event in pygame.event.get(): if ( event.type == pygame.QUIT or event.type == pygame.KEYDOWN and (event.key in [pygame.K_ESCAPE, pygame.K_q]) ): return elif event.type == pygame.KEYDOWN and event.key == pygame.K_p: pygame.image.save(screen, "pygame_util_demo.png") clock.tick(10)
__docformat__ = "reStructuredText" import sys import pyglet import pymunk from pymunk.vec2d import Vec2d import pymunk.pyglet_util import shapes_for_draw_demos window = pyglet.window.Window(1000, 700, vsync=False) space = pymunk.Space() draw_options = pymunk.pyglet_util.DrawOptions() captions = shapes_for_draw_demos.fill_space(space) textbatch = pyglet.graphics.Batch() pyglet.text.Label('Demo example of shapes drawn by pyglet_util.draw()', x=5, y=5, batch=textbatch, color=(100, 100, 100, 255)) for caption in captions: x, y = caption[0] y = y - 10 pyglet.text.Label(caption[1], x=x, y=y, batch=textbatch, color=(50, 50, 50, 255))
import matplotlib.pyplot as plt from shapes_for_draw_demos import fill_space import pymunk import pymunk.matplotlib_util from pymunk.vec2d import Vec2d space = pymunk.Space() captions = fill_space(space, (1, 1, 0, 1)) fig = plt.figure(figsize=(14, 10)) ax = plt.axes(xlim=(0, 1000), ylim=(0, 700)) ax.set_aspect("equal") for caption in captions: x, y = caption[0] y = y - 15 ax.text(x, y, caption[1], fontsize=12) o = pymunk.matplotlib_util.DrawOptions(ax) space.debug_draw(o) fig.savefig("matplotlib_util_demo.png", bbox_inches="tight")
__docformat__ = "reStructuredText" import sys import pyglet import pymunk from pymunk.vec2d import Vec2d import pymunk.pyglet_util import shapes_for_draw_demos window = pyglet.window.Window(1000, 700, vsync=False) space = pymunk.Space() draw_options = pymunk.pyglet_util.DrawOptions() captions = shapes_for_draw_demos.fill_space(space) textbatch = pyglet.graphics.Batch() pyglet.text.Label('Demo example of shapes drawn by pyglet_util.draw()', x=5, y=5, batch=textbatch, color=(100,100,100,255)) for caption in captions: x, y = caption[0] y = y - 10 pyglet.text.Label(caption[1], x=x, y=y, batch=textbatch, color=(50,50,50,255)) batch = pyglet.graphics.Batch() # otherwise save screenshot wont work _ = pyglet.clock.ClockDisplay()