ColabTurtlePlus 2.2.0__tar.gz → 2.2.1__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.
@@ -47,6 +47,14 @@ v2.2 October 2026
47
47
  Fixed some bugs related to color processing and speed.
48
48
  Added colormode to handle RGB either in [0,1] range or [1,255] range.
49
49
  Modified jumpto to mimic the teleport function added to the turtle module in Python 3.12
50
+
51
+ v2.2.1 November 2026
52
+ New function addgroupcomponent() to add an svg group to a shape compound.
53
+ The image (with or without the turtle(s)) can now be saved as a PNG file to the local computer using the savePNG() function.
54
+ Turtle shapes that are scaled differently in x and y directions are now rotated smoothly in right/left turns.
55
+ The function saveSVG() will now bring up a download dialog box to save the file to the local computer rather than to the
56
+ Colab or Jupyter sidebar file browser.
57
+
50
58
  """
51
59
 
52
60
  DEFAULT_WINDOW_SIZE = (800, 600)
@@ -130,15 +138,14 @@ TURTLE_USER_SVG_TEMPLATE = """<g id="{id}" visibility="{visibility}" transform="
130
138
  <polygon points="{points}" transform="skewX({sk}) scale({sx},{sy})" style="stroke:{pcolor};fill:{turtle_color};stroke-width:{pw}" />
131
139
  </g>"""
132
140
  TURTLE_COMPONENT_SVG_TEMPLATE = """<g id="user" visibility="{visibility}" transform="rotate({degrees},{rotation_x},{rotation_y}) translate({turtle_x}, {turtle_y})">
133
- "{component}"
134
- </g>"""
141
+ {component}</g>"""
135
142
 
136
- POLY_TEMPLATE = """<polygon points="{points}" transform="skewX({sk})
137
- scale({sx},{sy})" style="stroke:{pcolor};fill:{turtle_color};stroke-width:{pw}" />"""
138
- ELLIPSE_TEMPLATE = """<ellipse transform="skewX({sk}) scale({sx},{sy})"
139
- style="stroke:{pcolor};fill:{turtle_color};stroke-width:{pw}" rx="{rx}" ry ="{ry}" cx="{cx}" cy="{cy}" />"""
140
- PATH_TEMPLATE = """<path d="{path}" style="stroke:{pcolor};fill-rule:evenodd;fill:{turtle_color};fill-opacity:1;"
141
- transform="skewX({sk}) scale({sx},{sy})" />"""
143
+ POLY_TEMPLATE = """<polygon points="{points}" transform="skewX({sk}) scale({sx},{sy})"
144
+ style="stroke:{pcolor};fill:{turtle_color};stroke-width:{pw}" />"""
145
+ ELLIPSE_TEMPLATE = """<ellipse transform="skewX({sk}) scale({sx},{sy})" style="stroke:{pcolor};fill:{turtle_color};stroke-width:{pw}" rx="{rx}" ry ="{ry}" cx="{cx}" cy="{cy}" />"""
146
+ PATH_TEMPLATE = """<path d="{path}" style="stroke:{pcolor};fill-rule:{fill_rule};fill:{turtle_color};fill-opacity:1;" transform="skewX({sk}) scale({sx},{sy})"/>"""
147
+ GROUP_TEMPLATE = """<g style="stroke:{pcolor};fill-rule:{fill_rule};fill:{turtle_color};fill-opacity:1;"
148
+ transform="skewX({sk}) scale({sx},{sy})"> {group} </g>"""
142
149
 
143
150
 
144
151
  SPEED_TO_SEC_MAP = {0: 0, 1: 1.0, 2: 0.8, 3: 0.5, 4: 0.3, 5: 0.25, 6: 0.20, 7: 0.15, 8: 0.125, 9: 0.10, 10: 0.08, 11: 0.04, 12: 0.02, 13: 0.005}
@@ -243,7 +250,8 @@ class _Screen:
243
250
  pw = turtle.outline_width,
244
251
  rotation_x=turtle.turtle_pos[0],
245
252
  rotation_y=turtle.turtle_pos[1],
246
- id = turtle.turtle_shape)
253
+ id = turtle.turtle_shape,
254
+ fill_rule=turtle.fill_rule)
247
255
  return svg
248
256
 
249
257
  # helper function for linking svg strings of text
@@ -281,8 +289,6 @@ class _Screen:
281
289
  svg+=turtle.svg_stampsT_string
282
290
  return svg
283
291
 
284
-
285
- # Helper function for generating the whole svg string
286
292
  def _generateSvgDrawing(self):
287
293
  return SVG_TEMPLATE.format(window_width=self.window_size[0],
288
294
  window_height=self.window_size[1],
@@ -296,18 +302,8 @@ class _Screen:
296
302
  drawlines=self._svg_drawlines_string,
297
303
  kolor=self.border_color)
298
304
 
299
- def showSVG(self, turtle=False):
300
- """Shows the SVG code for the image to the screen.
301
-
302
- Args:
303
- turtle: (optional) a boolean that determines if the turtles
304
- are included in the svg output
305
-
306
- The SVG commands can be printed on screen (after the drawing is
307
- completed) or saved to a file for use in a program like inkscape
308
- or Adobe Illustrator, or displaying the image in a webpage.
309
- """
310
-
305
+ # Helper function for generating the entire svg string for use in showSVG, saveSVG, and savePNG
306
+ def _generateSvgString(self, turtle=False):
311
307
  header = ("""<svg width="{w}" height="{h}" viewBox="0 0 {w} {h}" xmlns="http://www.w3.org/2000/svg">\n""").format(
312
308
  w= self.window_size[0],
313
309
  h= self.window_size[1])
@@ -321,47 +317,145 @@ class _Screen:
321
317
  dots = self._generateSvgDots().replace(">",">\n")
322
318
  turtle_svg = (self._generateTurtlesSvgDrawing() + " \n") if turtle else ""
323
319
  output = header + stampsB + lines + image + dots + stampsT + turtle_svg + "</svg>"
324
- print(output)
325
-
326
- # Save the image as an SVG file using given filename. Set turtle=True to include turtle in svg output
327
- def saveSVG(self, file=None, turtle=False):
328
- """Saves the image as an SVG file.
320
+ return(output)
321
+
322
+ def showSVG(self, turtle=False):
323
+ """Shows the SVG code for the image to the screen.
329
324
 
330
325
  Args:
331
- file: a string giving filename for saved file. The extension
332
- ".svg" will be added if missing. If no filename is given,
333
- the default name SVGimage.svg will be used.
334
- turtle: an optional boolean that determines if the turtles
335
- are included in the svg output saved to the file. Default is False.
326
+ turtle: (optional) a boolean that determines if the turtles
327
+ are included in the svg output
336
328
 
337
329
  The SVG commands can be printed on screen (after the drawing is
338
- completed) or saved to a file for use in a program like inkscape
339
- or Adobe Illustrator, or displaying the image in a webpage.
330
+ completed) with showSVG, or saved to a file for use in a program like inkscape
331
+ or Adobe Illustrator, or displaying the image in a webpage with saveSVG.
340
332
  """
341
-
333
+ output = self._generateSvgString(turtle)
334
+ print(output)
335
+
336
+ # Download the image to the local computer as an SVG file using given filename. Set turtle=True to include turtle in svg output
337
+ def saveSVG(self, file="SVGimage.svg", turtle=False):
338
+ """
339
+
340
+ Args:
341
+ file: Filename as a string. If none is given, the default
342
+ filename "SVGimage.svg" will be used.
343
+ turtle: (optional) a boolean that determines if the turtles
344
+ are included in the svg output
345
+
346
+ Generates the SVG drawing text string and triggers an instant
347
+ direct download onto the user's local computer via the browser.
348
+ Works seamlessly across Google Colab, JupyterLab, and JupyterLite kernels.
349
+ """
350
+
342
351
  if file is None:
343
352
  file = "SVGimage.svg"
344
353
  elif not isinstance(file, str):
345
354
  raise ValueError("File name must be a string")
346
355
  if not file.endswith(".svg"):
347
356
  file += ".svg"
348
- text_file = open(file, "w")
349
- header = ("""<svg width="{w}" height="{h}" viewBox="0 0 {w} {h}" xmlns="http://www.w3.org/2000/svg">\n""").format(
350
- w= self.window_size[0],
351
- h= self.window_size[1])
352
- header += ("""<rect width="100%" height="100%" style="fill:{fillcolor};stroke:{kolor};stroke-width:1" />\n""").format(
353
- fillcolor=self.background_color,
354
- kolor=self.border_color)
355
- lines = self._svg_drawlines_string.replace("/>","/>\n")
356
- image = self._generateSvgLines().replace("/>","/>\n")
357
- stampsB = self._generateSvgStampsB().replace("</g>","</g>\n")
358
- stampsT = self._generateSvgStampsT().replace("</g>","</g>\n")
359
- dots = self._generateSvgDots().replace(">",">\n")
360
- turtle_svg = (self._generateTurtlesSvgDrawing() + " \n") if turtle else ""
361
- output = header + stampsB + lines + image + dots + stampsT + turtle_svg + "</svg>"
362
- text_file.write(output)
363
- text_file.close()
357
+
358
+ svg_string = self._generateSvgString(turtle)
359
+
360
+ # Escape backticks and fix any invalid escape sequences for safe JS template literals
361
+ svg_safe = svg_string.replace('`', r'\`').replace(r'\$', r'\\$')
362
+
363
+ # Build the JavaScript snippet cleanly to avoid syntax parsing color bleeding
364
+ js_lines = [
365
+ "(async () => {",
366
+ " try {",
367
+ f" const svgString = `{svg_safe}`;",
368
+ " const blob = new Blob([svgString], { type: 'image/svg+xml;charset=utf-8' });",
369
+ " const url = URL.createObjectURL(blob);",
370
+ " const downloadLink = document.createElement('a');",
371
+ " downloadLink.href = url;",
372
+ f" downloadLink.download = '{file}';",
373
+ " document.body.appendChild(downloadLink);",
374
+ " downloadLink.click();",
375
+ " document.body.removeChild(downloadLink);",
376
+ " URL.revokeObjectURL(url);",
377
+ " } catch (err) {",
378
+ " console.error('ColabTurtlePlus: Failed to download SVG:', err);",
379
+ " }",
380
+ "})();"
381
+ ]
382
+ js_code = "\n".join(js_lines)
383
+
384
+ try:
385
+ # Execute directly in the browser layout thread
386
+ display(HTML(f"<script>{js_code}</script>"))
387
+ #print(f"Triggered local browser download for: {file}")
388
+
389
+ except Exception as e:
390
+ print(f"Error executing saveSVG: {e}")
391
+
392
+ # Download the image to the local computer as a PNG file using given filename. Set turtle=True to include turtle in svg output.
393
+ def savePNG(self, file="SVGimage.png", turtle=False):
394
+ """
395
+
396
+ Args:
397
+ file: Filename as a string. If none is given, the default
398
+ filename "SVGimage.png" will be used.
399
+ turtle: (optional) a boolean that determines if the turtles
400
+ are included in the svg output
401
+
402
+ Converts the current SVG drawing to a PNG file entirely in the browser
403
+ and triggers an instant direct download onto the user's local computer.
404
+ Works flawlessly across Google Colab, JupyterLab, and JupyterLite kernels.
405
+ """
406
+ if not isinstance(file, str):
407
+ raise ValueError("File name must be a string")
408
+ if not file.endswith(".png"):
409
+ file += ".png"
410
+
411
+ svg_string = self._generateSvgString(turtle)
412
+
413
+ # Escape quotes and clean up the string so it's safe for JavaScript template literals
414
+ svg_safe = svg_string.replace('`', r'\`').replace(r'\$', r'\\$')
415
+
416
+ # Build the JavaScript snippet cleanly
417
+ js_lines = [
418
+ "(async () => {",
419
+ " try {",
420
+ f" const svgString = `{svg_safe}`;",
421
+ " const blob = new Blob([svgString], { type: 'image/svg+xml;charset=utf-8' });",
422
+ " const url = URL.createObjectURL(blob);",
423
+ " const img = new Image();",
424
+ " await new Promise((resolve, reject) => {",
425
+ " img.onload = resolve;",
426
+ " img.onerror = reject;",
427
+ " img.src = url;",
428
+ " });",
429
+ " const canvas = document.createElement('canvas');",
430
+ " canvas.width = img.width || 800;",
431
+ " canvas.height = img.height || 600;",
432
+ " const ctx = canvas.getContext('2d');",
433
+ " ctx.drawImage(img, 0, 0);",
434
+ " URL.revokeObjectURL(url);",
435
+ " const pngDataUrl = canvas.toDataURL('image/png');",
436
+ " const downloadLink = document.createElement('a');",
437
+ " downloadLink.href = pngDataUrl;",
438
+ f" downloadLink.download = '{file}';",
439
+ " document.body.appendChild(downloadLink);",
440
+ " downloadLink.click();",
441
+ " document.body.removeChild(downloadLink);",
442
+ " } catch (err) {",
443
+ " console.error('ColabTurtlePlus: Failed to render/download PNG:', err);",
444
+ " }",
445
+ "})();"
446
+ ]
447
+ js_code = "\n".join(js_lines)
364
448
 
449
+ try:
450
+ # This executes the script directly in the user's browser UI thread
451
+ # completely avoiding background kernel / web-worker sandboxes.
452
+ display(HTML(f"<script>{js_code}</script>"))
453
+ #print(f"Triggered local browser download for: {filename}")
454
+
455
+ except Exception as e:
456
+ print(f"Error executing savePNG: {e}")
457
+
458
+ # Used to make compound shapes
365
459
  def register_shape(self, name, shape=None):
366
460
  """Adds a turtle shape to to the shape list.
367
461
 
@@ -372,7 +466,7 @@ class _Screen:
372
466
 
373
467
  Installs the corresponding polygon shape or the corresponding compound shape.
374
468
  If no points are given, the turtle shape will be blank.
375
- Note: This version does NOT include shapes that are images
469
+ Note: This version does NOT include shapes from image files.
376
470
  """
377
471
 
378
472
  if not isinstance(name,str):
@@ -399,7 +493,7 @@ class _Screen:
399
493
  name = name.lower()
400
494
  VALID_TURTLE_SHAPES.add(name)
401
495
  pointstr = " ".join(f"{x},{y}" for x, y in points)
402
- shapeDict[name] = TURTLE_USER_SVG_TEMPLATE.replace("{points}",pointstr) #TURTLE_USER_SVG_TEMPLATE
496
+ shapeDict[name] = TURTLE_USER_SVG_TEMPLATE.replace("{points}",pointstr)
403
497
  else: #assume compound shape
404
498
  tmp=TURTLE_COMPONENT_SVG_TEMPLATE.format(
405
499
  component=shape._data,
@@ -959,6 +1053,26 @@ class Shape(object):
959
1053
  template = template.replace("{pcolor}",outline)
960
1054
  self._data = tmp + template
961
1055
 
1056
+ def addgroupcomponent(self, group, fill=None, outline=None):
1057
+ """Add SVG group commands to a shape of type compound.
1058
+
1059
+ Arguments: group is a group of svg commands
1060
+ fill is the fillcolor of the polygon,
1061
+ outline is the outline color of the polygon.
1062
+ """
1063
+
1064
+ tmp = self._data
1065
+ template = GROUP_TEMPLATE.replace("{group}", group)
1066
+ if fill is not None:
1067
+ template = template.replace("{turtle_color}",fill)
1068
+ if outline is None:
1069
+ template = template.replace("{pcolor}",fill)
1070
+ else:
1071
+ template = template.replace("{pcolor}", outline)
1072
+ elif outline is not None:
1073
+ template = template.replace("{pcolor}",outline)
1074
+ self._data = tmp + template
1075
+
962
1076
  def addellipsecomponent(self, center, radii, fill=None, outline=None):
963
1077
  """Add elliptical component to a shape of type compound.
964
1078
 
@@ -1023,8 +1137,10 @@ class Shape(object):
1023
1137
  template = template.replace("{pcolor}",outline)
1024
1138
  self._data = tmp + template + "\n"
1025
1139
 
1140
+ addComponent = addcomponent
1026
1141
  addEllipseComponet = addellipsecomponent
1027
1142
  addPathComponent = addpathcomponent
1143
+ addGroupComponent = addgroupcomponent
1028
1144
  #-------------------------------------------------------------
1029
1145
 
1030
1146
  #----------------------------------------------------------------------------------------------
@@ -1144,30 +1260,27 @@ class RawTurtle:
1144
1260
  raise ValueError('Degrees must be a number.')
1145
1261
  timeout_orig = self.timeout
1146
1262
  deg = angle*self.angle_conv
1263
+ template = self.shapeDict[self.turtle_shape]
1147
1264
  if self.turtle_speed == 0 or not self.animate:
1148
1265
  self.turtle_degree = (self.turtle_degree + deg) % 360
1149
1266
  self.screen._updateDrawing(turtle=self)
1150
- elif self.turtle_shape != 'ring' and self.stretchfactor[0]==self.stretchfactor[1]:
1267
+ elif self.turtle_shape != 'ring':
1151
1268
  stretchfactor_orig = self.stretchfactor
1152
- template = self.shapeDict[self.turtle_shape]
1153
- tmp = """<animateTransform id = "one" attributeName="transform"
1154
- type="scale"
1155
- from="{sx} {sy}" to="{sx} {sy}"
1156
- begin="0s" dur="0.01s"
1157
- repeatCount="1"
1158
- additive="sum"
1159
- fill="freeze"
1160
- /><animateTransform attributeName="transform"
1269
+ template = self.shapeDict[self.turtle_shape]
1270
+ tmp = """<animateTransform attributeName="transform"
1161
1271
  type="rotate"
1162
1272
  from="0 0 0" to ="{extent} 0 0"
1163
- begin="one.end" dur="{t}s"
1273
+ begin="0s" dur="{t}s"
1164
1274
  repeatCount="1"
1165
1275
  additive="sum"
1166
1276
  fill="freeze"
1167
1277
  /></g>""".format(extent=deg, t=self.timeout*abs(deg)/90, sx=self.stretchfactor[0], sy=self.stretchfactor[1])
1168
- newtemplate = template.replace("</g>",tmp)
1278
+
1279
+ # Split from the right at most 1 time
1280
+ parts = template.rsplit("</g>", 1)
1281
+ # Join the pieces back together with tmp string replacing the last </g>
1282
+ newtemplate = tmp.join(parts)
1169
1283
  self.shapeDict.update({self.turtle_shape:newtemplate})
1170
- self.stretchfactor = 1,1
1171
1284
  self.timeout = self.timeout*abs(deg)/90+0.001
1172
1285
  self.screen._updateDrawing(self)
1173
1286
  self.turtle_degree = (self.turtle_degree + deg) % 360
@@ -1175,7 +1288,7 @@ class RawTurtle:
1175
1288
  self.shapeDict.update({self.turtle_shape:template})
1176
1289
  self.stretchfactor = stretchfactor_orig
1177
1290
  self.timeout = timeout_orig
1178
- else: #_turtle_shape == 'ring' or _stretchfactor[0] != _stretchfactor[1]
1291
+ else: #_turtle_shape == 'ring'
1179
1292
  turtle_degree_orig = self.turtle_degree
1180
1293
  s = 1 if angle > 0 else -1
1181
1294
  while s*deg > 0:
@@ -2411,7 +2524,7 @@ class RawTurtle:
2411
2524
  ColabTurtle version. Use 'turtle2' for the polygonal turtle shape form
2412
2525
  turtle.py. The circle shape from the original ColabTurtle was renamed 'ring'.
2413
2526
 
2414
- Use register_shape (alias addshape) to create a polygonal shape with a chosen name.
2527
+ Use register_shape (alias addshape) to create other polygonal or compound shapes with a chosen name.
2415
2528
  """
2416
2529
 
2417
2530
  if name is None:
@@ -2665,10 +2778,11 @@ def getcolor(n):
2665
2778
 
2666
2779
 
2667
2780
  _tg_screen_functions = ['addshape', 'bgcolor', 'clearscreen', 'colormode', 'drawline', 'hideborder',
2668
- 'initializescreen','initializeTurtle', 'showSVG', 'saveSVG', 'line', 'mode', 'register_shape', 'resetscreen', 'setup',
2781
+ 'initializescreen','initializeTurtle', 'showSVG', 'saveSVG', 'savePNG' , 'line', 'mode', 'register_shape', 'resetscreen', 'setup',
2669
2782
  'setworldcoordinates', 'showborder', 'turtles', 'window_width', 'window_height' ]
2670
2783
 
2671
- _tg_shape_functions = ['addcomponent', 'addellipsecomponent', 'addpathcomponent']
2784
+ _tg_shape_functions = ['addcomponent', 'addellipsecomponent', 'addpathcomponent', 'addgroupcomponent',
2785
+ 'addComponent', 'addEllipseComponent', 'addPathComponent', 'addGroupComponent']
2672
2786
 
2673
2787
  _tg_turtle_functions = ['animationOff', 'animationOn', 'bk', 'back', 'backward', 'begin_fill',
2674
2788
  'circle', 'clear', 'clearstamp', 'clearstamps', 'color', 'degrees', 'delay', 'distance', 'done',
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ColabTurtlePlus
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: An HTML based Turtle implementation with classes for Google Colab and Jupyter Labs
5
5
  Home-page: https://github.com/mathriddle/ColabTurtlePlus
6
6
  Author: Larry Riddle
@@ -43,6 +43,13 @@ Sept. 2026: Version 2.1.2. Bug fix when multiple turtles have the same shape.
43
43
 
44
44
  Oct. 2026: Version 2.2.0. Added colormode and modified jumpto to mimic teleport from Python's turtle module.
45
45
 
46
+ Nov. 2026: Version 2.2.1.
47
+ New function addgroupcomponent() to add an svg group to a shape compound.
48
+ The image (with or without the turtle(s)) can now be saved as a PNG file to the local computer using the savePNG() function.
49
+ Turtle shapes that are scaled differently in x and y directions are now rotated smoothly in right/left turns.
50
+ The function saveSVG() will now bring up a download dialog box to save the file to the local computer rather than to the
51
+ Colab or Jupyter sidebar file browser.
52
+
46
53
  Installation
47
54
  ----
48
55
  Create an empty code cell and type:
@@ -51,8 +58,6 @@ Create an empty code cell and type:
51
58
 
52
59
  Run the code cell to install the library.
53
60
 
54
- **Note:** The previous non-class version of ColabTurtlePlus can be installed using !pip install ColabTurtlePlus==1.5.
55
-
56
61
  Usage
57
62
  ----
58
63
  In a code cell, import the module using
@@ -1,6 +1,5 @@
1
1
  LICENSE
2
2
  README.md
3
- pyproject.toml
4
3
  setup.cfg
5
4
  setup.py
6
5
  ColabTurtlePlus/Turtle.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ColabTurtlePlus
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: An HTML based Turtle implementation with classes for Google Colab and Jupyter Labs
5
5
  Home-page: https://github.com/mathriddle/ColabTurtlePlus
6
6
  Author: Larry Riddle
@@ -43,6 +43,13 @@ Sept. 2026: Version 2.1.2. Bug fix when multiple turtles have the same shape.
43
43
 
44
44
  Oct. 2026: Version 2.2.0. Added colormode and modified jumpto to mimic teleport from Python's turtle module.
45
45
 
46
+ Nov. 2026: Version 2.2.1.
47
+ New function addgroupcomponent() to add an svg group to a shape compound.
48
+ The image (with or without the turtle(s)) can now be saved as a PNG file to the local computer using the savePNG() function.
49
+ Turtle shapes that are scaled differently in x and y directions are now rotated smoothly in right/left turns.
50
+ The function saveSVG() will now bring up a download dialog box to save the file to the local computer rather than to the
51
+ Colab or Jupyter sidebar file browser.
52
+
46
53
  Installation
47
54
  ----
48
55
  Create an empty code cell and type:
@@ -51,8 +58,6 @@ Create an empty code cell and type:
51
58
 
52
59
  Run the code cell to install the library.
53
60
 
54
- **Note:** The previous non-class version of ColabTurtlePlus can be installed using !pip install ColabTurtlePlus==1.5.
55
-
56
61
  Usage
57
62
  ----
58
63
  In a code cell, import the module using
@@ -18,6 +18,13 @@ Sept. 2026: Version 2.1.2. Bug fix when multiple turtles have the same shape.
18
18
 
19
19
  Oct. 2026: Version 2.2.0. Added colormode and modified jumpto to mimic teleport from Python's turtle module.
20
20
 
21
+ Nov. 2026: Version 2.2.1.
22
+ New function addgroupcomponent() to add an svg group to a shape compound.
23
+ The image (with or without the turtle(s)) can now be saved as a PNG file to the local computer using the savePNG() function.
24
+ Turtle shapes that are scaled differently in x and y directions are now rotated smoothly in right/left turns.
25
+ The function saveSVG() will now bring up a download dialog box to save the file to the local computer rather than to the
26
+ Colab or Jupyter sidebar file browser.
27
+
21
28
  Installation
22
29
  ----
23
30
  Create an empty code cell and type:
@@ -26,8 +33,6 @@ Create an empty code cell and type:
26
33
 
27
34
  Run the code cell to install the library.
28
35
 
29
- **Note:** The previous non-class version of ColabTurtlePlus can be installed using !pip install ColabTurtlePlus==1.5.
30
-
31
36
  Usage
32
37
  ----
33
38
  In a code cell, import the module using
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = ColabTurtlePlus
3
- version = 2.2.0
3
+ version = 2.2.1
4
4
  author = Larry Riddle
5
5
  author_email = lriddle@agnesscott.edu
6
6
  description = 'An HTML based Turtle implementation with classes for Google Colab and Jupyter Labs'
@@ -9,7 +9,7 @@ README = (HERE / "README.md").read_text()
9
9
 
10
10
  setup(
11
11
  name='ColabTurtlePlus',
12
- version='2.2.0',
12
+ version='2.2.1',
13
13
  packages=['ColabTurtlePlus'],
14
14
  url='https://github.com/mathriddle/ColabTurtlePlus',
15
15
  license='MIT',
@@ -1,6 +0,0 @@
1
- [build-system]
2
- requires = [
3
- "setuptools>=42",
4
- "wheel"
5
- ]
6
- build-backend = "setuptools.build_meta"
File without changes