Skip to content

Commit 1635b96

Browse files
committed
Fixes to pillow demo
1 parent b071a8c commit 1635b96

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

pymunk/examples/pillow_util_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from .shapes_for_draw_demos import fill_space
1414

15-
img = Image.new("RGB", (1000, 700), ImageColor.getrgb("white"))
15+
img = Image.new("RGB", (1000, 700), "white")
1616
draw = ImageDraw.Draw(img)
1717

1818
space = pymunk.Space()

pymunk/pillow_util.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,24 @@
4646

4747
class DrawOptions(pymunk.SpaceDebugDrawOptions):
4848
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.
5250
5351
Typical usage::
5452
5553
>>> import pymunk
56-
>>> surface = pygame.Surface((10,10))
54+
>>> from PIL import Image
55+
>>> image = Image.new("RGB", (1000, 700), "white")
5756
>>> space = pymunk.Space()
58-
>>> options = pymunk.pygame_util.DrawOptions(surface)
57+
>>> options = pymunk.pillow_util.DrawOptions(image)
5958
>>> space.debug_draw(options)
6059
6160
You can control the color of a shape by setting shape.color to the color
6261
you want it drawn in::
6362
6463
>>> 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)
7565
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
7967
8068
:Parameters:
8169
im : Image.Image

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
1010
[project]
1111
name = "pymunk"
1212
version = "7.1.0" # remember to change me for new versions!
13-
# Require cffi >1.14.0 since that (and older) has problem with returing structs from functions.
13+
# Require cffi >1.14.0 since that (and older) has problem with returning structs from functions.
1414
# Require cffi >= 1.17.1 since older cant work with latest setuptools version
1515
dependencies = [
1616
"cffi >= 1.17.1; platform_system != 'Emscripten'",

0 commit comments

Comments
 (0)