|
46 | 46 |
|
47 | 47 | class DrawOptions(pymunk.SpaceDebugDrawOptions): |
48 | 48 | def __init__(self, im: Image.Image) -> None: |
49 | | - """Draw a pymunk.Space on a pygame.Surface object. |
50 | | -
|
51 | | - This class should work both with Pygame and Pygame-CE. |
| 49 | + """Draw a pymunk.Space on a pillow Image object. |
52 | 50 |
|
53 | 51 | Typical usage:: |
54 | 52 |
|
55 | 53 | >>> import pymunk |
56 | | - >>> surface = pygame.Surface((10,10)) |
| 54 | + >>> from PIL import Image |
| 55 | + >>> image = Image.new("RGB", (1000, 700), "white") |
57 | 56 | >>> space = pymunk.Space() |
58 | | - >>> options = pymunk.pygame_util.DrawOptions(surface) |
| 57 | + >>> options = pymunk.pillow_util.DrawOptions(image) |
59 | 58 | >>> space.debug_draw(options) |
60 | 59 |
|
61 | 60 | You can control the color of a shape by setting shape.color to the color |
62 | 61 | you want it drawn in:: |
63 | 62 |
|
64 | 63 | >>> c = pymunk.Circle(None, 10) |
65 | | - >>> c.color = pygame.Color("pink") |
66 | | -
|
67 | | - See pygame_util.demo.py for a full example |
68 | | -
|
69 | | -
|
70 | | - >>> space = pymunk.Space() |
71 | | - >>> space.gravity = (0, -1000) |
72 | | - >>> body = pymunk.Body() |
73 | | - >>> body.position = (0, 0) # will be positioned in the top left corner |
74 | | - >>> space.debug_draw(options) |
| 64 | + >>> c.color = (255,0,0,255) |
75 | 65 |
|
76 | | - >>> body = pymunk.Body() |
77 | | - >>> body.position = (0, 0) |
78 | | - >>> # Body will be position in bottom left corner |
| 66 | + See pillow_util.demo.py for a full example |
79 | 67 |
|
80 | 68 | :Parameters: |
81 | 69 | im : Image.Image |
|
0 commit comments