ipyturtle3 0.1.3__tar.gz → 0.1.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.
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/PKG-INFO +6 -3
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/README.md +0 -0
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/ipyturtle3/__init__.py +1 -1
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/ipyturtle3/ipyturtle3.py +72 -7
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/ipyturtle3.egg-info/PKG-INFO +6 -3
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/ipyturtle3.egg-info/SOURCES.txt +0 -1
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/ipyturtle3.egg-info/dependency_links.txt +0 -0
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/ipyturtle3.egg-info/requires.txt +0 -0
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/ipyturtle3.egg-info/top_level.txt +0 -0
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/setup.cfg +0 -0
- {ipyturtle3-0.1.3 → ipyturtle3-0.1.5}/setup.py +6 -3
- ipyturtle3-0.1.3/LICENSE +0 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ipyturtle3
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Turtle graphics based on ipycanvas which can run on jupyter lab/notebook/vscode.
|
|
5
5
|
Home-page: https://github.com/williamnavaraj/ipyturtle3.git
|
|
6
6
|
Author: William Navaraj
|
|
@@ -74,9 +74,12 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
74
74
|
Classifier: Intended Audience :: Education
|
|
75
75
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
76
76
|
Classifier: Programming Language :: Python :: 3
|
|
77
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
78
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
79
77
|
Classifier: Programming Language :: Python :: 3.8
|
|
80
78
|
Classifier: Programming Language :: Python :: 3.9
|
|
81
79
|
Classifier: Programming Language :: Python :: 3.10
|
|
80
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
81
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
82
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
83
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
84
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
82
85
|
Description-Content-Type: text/markdown
|
|
File without changes
|
|
@@ -11,7 +11,7 @@ This was developed to solve this.
|
|
|
11
11
|
"""
|
|
12
12
|
from .ipyturtle3 import Turtle, Canvas, TurtleScreen,hold_canvas, Shape
|
|
13
13
|
|
|
14
|
-
__version__ = "0.1.
|
|
14
|
+
__version__ = "0.1.4"
|
|
15
15
|
__author__ = 'William Navaraj'
|
|
16
16
|
__homepage__ = 'https://github.com/williamnavaraj'
|
|
17
17
|
__all__ =['Turtle','Canvas','TurtleScreen','hold_canvas','Shape']
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# ipyturtle3.py: an ipycanvas based turtle graphics module for Python
|
|
5
5
|
# implemented as wrapper around turtle.py which ships with python
|
|
6
|
-
# Version 0.1.
|
|
6
|
+
# Version 0.1.4 - 04. 06. 2022
|
|
7
7
|
#
|
|
8
8
|
# Copyright [2022] [William Navaraj]
|
|
9
9
|
|
|
@@ -158,14 +158,44 @@ class Canvas(ipycanvas.Canvas):
|
|
|
158
158
|
self.object_id=self.object_id+1
|
|
159
159
|
self.canvas_objects.append({"ID":self.object_id,"Type":"Line","LineSegments":[a,b,c,d],"Fill":fill,"Width":width})
|
|
160
160
|
return self.object_id
|
|
161
|
+
|
|
161
162
|
def create_polygon(self,pg, fill="", width=2,
|
|
162
163
|
capstyle = "ROUND",outline=""):
|
|
163
164
|
self.object_id=self.object_id+1
|
|
164
165
|
self.canvas_objects.append({"ID":self.object_id,"Type":"Polygon","Polygon":pg,"Fill":fill,"Width":width,"Outline":outline,"Top":False})
|
|
165
166
|
return self.object_id
|
|
167
|
+
|
|
168
|
+
def create_text(self, x, y, text="", anchor="s", fill="black", font=("Arial", 12, "normal")):
|
|
169
|
+
self.object_id += 1
|
|
170
|
+
self.canvas_objects.append({
|
|
171
|
+
"ID": self.object_id,
|
|
172
|
+
"Type": "Text",
|
|
173
|
+
"Text": text,
|
|
174
|
+
"XPos": x,
|
|
175
|
+
"YPos": y,
|
|
176
|
+
"Anchor": anchor,
|
|
177
|
+
"Fill": fill,
|
|
178
|
+
"Font": font,
|
|
179
|
+
})
|
|
180
|
+
return self.object_id
|
|
181
|
+
|
|
182
|
+
def bbox(self, item):
|
|
183
|
+
"""Return a bounding box (x0, y0, x1, y1) estimate for a canvas item."""
|
|
184
|
+
for i in self.canvas_objects:
|
|
185
|
+
if i["ID"] == item and i["Type"] == "Text":
|
|
186
|
+
font = i["Font"]
|
|
187
|
+
size = font[1] if isinstance(font, (list, tuple)) and len(font) > 1 else 12
|
|
188
|
+
text = i["Text"]
|
|
189
|
+
# Approximate: ~0.6 * size per character wide, size tall
|
|
190
|
+
w = int(len(text) * size * 0.6)
|
|
191
|
+
h = int(size)
|
|
192
|
+
x, y = int(i["XPos"]), int(i["YPos"])
|
|
193
|
+
return (x, y - h, x + w, y)
|
|
194
|
+
return (0, 0, 0, 0)
|
|
195
|
+
|
|
166
196
|
def after(self,ms):
|
|
167
|
-
|
|
168
197
|
time.sleep(ms*0.001)
|
|
198
|
+
|
|
169
199
|
def coords(self,pg_item,*coords_list):
|
|
170
200
|
for i in self.canvas_objects:
|
|
171
201
|
if i["ID"]==pg_item and i["Type"]=="Polygon":
|
|
@@ -174,6 +204,7 @@ class Canvas(ipycanvas.Canvas):
|
|
|
174
204
|
elif i["ID"]==pg_item and i["Type"]=="Line":
|
|
175
205
|
i["LineSegments"]=copy.deepcopy([*coords_list])
|
|
176
206
|
return i["LineSegments"]
|
|
207
|
+
|
|
177
208
|
def itemconfigure(self,pg_item,fill=None,width=None,outline=None):
|
|
178
209
|
for i in self.canvas_objects:
|
|
179
210
|
if i["ID"]==pg_item:
|
|
@@ -184,6 +215,7 @@ class Canvas(ipycanvas.Canvas):
|
|
|
184
215
|
if(outline is not None):
|
|
185
216
|
i["Outline"]=outline
|
|
186
217
|
break
|
|
218
|
+
|
|
187
219
|
def tag_raise(self,pg_item):
|
|
188
220
|
for i in range(len(self.canvas_objects)):
|
|
189
221
|
if self.canvas_objects[i]["ID"]==pg_item:
|
|
@@ -191,9 +223,6 @@ class Canvas(ipycanvas.Canvas):
|
|
|
191
223
|
self.canvas_objects.append(a)
|
|
192
224
|
break
|
|
193
225
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
226
|
def winfo_rgb(self, color):
|
|
198
227
|
"""Return a tuple of integer RGB values in range(65536) for color in this widget."""
|
|
199
228
|
import webcolors
|
|
@@ -247,7 +276,7 @@ class TurtleScreen(turtle.TurtleScreen):
|
|
|
247
276
|
"triangle" : Shape("polygon", ((10,-5.77), (0,11.55),
|
|
248
277
|
(-10,-5.77))),
|
|
249
278
|
"classic": Shape("polygon", ((0,0),(-5,-9),(0,-7),(5,-9))),
|
|
250
|
-
"blank" : Shape("
|
|
279
|
+
"blank" : Shape("polygon", ((0,0),(0,0),(0,0)))
|
|
251
280
|
}
|
|
252
281
|
|
|
253
282
|
self._bgpics = {"nopic" : ""}
|
|
@@ -322,6 +351,16 @@ class TurtleScreen(turtle.TurtleScreen):
|
|
|
322
351
|
return self.cv.create_line(0, 0, 0, 0, fill="", width=2,
|
|
323
352
|
capstyle = "ROUND") #TK.ROUND
|
|
324
353
|
|
|
354
|
+
def _write(self, pos, txt, align, font, pencolor):
|
|
355
|
+
x, y = pos
|
|
356
|
+
anchor = {"left": "sw", "center": "s", "right": "se"}
|
|
357
|
+
item = self.cv.create_text(
|
|
358
|
+
x * self.xscale - 1, -y * self.yscale,
|
|
359
|
+
text=txt, anchor=anchor[align], fill=pencolor, font=font
|
|
360
|
+
)
|
|
361
|
+
_, _, x1, _ = self.cv.bbox(item)
|
|
362
|
+
self._update()
|
|
363
|
+
return item, x1 - 1
|
|
325
364
|
|
|
326
365
|
def _update(self):
|
|
327
366
|
"""Redraw graphics items on canvas
|
|
@@ -332,7 +371,10 @@ class TurtleScreen(turtle.TurtleScreen):
|
|
|
332
371
|
if i["ID"]==0:
|
|
333
372
|
self.cv.fill_style=self.cv.background_color
|
|
334
373
|
self.cv.fill_rect(0, 0, self.cv.canvwidth, self.cv.canvheight)
|
|
374
|
+
self.cv.line_width=1.0
|
|
335
375
|
elif i["Type"]=="Polygon":
|
|
376
|
+
if i['Width'] !="":
|
|
377
|
+
self.cv.line_width=float(i['Width'])
|
|
336
378
|
if i['Fill'] !="":
|
|
337
379
|
self.cv.fill_style=i['Fill']
|
|
338
380
|
if i['Outline'] != "":
|
|
@@ -341,7 +383,10 @@ class TurtleScreen(turtle.TurtleScreen):
|
|
|
341
383
|
pg=[(L[i]+self.cv.canvwidth/2,L[i+1]+self.cv.canvheight/2) for i in range(0, len(L),2)]
|
|
342
384
|
self.cv.fill_polygon(pg)
|
|
343
385
|
self.cv.stroke_polygon(pg)
|
|
386
|
+
self.cv.line_width=1.0
|
|
344
387
|
elif i["Type"]=="Line":
|
|
388
|
+
if i['Width'] !="":
|
|
389
|
+
self.cv.line_width=float(i['Width'])
|
|
345
390
|
if i['Fill'] !="":
|
|
346
391
|
self.cv.fill_style=i['Fill']
|
|
347
392
|
self.cv.stroke_style=i['Fill']
|
|
@@ -349,6 +394,25 @@ class TurtleScreen(turtle.TurtleScreen):
|
|
|
349
394
|
if (len(L)>=4):
|
|
350
395
|
pg=[(L[i]+self.cv.canvwidth/2,L[i+1]+self.cv.canvheight/2) for i in range(0, len(L),2)] #[L[0]+self.cv.canvwidth/2,L[1]+self.cv.canvheight/2, L[2]+self.cv.canvwidth/2,L[3]+self.cv.canvheight/2 ]
|
|
351
396
|
self.cv.stroke_lines(pg)
|
|
397
|
+
self.cv.line_width=1.0
|
|
398
|
+
elif i["Type"] == "Text":
|
|
399
|
+
font_tuple = i["Font"]
|
|
400
|
+
if isinstance(font_tuple, (list, tuple)) and len(font_tuple) >= 2:
|
|
401
|
+
family = font_tuple[0]
|
|
402
|
+
size = font_tuple[1]
|
|
403
|
+
style = font_tuple[2] if len(font_tuple) > 2 else "normal"
|
|
404
|
+
else:
|
|
405
|
+
family, size, style = "Arial", 12, "normal"
|
|
406
|
+
self.cv.font = f"{style} {size}px {family}"
|
|
407
|
+
self.cv.fill_style = i["Fill"]
|
|
408
|
+
# Map turtle anchor ("sw","s","se") to ipycanvas text_align/baseline
|
|
409
|
+
anchor = i.get("Anchor", "s")
|
|
410
|
+
align_map = {"sw": "left", "s": "center", "se": "right"}
|
|
411
|
+
self.cv.text_align = align_map.get(anchor, "center")
|
|
412
|
+
self.cv.text_baseline = "alphabetic"
|
|
413
|
+
x = i["XPos"] + self.cv.canvwidth / 2
|
|
414
|
+
y = i["YPos"] + self.cv.canvheight / 2
|
|
415
|
+
self.cv.fill_text(i["Text"], x, y)
|
|
352
416
|
elif i["Type"]=="Image":
|
|
353
417
|
if(i["isNull"]==False):
|
|
354
418
|
#pass
|
|
@@ -367,4 +431,5 @@ class TurtleScreen(turtle.TurtleScreen):
|
|
|
367
431
|
def _createimage(self, image):
|
|
368
432
|
"""Create and return image item on canvas.
|
|
369
433
|
"""
|
|
370
|
-
return self.cv.create_image(0, 0, image_file_name=image)
|
|
434
|
+
return self.cv.create_image(0, 0, image_file_name=image)
|
|
435
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ipyturtle3
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Turtle graphics based on ipycanvas which can run on jupyter lab/notebook/vscode.
|
|
5
5
|
Home-page: https://github.com/williamnavaraj/ipyturtle3.git
|
|
6
6
|
Author: William Navaraj
|
|
@@ -74,9 +74,12 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
74
74
|
Classifier: Intended Audience :: Education
|
|
75
75
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
76
76
|
Classifier: Programming Language :: Python :: 3
|
|
77
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
78
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
79
77
|
Classifier: Programming Language :: Python :: 3.8
|
|
80
78
|
Classifier: Programming Language :: Python :: 3.9
|
|
81
79
|
Classifier: Programming Language :: Python :: 3.10
|
|
80
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
81
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
82
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
83
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
84
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
82
85
|
Description-Content-Type: text/markdown
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -6,7 +6,7 @@ long_description = (this_directory / "README.md").read_text()
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name='ipyturtle3',
|
|
9
|
-
version='0.1.
|
|
9
|
+
version='0.1.5',
|
|
10
10
|
description='Turtle graphics based on ipycanvas which can run on jupyter lab/notebook/vscode. ',
|
|
11
11
|
url='https://github.com/williamnavaraj/ipyturtle3.git',
|
|
12
12
|
author='William Navaraj',
|
|
@@ -23,10 +23,13 @@ setup(
|
|
|
23
23
|
'Intended Audience :: Education',
|
|
24
24
|
'License :: OSI Approved :: Apache Software License',
|
|
25
25
|
'Programming Language :: Python :: 3',
|
|
26
|
-
'Programming Language :: Python :: 3.6',
|
|
27
|
-
'Programming Language :: Python :: 3.7',
|
|
28
26
|
'Programming Language :: Python :: 3.8',
|
|
29
27
|
'Programming Language :: Python :: 3.9',
|
|
30
28
|
'Programming Language :: Python :: 3.10',
|
|
29
|
+
'Programming Language :: Python :: 3.11',
|
|
30
|
+
'Programming Language :: Python :: 3.12',
|
|
31
|
+
'Programming Language :: Python :: 3.13',
|
|
32
|
+
'Programming Language :: Python :: 3.14',
|
|
33
|
+
'Programming Language :: Python :: 3.15',
|
|
31
34
|
],
|
|
32
35
|
)
|
ipyturtle3-0.1.3/LICENSE
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Copyright [2022] [William Navaraj]
|
|
2
|
-
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|