drawzero 0.4.3__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 (80) hide show
  1. drawzero-0.4.5/PKG-INFO +310 -0
  2. {drawzero-0.4.3 → drawzero-0.4.5}/README.md +92 -2
  3. drawzero-0.4.5/docs/ex_00.png +0 -0
  4. drawzero-0.4.5/docs/ex_01.png +0 -0
  5. drawzero-0.4.5/docs/ex_02.png +0 -0
  6. drawzero-0.4.5/docs/ex_03.png +0 -0
  7. drawzero-0.4.5/docs/ex_04.png +0 -0
  8. drawzero-0.4.5/docs/ex_05.png +0 -0
  9. drawzero-0.4.5/docs/ex_06.png +0 -0
  10. drawzero-0.4.5/docs/ex_10.png +0 -0
  11. drawzero-0.4.5/docs/ex_13.png +0 -0
  12. {drawzero-0.4.3 → drawzero-0.4.5}/setup.py +3 -3
  13. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/__about__.py +1 -1
  14. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/__init__.py +46 -44
  15. drawzero-0.4.5/src/drawzero/examples/00_hello_world.py +20 -0
  16. drawzero-0.4.5/src/drawzero/examples/05_points.py +57 -0
  17. drawzero-0.4.3/src/drawzero/examples/05_turtle_style.py → drawzero-0.4.5/src/drawzero/examples/06_turtle_style.py +18 -18
  18. drawzero-0.4.5/src/drawzero/examples/13_gradients.py +17 -0
  19. drawzero-0.4.3/src/drawzero/examples/16_game_stars.py → drawzero-0.4.5/src/drawzero/examples/18_game_stars.py +97 -97
  20. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/examples/99_errors.py +40 -40
  21. drawzero-0.4.5/src/drawzero/examples/dummy.py +12 -0
  22. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/converters.py +7 -1
  23. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/copy_examples.py +16 -16
  24. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/draw.py +317 -311
  25. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/i18n.py +166 -166
  26. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/pt.py +11 -11
  27. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/renderer.py +14 -4
  28. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/renderer_ejudge.py +110 -110
  29. drawzero-0.4.5/src/drawzero.egg-info/PKG-INFO +310 -0
  30. drawzero-0.4.5/src/drawzero.egg-info/SOURCES.txt +71 -0
  31. drawzero-0.4.5/src/drawzero.egg-info/requires.txt +1 -0
  32. drawzero-0.4.5/tests/test_converters.py +124 -0
  33. drawzero-0.4.5/tests/test_copy_examples.py +26 -0
  34. drawzero-0.4.5/tests/test_errors.py +71 -0
  35. drawzero-0.4.5/tests/test_examples_gui_mode.py +86 -0
  36. drawzero-0.4.5/tests/test_examples_text_mode.py +84 -0
  37. drawzero-0.4.5/tests/test_gradient.py +35 -0
  38. drawzero-0.4.5/tests/test_i18n.py +16 -0
  39. drawzero-0.4.5/tests/test_pt.py +16 -0
  40. drawzero-0.4.3/PKG-INFO +0 -219
  41. drawzero-0.4.3/docs/pt.rst +0 -0
  42. drawzero-0.4.3/src/drawzero/examples/00_hello_world.py +0 -20
  43. drawzero-0.4.3/src/drawzero.egg-info/PKG-INFO +0 -219
  44. drawzero-0.4.3/src/drawzero.egg-info/SOURCES.txt +0 -53
  45. drawzero-0.4.3/src/drawzero.egg-info/entry_points.txt +0 -3
  46. drawzero-0.4.3/src/drawzero.egg-info/requires.txt +0 -1
  47. {drawzero-0.4.3 → drawzero-0.4.5}/LICENSE +0 -0
  48. {drawzero-0.4.3 → drawzero-0.4.5}/MANIFEST.in +0 -0
  49. {drawzero-0.4.3 → drawzero-0.4.5}/docs/hello_world.png +0 -0
  50. {drawzero-0.4.3 → drawzero-0.4.5}/docs/keyboard_and_mouse_events.gif +0 -0
  51. {drawzero-0.4.3 → drawzero-0.4.5}/docs/planet_animation.gif +0 -0
  52. {drawzero-0.4.3 → drawzero-0.4.5}/docs/transparent.png +0 -0
  53. {drawzero-0.4.3 → drawzero-0.4.5}/setup.cfg +0 -0
  54. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/__main__.py +0 -0
  55. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/examples/01_grid_and_coordinates.py +0 -0
  56. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/examples/02_loops_and_rgb_colors.py +0 -0
  57. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/examples/03_simple_objects.py +0 -0
  58. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/examples/04_loops_sin_plot.py +0 -0
  59. /drawzero-0.4.3/src/drawzero/examples/06_animation_circles.py → /drawzero-0.4.5/src/drawzero/examples/07_animation_circles.py +0 -0
  60. /drawzero-0.4.3/src/drawzero/examples/07_animation_traffic_light.py → /drawzero-0.4.5/src/drawzero/examples/08_animation_traffic_light.py +0 -0
  61. /drawzero-0.4.3/src/drawzero/examples/08_animation_rectangles.py → /drawzero-0.4.5/src/drawzero/examples/09_animation_rectangles.py +0 -0
  62. /drawzero-0.4.3/src/drawzero/examples/09_animation_planets.py → /drawzero-0.4.5/src/drawzero/examples/10_animation_planets.py +0 -0
  63. /drawzero-0.4.3/src/drawzero/examples/10_transparency_and_line_width.py → /drawzero-0.4.5/src/drawzero/examples/11_transparency_and_line_width.py +0 -0
  64. /drawzero-0.4.3/src/drawzero/examples/11_images.py → /drawzero-0.4.5/src/drawzero/examples/12_images.py +0 -0
  65. /drawzero-0.4.3/src/drawzero/examples/12_animation_close_vertex.py → /drawzero-0.4.5/src/drawzero/examples/14_animation_close_vertex.py +0 -0
  66. /drawzero-0.4.3/src/drawzero/examples/13_animation_firework.py → /drawzero-0.4.5/src/drawzero/examples/15_animation_firework.py +0 -0
  67. /drawzero-0.4.3/src/drawzero/examples/14_keyboard_and_mouse.py → /drawzero-0.4.5/src/drawzero/examples/16_keyboard_and_mouse.py +0 -0
  68. /drawzero-0.4.3/src/drawzero/examples/15_mouse_tube.py → /drawzero-0.4.5/src/drawzero/examples/17_mouse_tube.py +0 -0
  69. /drawzero-0.4.3/src/drawzero/examples/17_game_colors.py → /drawzero-0.4.5/src/drawzero/examples/19_game_colors.py +0 -0
  70. /drawzero-0.4.3/src/drawzero/examples/18_game_racing.py → /drawzero-0.4.5/src/drawzero/examples/20_game_racing.py +0 -0
  71. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/examples/__init__.py +0 -0
  72. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/examples/cat.png +0 -0
  73. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/__init__.py +0 -0
  74. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/colors.py +0 -0
  75. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/errors.py +0 -0
  76. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/gradient.py +0 -0
  77. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/key_flags.py +0 -0
  78. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero/utils/screen_size.py +0 -0
  79. {drawzero-0.4.3 → drawzero-0.4.5}/src/drawzero.egg-info/dependency_links.txt +0 -0
  80. {drawzero-0.4.3 → 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)
@@ -66,6 +66,71 @@ while True:
66
66
  ```
67
67
 
68
68
 
69
+ # Point class which acts like 2-d vector and Turtle both
70
+
71
+ <img alt="transparent.png" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/ex_05.png" width="50%">
72
+
73
+ ```python
74
+ from drawzero import *
75
+
76
+ # just coordinates
77
+ A = Pt(100, 100)
78
+ B = Pt(300, 150)
79
+ line(C.red, A, B)
80
+
81
+ # A point which acts as 2-d vector and as a Turtle
82
+ # Pt(x=0.0, y=0.0, *, heading=0.0)
83
+ #
84
+ # Provides (for a, b — points, k number):
85
+ # * arithmetic
86
+ # a+b — vector addition
87
+ # a-b — vector subtraction
88
+ # k*a and a*k — multiplication with scalar
89
+ # abs — absolute value of a
90
+ # +a, -a
91
+
92
+ # arithmetic
93
+ A = Pt(100, 200)
94
+ dx = Pt(50, 5)
95
+ for i in range(10):
96
+ filled_circle(C.blue, A + dx * i, radius=10)
97
+
98
+ # * turtle-style movement
99
+ # forward — Move the point forward by the specified distance.
100
+ # backward — Move the point backward by distance.
101
+ # right — Turn point right by angle degrees.
102
+ # left — Turn point left by angle degrees.
103
+ # goto — Move point to an absolute position.
104
+ # rotate_around — Rotate around given point by angle degrees.
105
+ # move_towards — Move towards the given point by the specified distance.
106
+ # reset, home — Move point to the origin - coordinates (0,0), set heading=0
107
+ # setx — Set the point's first coordinate to x
108
+ # sety — Set the point's second coordinate to y
109
+ # setheading — Set the point's heading
110
+
111
+ A = Pt(100, 300)
112
+ B = Pt(1000, 400)
113
+ for i in range(10):
114
+ filled_circle(C.green2, A, radius=10)
115
+ A.move_towards(50, B)
116
+
117
+ A = Pt(100, 400)
118
+ for i in range(10):
119
+ filled_circle(C.magenta, A, radius=10)
120
+ A.left(10).forward(30)
121
+
122
+ # * information
123
+ # position — Return the point's current location (x,y), as a tuple.
124
+ # x, xcor — Return the point's x coordinate.
125
+ # y, ycor — Return the point's y coordinate
126
+ # heading — Return the point's heading
127
+ # distance — Return the distance between points
128
+ # towards — Return the angle towards point
129
+ # * deep copy
130
+ # copy — a clone of point
131
+ ```
132
+
133
+
69
134
 
70
135
  # Transparency
71
136
 
@@ -124,6 +189,31 @@ circle((0, 255, 0, 50), (100, 110), 50, line_width=10) # <-- RGBA
124
189
  </details>
125
190
 
126
191
 
192
+ # Color gradients
193
+
194
+ <img alt="transparent.png" src="https://raw.githubusercontent.com/ShashkovS/drawzero/master/docs/ex_13.png" width="50%">
195
+
196
+ ```python
197
+ from drawzero import *
198
+
199
+
200
+ scale1 = Gradient([C.black, C.white], 0, 1000)
201
+ for x in range(0, 1000, 10):
202
+ filled_rect(scale1(x), (x, 0), 10, 100)
203
+ text(C.white, 'scale1 = Gradient([C.black, C.white], 0, 1000)', (50, 100), 48, '<^')
204
+
205
+ scale2 = Gradient([C.green, C.yellow, C.magenta, C.red], 0, 1000)
206
+ for x in range(0, 1000, 10):
207
+ filled_rect(scale2(x), (x, 200), 10, 100)
208
+ text(C.white, 'scale2 = Gradient([C.green, C.yellow, C.magenta, C.red], 0, 1000)', (50, 300), 32, '<^')
209
+
210
+ scale3 = Gradient([C.white, C.black, C.red, C.black, C.white], 200, 800)
211
+ for x in range(0, 1000, 10):
212
+ filled_rect(scale3(x), (x, 400), 10, 100)
213
+ text(C.white, 'scale3 = Gradient([C.white, C.black, C.red, C.black, C.white], 200, 800)', (50, 500), 32, '<^')
214
+ ```
215
+
216
+
127
217
 
128
218
  # Keyboard and mouse events
129
219
 
@@ -180,10 +270,10 @@ Or run the following program:
180
270
  ```python
181
271
  import os, sys
182
272
  python = sys.executable
183
- user = '--user' if 'venv' not in python else ''
273
+ user = '--user' if 'venv' not in python and 'virtualenvs' not in python else ''
184
274
  cmd = f'"{python}" -m pip install drawzero --upgrade {user}'
185
- print(cmd)
186
275
  os.system(cmd)
276
+ from drawzero import *
187
277
  ```
188
278
 
189
279
  # [Contributing](CONTRIBUTING.md)
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -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.3'
8
+ __version__ = '0.4.5'
9
9
  __author__ = "Sergey Shashkov"
10
10
  __license__ = "MIT"
11
11
  __copyright__ = "Copyright 2020- Sergey Shashkov"
@@ -1,44 +1,46 @@
1
- """
2
- drawzero
3
- ========
4
- A zero-boilerplate canvas drawing framework for Python 3, based on Pygame.
5
- """
6
-
7
- from .utils.draw import *
8
- from .utils.pt import Pt
9
- from .utils.gradient import Gradient
10
- from .utils.copy_examples import copy_examples
11
- from .utils.screen_size import set_virtual_size
12
- from .utils.i18n import set_lang
13
- from .utils.key_flags import K, KEY
14
- from .utils.colors import C, COLORS, THECOLORS, ALL_COLORS
15
- from .__about__ import __author__, __copyright__, __version__
16
-
17
- __all__ = [
18
- # spec
19
- '__author__', '__copyright__', '__version__',
20
- # simple shapes
21
- 'line', 'arc', 'circle', 'rect', 'ellipse', 'rect_rotated', 'polygon',
22
- # filled shapes
23
- 'filled_circle', 'filled_rect', 'filled_ellipse', 'filled_rect_rotated', 'filled_polygon',
24
- # other
25
- 'grid', 'text', 'clear', 'fill', 'image', 'fps', 'set_lang',
26
- # animation control
27
- 'tick', 'sleep', 'quit',
28
- # keyboard and mouse
29
- 'mouse_pos',
30
- # examples
31
- 'copy_examples',
32
- # Point class
33
- 'Pt',
34
- # Color consts (all are the same)
35
- 'C', 'COLORS', 'THECOLORS', 'ALL_COLORS',
36
- # Keyboard key names
37
- 'K', 'KEY',
38
- # Gradient tools
39
- 'Gradient',
40
- # pygamezero compatibility
41
- 'screen', 'set_virtual_size',
42
- # Mouse and keyboard events
43
- 'get_keys_pressed', 'keys_mods_pressed', 'get_mouse_pressed', 'keysdown', 'keysup', 'mousemotions', 'mousebuttonsdown', 'mousebuttonsup',
44
- ]
1
+ """
2
+ drawzero
3
+ ========
4
+ A zero-boilerplate canvas drawing framework for Python 3, based on Pygame.
5
+ """
6
+
7
+ from .utils.draw import *
8
+ from .utils.pt import Pt
9
+ from .utils.gradient import Gradient
10
+ from .utils.copy_examples import copy_examples
11
+ from .utils.screen_size import set_virtual_size
12
+ from .utils.i18n import set_lang
13
+ from .utils.key_flags import K, KEY
14
+ from .utils.colors import C, COLORS, THECOLORS, ALL_COLORS
15
+ from .__about__ import __author__, __copyright__, __version__
16
+
17
+ __all__ = [
18
+ # spec
19
+ '__author__', '__copyright__', '__version__',
20
+ #
21
+ 'run',
22
+ # simple shapes
23
+ 'line', 'arc', 'circle', 'rect', 'ellipse', 'rect_rotated', 'polygon',
24
+ # filled shapes
25
+ 'filled_circle', 'filled_rect', 'filled_ellipse', 'filled_rect_rotated', 'filled_polygon',
26
+ # other
27
+ 'grid', 'text', 'clear', 'fill', 'image', 'fps', 'set_lang',
28
+ # animation control
29
+ 'tick', 'sleep', 'quit',
30
+ # keyboard and mouse
31
+ 'mouse_pos',
32
+ # examples
33
+ 'copy_examples',
34
+ # Point class
35
+ 'Pt',
36
+ # Color consts (all are the same)
37
+ 'C', 'COLORS', 'THECOLORS', 'ALL_COLORS',
38
+ # Keyboard key names
39
+ 'K', 'KEY',
40
+ # Gradient tools
41
+ 'Gradient',
42
+ # pygamezero compatibility
43
+ 'screen', 'set_virtual_size',
44
+ # Mouse and keyboard events
45
+ 'get_keys_pressed', 'keys_mods_pressed', 'get_mouse_pressed', 'keysdown', 'keysup', 'mousemotions', 'mousebuttonsdown', 'mousebuttonsup',
46
+ ]
@@ -0,0 +1,20 @@
1
+ # Just import everything
2
+ # Импортируем всё
3
+ from drawzero import *
4
+
5
+ # Red rectangle with upper left corner at (50, 150) and width = 900, height = 700
6
+ # Красный прямоугольник с левым верхнем углом в точке(50, 150), шириной 900 и высотой 700
7
+ rect('red', (50, 150), 900, 700)
8
+
9
+ # Straight orange line from (100, 500) to (900, 500)
10
+ # Оранжевая прямая линия из точки (100, 500) в точку (900, 500)
11
+ line('orange', (100, 500), (900, 500))
12
+
13
+ # Centered text
14
+ # Центрированный текст
15
+ text('green', 'Hello world!', (500, 250), fontsize=72)
16
+ text('blue', 'Привет, мир!', (500, 750), fontsize=72)
17
+
18
+ # Run loop
19
+ # Запуск
20
+ run()
@@ -0,0 +1,57 @@
1
+ from drawzero import *
2
+
3
+ # just coordinates
4
+ A = Pt(100, 100)
5
+ B = Pt(300, 150)
6
+ line(C.red, A, B)
7
+
8
+ # A point which acts as 2-d vector and as a Turtle
9
+ # Pt(x=0.0, y=0.0, *, heading=0.0)
10
+ #
11
+ # Provides (for a, b — points, k number):
12
+ # * arithmetic
13
+ # a+b — vector addition
14
+ # a-b — vector subtraction
15
+ # k*a and a*k — multiplication with scalar
16
+ # abs — absolute value of a
17
+ # +a, -a
18
+
19
+ # arithmetic
20
+ A = Pt(100, 200)
21
+ dx = Pt(50, 5)
22
+ for i in range(10):
23
+ filled_circle(C.blue, A + dx * i, radius=10)
24
+
25
+ # * turtle-style movement
26
+ # forward — Move the point forward by the specified distance.
27
+ # backward — Move the point backward by distance.
28
+ # right — Turn point right by angle degrees.
29
+ # left — Turn point left by angle degrees.
30
+ # goto — Move point to an absolute position.
31
+ # rotate_around — Rotate around given point by angle degrees.
32
+ # move_towards — Move towards the given point by the specified distance.
33
+ # reset, home — Move point to the origin - coordinates (0,0), set heading=0
34
+ # setx — Set the point's first coordinate to x
35
+ # sety — Set the point's second coordinate to y
36
+ # setheading — Set the point's heading
37
+
38
+ A = Pt(100, 300)
39
+ B = Pt(1000, 400)
40
+ for i in range(10):
41
+ filled_circle(C.green2, A, radius=10)
42
+ A.move_towards(50, B)
43
+
44
+ A = Pt(100, 400)
45
+ for i in range(10):
46
+ filled_circle(C.magenta, A, radius=10)
47
+ A.left(10).forward(30)
48
+
49
+ # * information
50
+ # position — Return the point's current location (x,y), as a tuple.
51
+ # x, xcor — Return the point's x coordinate.
52
+ # y, ycor — Return the point's y coordinate
53
+ # heading — Return the point's heading
54
+ # distance — Return the distance between points
55
+ # towards — Return the angle towards point
56
+ # * deep copy
57
+ # copy — a clone of point