drawzero 0.4.4__tar.gz → 0.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. drawzero-0.4.5/PKG-INFO +310 -0
  2. {drawzero-0.4.4 → drawzero-0.4.5}/setup.py +3 -3
  3. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/__about__.py +1 -1
  4. drawzero-0.4.5/src/drawzero/examples/dummy.py +12 -0
  5. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/converters.py +7 -1
  6. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/pt.py +11 -11
  7. drawzero-0.4.5/src/drawzero.egg-info/PKG-INFO +310 -0
  8. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero.egg-info/SOURCES.txt +10 -3
  9. drawzero-0.4.5/tests/test_converters.py +124 -0
  10. drawzero-0.4.5/tests/test_copy_examples.py +26 -0
  11. drawzero-0.4.5/tests/test_errors.py +71 -0
  12. drawzero-0.4.5/tests/test_examples_gui_mode.py +86 -0
  13. drawzero-0.4.5/tests/test_examples_text_mode.py +84 -0
  14. drawzero-0.4.5/tests/test_gradient.py +35 -0
  15. drawzero-0.4.5/tests/test_i18n.py +16 -0
  16. drawzero-0.4.5/tests/test_pt.py +16 -0
  17. drawzero-0.4.4/PKG-INFO +0 -309
  18. drawzero-0.4.4/docs/pt.rst +0 -0
  19. drawzero-0.4.4/src/drawzero.egg-info/PKG-INFO +0 -309
  20. drawzero-0.4.4/src/drawzero.egg-info/entry_points.txt +0 -3
  21. {drawzero-0.4.4 → drawzero-0.4.5}/LICENSE +0 -0
  22. {drawzero-0.4.4 → drawzero-0.4.5}/MANIFEST.in +0 -0
  23. {drawzero-0.4.4 → drawzero-0.4.5}/README.md +0 -0
  24. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_00.png +0 -0
  25. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_01.png +0 -0
  26. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_02.png +0 -0
  27. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_03.png +0 -0
  28. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_04.png +0 -0
  29. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_05.png +0 -0
  30. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_06.png +0 -0
  31. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_10.png +0 -0
  32. {drawzero-0.4.4 → drawzero-0.4.5}/docs/ex_13.png +0 -0
  33. {drawzero-0.4.4 → drawzero-0.4.5}/docs/hello_world.png +0 -0
  34. {drawzero-0.4.4 → drawzero-0.4.5}/docs/keyboard_and_mouse_events.gif +0 -0
  35. {drawzero-0.4.4 → drawzero-0.4.5}/docs/planet_animation.gif +0 -0
  36. {drawzero-0.4.4 → drawzero-0.4.5}/docs/transparent.png +0 -0
  37. {drawzero-0.4.4 → drawzero-0.4.5}/setup.cfg +0 -0
  38. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/__init__.py +0 -0
  39. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/__main__.py +0 -0
  40. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/00_hello_world.py +0 -0
  41. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/01_grid_and_coordinates.py +0 -0
  42. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/02_loops_and_rgb_colors.py +0 -0
  43. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/03_simple_objects.py +0 -0
  44. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/04_loops_sin_plot.py +0 -0
  45. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/05_points.py +0 -0
  46. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/06_turtle_style.py +0 -0
  47. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/07_animation_circles.py +0 -0
  48. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/08_animation_traffic_light.py +0 -0
  49. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/09_animation_rectangles.py +0 -0
  50. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/10_animation_planets.py +0 -0
  51. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/11_transparency_and_line_width.py +0 -0
  52. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/12_images.py +0 -0
  53. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/13_gradients.py +0 -0
  54. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/14_animation_close_vertex.py +0 -0
  55. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/15_animation_firework.py +0 -0
  56. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/16_keyboard_and_mouse.py +0 -0
  57. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/17_mouse_tube.py +0 -0
  58. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/18_game_stars.py +0 -0
  59. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/19_game_colors.py +0 -0
  60. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/20_game_racing.py +0 -0
  61. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/99_errors.py +0 -0
  62. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/__init__.py +0 -0
  63. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/examples/cat.png +0 -0
  64. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/__init__.py +0 -0
  65. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/colors.py +0 -0
  66. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/copy_examples.py +0 -0
  67. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/draw.py +0 -0
  68. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/errors.py +0 -0
  69. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/gradient.py +0 -0
  70. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/i18n.py +0 -0
  71. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/key_flags.py +0 -0
  72. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/renderer.py +0 -0
  73. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/renderer_ejudge.py +0 -0
  74. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero/utils/screen_size.py +0 -0
  75. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero.egg-info/dependency_links.txt +0 -0
  76. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero.egg-info/requires.txt +0 -0
  77. {drawzero-0.4.4 → drawzero-0.4.5}/src/drawzero.egg-info/top_level.txt +0 -0
@@ -0,0 +1,310 @@
1
+ Metadata-Version: 2.1
2
+ Name: drawzero
3
+ Version: 0.4.5
4
+ Summary: A zero-boilerplate canvas drawing framework for Python 3, based on Pygame.
5
+ Home-page: https://github.com/ShashkovS/drawzero
6
+ Author: Sergey Shashkov
7
+ Author-email: sh57@yandex.ru
8
+ License: MIT
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Education
11
+ Classifier: Intended Audience :: End Users/Desktop
12
+ Classifier: Environment :: Win32 (MS Windows)
13
+ Classifier: Environment :: X11 Applications
14
+ Classifier: Environment :: MacOS X
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Natural Language :: Russian
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: pygame>=2.0.1
30
+
31
+
32
+ <p align="center">
33
+ <a href="https://pypi.org/project/drawzero/" target="_blank">
34
+ <img alt="PyPI" src="https://img.shields.io/pypi/v/drawzero">
35
+ </a>
36
+ <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/drawzero">
37
+ <img alt="GitHub" src="https://img.shields.io/github/license/ShashkovS/drawzero">
38
+ <img alt="coverage" src="https://img.shields.io/badge/coverage-90%25-brightgreen">
39
+ </p>
40
+
41
+ # Draw Zero
42
+ A zero-boilerplate canvas drawing framework for Python 3, based on Pygame.
43
+
44
+
45
+ ## Some examples
46
+
47
+ Here's some neat stuff you can do:
48
+
49
+ ``` python
50
+ # import all
51
+ from drawzero import *
52
+
53
+ # simple shapes
54
+ fill('#12bbae')
55
+ line('red', (400, 400), (800, 800))
56
+ circle('yellow', (500, 560), 200)
57
+ filled_circle('brown', (500, 500), 20)
58
+ text('red', 'Hello, world!', (300, 200), 72)
59
+ rect('blue', (200, 600), 100, 100)
60
+ filled_rect('orange', (400, 600), 100, 100)
61
+ polygon('white', [(20, 200), (100, 240), (40, 160)])
62
+ filled_polygon('burlywood', 200, 400, 130, 304, 20, 342, 20, 458, 130, 496, )
63
+ ```
64
+
65
+ <img alt="hello world" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/hello_world.png" width="75%">
66
+
67
+ # Animation
68
+
69
+ Animations are also straightforward:
70
+
71
+ <img alt="planet_animation" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/planet_animation.gif" width="50%">
72
+
73
+ ``` python
74
+ from drawzero import *
75
+ from math import sin, cos, pi
76
+
77
+ earth_orbit = 400
78
+ earth_radius = 30
79
+ earth_rot_step = 2 * pi / 360
80
+ moon_orbit = 100
81
+ moon_radius = 10
82
+ moon_rot_step = 2 * pi / 60
83
+
84
+ i = 0
85
+ while True:
86
+ i += 1
87
+ e_x = 500 + earth_orbit * cos(earth_rot_step * i)
88
+ e_y = 500 + earth_orbit * sin(earth_rot_step * i)
89
+ m_x = e_x + moon_orbit * cos(moon_rot_step * i)
90
+ m_y = e_y + moon_orbit * sin(moon_rot_step * i)
91
+
92
+ clear()
93
+ filled_circle(C.red, (500, 500), 100)
94
+ filled_circle(C.blue, (e_x, e_y), earth_radius)
95
+ filled_circle(C.yellow, (m_x, m_y), moon_radius)
96
+ tick()
97
+ ```
98
+
99
+
100
+ # Point class which acts like 2-d vector and Turtle both
101
+
102
+ <img alt="transparent.png" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/ex_05.png" width="50%">
103
+
104
+ ```python
105
+ from drawzero import *
106
+
107
+ # just coordinates
108
+ A = Pt(100, 100)
109
+ B = Pt(300, 150)
110
+ line(C.red, A, B)
111
+
112
+ # A point which acts as 2-d vector and as a Turtle
113
+ # Pt(x=0.0, y=0.0, *, heading=0.0)
114
+ #
115
+ # Provides (for a, b — points, k number):
116
+ # * arithmetic
117
+ # a+b — vector addition
118
+ # a-b — vector subtraction
119
+ # k*a and a*k — multiplication with scalar
120
+ # abs — absolute value of a
121
+ # +a, -a
122
+
123
+ # arithmetic
124
+ A = Pt(100, 200)
125
+ dx = Pt(50, 5)
126
+ for i in range(10):
127
+ filled_circle(C.blue, A + dx * i, radius=10)
128
+
129
+ # * turtle-style movement
130
+ # forward — Move the point forward by the specified distance.
131
+ # backward — Move the point backward by distance.
132
+ # right — Turn point right by angle degrees.
133
+ # left — Turn point left by angle degrees.
134
+ # goto — Move point to an absolute position.
135
+ # rotate_around — Rotate around given point by angle degrees.
136
+ # move_towards — Move towards the given point by the specified distance.
137
+ # reset, home — Move point to the origin - coordinates (0,0), set heading=0
138
+ # setx — Set the point's first coordinate to x
139
+ # sety — Set the point's second coordinate to y
140
+ # setheading — Set the point's heading
141
+
142
+ A = Pt(100, 300)
143
+ B = Pt(1000, 400)
144
+ for i in range(10):
145
+ filled_circle(C.green2, A, radius=10)
146
+ A.move_towards(50, B)
147
+
148
+ A = Pt(100, 400)
149
+ for i in range(10):
150
+ filled_circle(C.magenta, A, radius=10)
151
+ A.left(10).forward(30)
152
+
153
+ # * information
154
+ # position — Return the point's current location (x,y), as a tuple.
155
+ # x, xcor — Return the point's x coordinate.
156
+ # y, ycor — Return the point's y coordinate
157
+ # heading — Return the point's heading
158
+ # distance — Return the distance between points
159
+ # towards — Return the angle towards point
160
+ # * deep copy
161
+ # copy — a clone of point
162
+ ```
163
+
164
+
165
+
166
+ # Transparency
167
+
168
+ Transparency is also straightforward via alpha parameter or RGBA color:
169
+
170
+ <img alt="transparent.png" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/transparent.png" width="50%">
171
+
172
+ ```python
173
+ from drawzero import *
174
+
175
+ clear()
176
+ fill(C.black)
177
+
178
+ filled_circle('red', (100, 100), 20)
179
+ filled_circle('blue', (100, 110), 22, alpha=100) # <-- alpha
180
+ circle('red', (100, 100), 50, line_width=10)
181
+ circle((0, 255, 0, 50), (100, 110), 50, line_width=10) # <-- RGBA
182
+ ...
183
+ ```
184
+
185
+ <details>
186
+ <summary>Full code for transparency and line width example</summary>
187
+
188
+ ``` python
189
+ from drawzero import *
190
+
191
+ clear()
192
+ fill(C.black)
193
+
194
+ filled_circle('red', (100, 100), 20)
195
+ filled_circle('blue', (100, 110), 22, alpha=100)
196
+ circle('red', (100, 100), 50, line_width=10)
197
+ circle((0, 255, 0, 50), (100, 110), 50, line_width=10)
198
+ filled_rect(C.aquamarine, (200, 100), 100, 40)
199
+ filled_rect(C.darkmagenta, (210, 110), 100, 40, alpha=80)
200
+ rect(C.darkgoldenrod, (180, 90), 200, 80, line_width=10)
201
+ rect(C.hotpink, (190, 90), 200, 90, alpha=180, line_width=10)
202
+
203
+ line('red', 600, 400, 600, 990)
204
+ image('cat.png', (500, 500))
205
+ image('cat.png', (500, 800), width=200, alpha=128)
206
+ image('cat.png', (550, 850), width=200, alpha=128)
207
+
208
+ polygon('yellow', [(20, 300), (100, 340), (40, 260)], line_width=20)
209
+ polygon((0, 0, 255, 200), [(20, 300), (100, 340), (40, 260)], line_width=15)
210
+ polygon('red', [(20, 300), (100, 340), (40, 260)])
211
+
212
+ filled_polygon('burlywood', 200, 600, 130, 504, 20, 542, 20, 658, 130, 696)
213
+ filled_polygon(C.hotpink, 200, 700, 130, 604, 20, 642, 20, 758, 130, 796, alpha=100)
214
+
215
+ line(C.green, (700, 100), (800, 200))
216
+ line(C.green, (710, 100), (810, 200), line_width=5)
217
+ line(C.red, (820, 100), (720, 200), line_width=10, alpha=50)
218
+ line(C.blue, (830, 100), (730, 200), line_width=10, alpha=128)
219
+ ```
220
+ </details>
221
+
222
+
223
+ # Color gradients
224
+
225
+ <img alt="transparent.png" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/ex_13.png" width="50%">
226
+
227
+ ```python
228
+ from drawzero import *
229
+
230
+
231
+ scale1 = Gradient([C.black, C.white], 0, 1000)
232
+ for x in range(0, 1000, 10):
233
+ filled_rect(scale1(x), (x, 0), 10, 100)
234
+ text(C.white, 'scale1 = Gradient([C.black, C.white], 0, 1000)', (50, 100), 48, '<^')
235
+
236
+ scale2 = Gradient([C.green, C.yellow, C.magenta, C.red], 0, 1000)
237
+ for x in range(0, 1000, 10):
238
+ filled_rect(scale2(x), (x, 200), 10, 100)
239
+ text(C.white, 'scale2 = Gradient([C.green, C.yellow, C.magenta, C.red], 0, 1000)', (50, 300), 32, '<^')
240
+
241
+ scale3 = Gradient([C.white, C.black, C.red, C.black, C.white], 200, 800)
242
+ for x in range(0, 1000, 10):
243
+ filled_rect(scale3(x), (x, 400), 10, 100)
244
+ text(C.white, 'scale3 = Gradient([C.white, C.black, C.red, C.black, C.white], 200, 800)', (50, 500), 32, '<^')
245
+ ```
246
+
247
+
248
+
249
+ # Keyboard and mouse events
250
+
251
+ Process keyboard events in two ways: check if key is pressed via `get_keys_pressed()` or run throw `keysdown` or `keysup` events:
252
+
253
+ ``` python
254
+ from drawzero import *
255
+
256
+ upper_text = 'Typed: '
257
+ SIZE = 20
258
+ x = y = 500 - SIZE // 2
259
+
260
+ while True:
261
+ # Mouse buttons events
262
+ if mousebuttonsdown:
263
+ x, y = mousebuttonsdown[0].pos
264
+ # Keys which are still pressed
265
+ keys = get_keys_pressed()
266
+ if keys[K.UP] or keys[K.w]:
267
+ y -= 5
268
+ if keys[K.DOWN] or keys[K.s]:
269
+ y += 5
270
+ if keys[K.LEFT] or keys[K.a]:
271
+ x -= 5
272
+ if keys[K.RIGHT] or keys[K.d]:
273
+ x += 5
274
+ # Keyboard events
275
+ for ev in keysdown:
276
+ if ev.unicode:
277
+ upper_text += ev.unicode
278
+
279
+ # Redraw everything
280
+ clear()
281
+ filled_rect(C.red, x, y, SIZE, SIZE)
282
+ text(C.white, upper_text, (100, 5))
283
+ filled_circle(C.yellow, mouse_pos(), 3)
284
+ tick()
285
+ ```
286
+
287
+ <img alt="keyboard_and_mouse_events.gif" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/keyboard_and_mouse_events.gif" width="50%">
288
+
289
+
290
+
291
+ # Installation
292
+
293
+ In a Terminal window, type:
294
+ ```shell
295
+ pip install drawzero --upgrade --user
296
+ ```
297
+
298
+
299
+ Or run the following program:
300
+
301
+ ```python
302
+ import os, sys
303
+ python = sys.executable
304
+ user = '--user' if 'venv' not in python and 'virtualenvs' not in python else ''
305
+ cmd = f'"{python}" -m pip install drawzero --upgrade {user}'
306
+ os.system(cmd)
307
+ from drawzero import *
308
+ ```
309
+
310
+ # [Contributing](CONTRIBUTING.md)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- # pip install wheel twine
4
+ # pip install wheel twine setuptools
5
5
 
6
6
  # build and upload
7
7
  # python setup.py sdist bdist_wheel
@@ -108,13 +108,13 @@ setup(
108
108
  'Operating System :: OS Independent',
109
109
  'Programming Language :: Python',
110
110
  'Programming Language :: Python :: 3',
111
- 'Programming Language :: Python :: 3.7',
112
111
  'Programming Language :: Python :: 3.8',
113
112
  'Programming Language :: Python :: 3.9',
114
113
  'Programming Language :: Python :: 3.10',
115
114
  'Programming Language :: Python :: 3.11',
115
+ 'Programming Language :: Python :: 3.12',
116
+ 'Programming Language :: Python :: 3.13',
116
117
  'Programming Language :: Python :: Implementation :: CPython',
117
- 'Topic :: Multimedia :: Graphics',
118
118
  ],
119
119
  # $ setup.py publish support.
120
120
  cmdclass={
@@ -5,7 +5,7 @@ __all__ = [
5
5
  "__copyright__",
6
6
  ]
7
7
 
8
- __version__ = '0.4.4'
8
+ __version__ = '0.4.5'
9
9
  __author__ = "Sergey Shashkov"
10
10
  __license__ = "MIT"
11
11
  __copyright__ = "Copyright 2020- Sergey Shashkov"
@@ -0,0 +1,12 @@
1
+ from drawzero import *
2
+
3
+ circle('red', (500, 500), 50)
4
+
5
+
6
+ print('a b c d')
7
+ for a in range(2):
8
+ for b in range(2):
9
+ for c in range(2):
10
+ for d in range(2):
11
+ if (not c) and ((not a) <= (not d) <= (not b)):
12
+ print(a, b, c, d)
@@ -136,7 +136,13 @@ def _to_rect(rect: List, error: BadDrawParmsError) -> Optional[Tuple[int, int, i
136
136
  error.errors.append(I18N.use_rect_correct)
137
137
  return None
138
138
  x, y, w, h = rect
139
- return to_canvas_x(x), to_canvas_y(y), to_canvas_x(w), to_canvas_y(h)
139
+ cx = to_canvas_x(x)
140
+ cy = to_canvas_y(y)
141
+ cxw = to_canvas_x(x+w)
142
+ cyh = to_canvas_y(y+h)
143
+ cw = cxw - cx
144
+ ch = cyh - cy
145
+ return cx, cy, cw, ch
140
146
 
141
147
 
142
148
  def _to_points_list(points: Union[list, tuple], error: BadDrawParmsError) -> Optional[List[Tuple[int, int]]]:
@@ -349,9 +349,9 @@ class Pt:
349
349
  >>> point.heading
350
350
  22
351
351
  >>> point.right(45)
352
- Pt(0,0,heading=337.0)
352
+ Pt(0,0,heading=67.0)
353
353
  """
354
- self.heading = (self.heading - angle) % 360.0
354
+ self.heading = (self.heading + angle) % 360.0
355
355
  self._heading_rad = self.heading / 180.0 * pi
356
356
  return self
357
357
 
@@ -372,9 +372,9 @@ class Pt:
372
372
  >>> point.heading
373
373
  22
374
374
  >>> point.left(45)
375
- Pt(0,0,heading=67.0)
375
+ Pt(0,0,heading=337.0)
376
376
  """
377
- self.heading = (self.heading + angle) % 360.0
377
+ self.heading = (self.heading - angle) % 360.0
378
378
  self._heading_rad = self.heading / 180.0 * pi
379
379
  return self
380
380
 
@@ -403,7 +403,7 @@ class Pt:
403
403
 
404
404
  Example (for a Point instance named point):
405
405
  >>> point = Pt()
406
- >>> point.left(60)
406
+ >>> point.right(60)
407
407
  Pt(0.0,0.0,heading=60.0)
408
408
  >>> point.forward(100)
409
409
  Pt(50.0,86.602540378444,heading=60.0)
@@ -419,7 +419,7 @@ class Pt:
419
419
 
420
420
  Example (for a Point instance named point):
421
421
  >>> point = Pt()
422
- >>> point.left(60)
422
+ >>> point.right(60)
423
423
  Pt(0.0,0.0,heading=60.0)
424
424
  >>> point.forward(100)
425
425
  Pt(50.0,86.602540378444,heading=60.0)
@@ -476,13 +476,13 @@ class Pt:
476
476
  Example (for a Point instance named point):
477
477
  >>> tp = Pt(1, 0)
478
478
  >>> tp.rotate_around(90, (0, 0))
479
- Pt(0.0,1.0,heading=0.0)
479
+ Pt(0.0,-1.0,heading=0.0)
480
480
  >>> tp.rotate_around(90, Pt(0, 0))
481
- Pt(-1.0,0.0,heading=0.0)
481
+ Pt(-1.0,-0.0,heading=0.0)
482
482
  >>> tp.rotate_around(90, 0, 0)
483
- Pt(-0.0,-1.0,heading=0.0)
483
+ Pt(-0.0,1.0,heading=0.0)
484
484
  >>> tp.rotate_around(180, [2, 3])
485
- Pt(4.0,7.0,heading=0.0)
485
+ Pt(4.0,5.0,heading=0.0)
486
486
  """
487
487
  if isinstance(x, Pt):
488
488
  px = x.x
@@ -495,7 +495,7 @@ class Pt:
495
495
  py = y
496
496
  dx = self.x - px
497
497
  dy = self.y - py
498
- angle_rad = angle * pi / 180.0
498
+ angle_rad = - angle * pi / 180.0
499
499
  c, s = cos(angle_rad), sin(angle_rad)
500
500
  ndx = dx * c + -dy * s
501
501
  ndy = dx * s + dy * c