TurtleExtension 2.0.0__tar.gz → 2.1.0__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 (26) hide show
  1. {turtleextension-2.0.0 → turtleextension-2.1.0}/PKG-INFO +1 -1
  2. {turtleextension-2.0.0 → turtleextension-2.1.0}/TurtleExtension.egg-info/PKG-INFO +1 -1
  3. {turtleextension-2.0.0 → turtleextension-2.1.0}/pyproject.toml +1 -1
  4. turtleextension-2.1.0/turtle_extension/__init__.py +63 -0
  5. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/__init__.py +10 -0
  6. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/custom_turtle_shapes.py +13 -8
  7. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/custom_turtle_shapes.pyi +4 -1
  8. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/global_functions.py +10 -2
  9. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/global_functions.pyi +1 -0
  10. turtleextension-2.1.0/turtle_extension/foundations/global_variables.py +15 -0
  11. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/global_variables.pyi +2 -0
  12. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/turtle_functions.py +3 -0
  13. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/foundations/turtle_functions.pyi +2 -1
  14. turtleextension-2.1.0/turtle_extension/turtle_heart/__init__.py +8 -0
  15. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/turtle_heart/turtle_skeleton.py +2 -0
  16. {turtleextension-2.0.0 → turtleextension-2.1.0}/turtle_extension/turtle_heart/turtle_skeleton.pyi +10 -1
  17. turtleextension-2.0.0/turtle_extension/__init__.py +0 -54
  18. turtleextension-2.0.0/turtle_extension/foundations/global_variables.py +0 -14
  19. turtleextension-2.0.0/turtle_extension/turtle_heart/__init__.py +0 -6
  20. {turtleextension-2.0.0 → turtleextension-2.1.0}/LICENSE +0 -0
  21. {turtleextension-2.0.0 → turtleextension-2.1.0}/README.md +0 -0
  22. {turtleextension-2.0.0 → turtleextension-2.1.0}/TurtleExtension.egg-info/SOURCES.txt +0 -0
  23. {turtleextension-2.0.0 → turtleextension-2.1.0}/TurtleExtension.egg-info/dependency_links.txt +0 -0
  24. {turtleextension-2.0.0 → turtleextension-2.1.0}/TurtleExtension.egg-info/requires.txt +0 -0
  25. {turtleextension-2.0.0 → turtleextension-2.1.0}/TurtleExtension.egg-info/top_level.txt +0 -0
  26. {turtleextension-2.0.0 → turtleextension-2.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TurtleExtension
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: A Python utility library providing turtle extensions on top of Python's original turtle feature.
5
5
  Author-email: "Miah M. Sabiq" <miah.sabiq@gibs.at>
6
6
  Requires-Python: >=3.14
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TurtleExtension
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: A Python utility library providing turtle extensions on top of Python's original turtle feature.
5
5
  Author-email: "Miah M. Sabiq" <miah.sabiq@gibs.at>
6
6
  Requires-Python: >=3.14
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "TurtleExtension"
7
- version = "2.0.0"
7
+ version = "2.1.0"
8
8
  description = "A Python utility library providing turtle extensions on top of Python's original turtle feature."
9
9
  readme = "README.md"
10
10
  requires-python = ">= 3.14"
@@ -0,0 +1,63 @@
1
+ """
2
+ This package is part of the GeometricalDomination project ecosystem.
3
+
4
+ It contains a chainable turtle class called ChainTurtle and a collection of extra provided features along with it:
5
+
6
+ 1. tls_color -> this function make a list of colored turtles and returns it
7
+ 2. get_screen -> turtle screen initializer function
8
+ 3. SU -> screen update function
9
+
10
+ And a lot more.
11
+
12
+ Author: Miah M. Sabiq
13
+ """
14
+
15
+ #* Imports foundational functions across numerous files
16
+ from .foundations import (
17
+ CUSTOM_SHAPES, #* [[custom_turtle_shapes.py]]
18
+ get_UserShape_dict, #* [[custom_turtle_shapes.py#get_UserShape_dict]]
19
+
20
+ get_screen, #* [[global_functions.py#get_screen]]
21
+ mainloop, #* [[global_functions.py#mainloop]]
22
+ reset_tls, #* [[global_functions.py#reset_tls]]
23
+ SU, #* [[global_functions.py#SU]]
24
+ tls_color, #* [[global_functions.py#tls_color]]
25
+
26
+ t_now, #* [[global_variables.py#t_now]]
27
+ t_shape, #* [[global_variables.py#t_shape]]
28
+ UV, #* [[global_variables.py]]
29
+
30
+ TurtleFct, #* [[TurtleFct]]
31
+ UserShape, #* [[UserShape]]
32
+ )
33
+
34
+ #* Imports core mechanisms of this package:
35
+ #* [[ChainTurtle]] and [[turtle.py]] from [[turtle_skeleton.py]]
36
+ from .turtle_heart import (
37
+ ChainTurtle, #* [[ChainTurtle]]
38
+ tl, #* [[turtle.py]]
39
+ )
40
+
41
+
42
+ #* Specifies all available functions and dictionaries through wild card import
43
+ __all__ = [
44
+ "UV",
45
+ "t_now",
46
+ "t_shape",
47
+
48
+ "get_screen",
49
+ "SU",
50
+ "mainloop",
51
+ "tls_color",
52
+ "reset_tls",
53
+
54
+ "UserShape",
55
+ "get_UserShape_dict",
56
+ "CUSTOM_SHAPES",
57
+
58
+ "TurtleFct",
59
+
60
+
61
+ "ChainTurtle",
62
+ "tl",
63
+ ]
@@ -1,8 +1,11 @@
1
+ #* Imports function, class and dictionary from [[custom_turtle_shapes.py]]
1
2
  from .custom_turtle_shapes import (
2
3
  CUSTOM_SHAPES,
3
4
  UserShape,
4
5
  get_UserShape_dict,
5
6
  )
7
+
8
+ #* Imports fundamental turtle functions from [[global_functions.py]]
6
9
  from .global_functions import (
7
10
  SU,
8
11
  get_screen,
@@ -10,15 +13,22 @@ from .global_functions import (
10
13
  reset_tls,
11
14
  tls_color,
12
15
  )
16
+
17
+ #* Imports universal dictionary and related functions from [[global_variables.py]]
13
18
  from .global_variables import (
14
19
  UV,
15
20
  t_now,
16
21
  t_shape,
17
22
  )
23
+
24
+ #* Imports class from [[turtle_functions.py]]
18
25
  from .turtle_functions import (
19
26
  TurtleFct,
20
27
  )
21
28
 
29
+
30
+ #* Specifies functions, classes, and dictionaries available in foundations package
31
+ #* through wild card import
22
32
  __all__ = [
23
33
  "UV",
24
34
  "t_now",
@@ -4,8 +4,8 @@ import uf
4
4
 
5
5
  from ..turtle_heart import tl
6
6
 
7
- helper = uf.helper
8
7
 
8
+ #* Class containing all premade turtle shape functions
9
9
  @uf.cls_deco_superposition(staticmethod)
10
10
  class UserShape:
11
11
  def custom_circle():
@@ -16,7 +16,7 @@ class UserShape:
16
16
  return tl.get_poly()
17
17
 
18
18
  def custom_square():
19
- length: Real = helper.length_float()
19
+ length: Real = uf.helper.length_float()
20
20
  tl.begin_poly()
21
21
 
22
22
  for _ in range(4):
@@ -27,7 +27,7 @@ class UserShape:
27
27
  return tl.get_poly()
28
28
 
29
29
  def custom_triangle():
30
- length: Real = helper.length_float()
30
+ length: Real = uf.helper.length_float()
31
31
  tl.begin_poly()
32
32
 
33
33
  for _ in range(3):
@@ -38,8 +38,8 @@ class UserShape:
38
38
  return tl.get_poly()
39
39
 
40
40
  def custom_poly():
41
- length: Real = helper.length_float()
42
- sides: int = helper.sides_num()
41
+ length: Real = uf.helper.length_float()
42
+ sides: int = uf.helper.sides_num()
43
43
 
44
44
  radius = length / (2 * uf.sine(180 / sides))
45
45
  angle_to_right = (180 - (180 * (sides - 2)) / sides) / 2
@@ -53,7 +53,7 @@ class UserShape:
53
53
  return tl.get_poly()
54
54
 
55
55
  def custom_SOD():
56
- side: Real = helper.length_float()
56
+ side: Real = uf.helper.length_float()
57
57
  tl.begin_poly()
58
58
 
59
59
  for _ in range(6):
@@ -65,15 +65,20 @@ class UserShape:
65
65
  tl.end_poly()
66
66
  return tl.get_poly()
67
67
 
68
+ #* Creates and returns a dictionary mapping [[UserShape]]
69
+ #* function names with their corresponding function
68
70
  @classmethod
69
- def _list_shapes(cls):
71
+ def list_shapes(cls):
70
72
  return uf.classes_to_dict(cls)
71
73
 
74
+ #* Creates a customized dictionary mapping [[UserShape]] functions by having the
75
+ #* prefix "custom_" switched with cm
72
76
  def get_UserShape_dict():
73
77
  return {
74
78
  f"cm {name.removeprefix('custom_')}": func
75
- for name, func in UserShape._list_shapes().items()
79
+ for name, func in UserShape.list_shapes().items()
76
80
  if not name.startswith("_")
77
81
  }
78
82
 
83
+ #* [[UserShape]] dictionary storage
79
84
  CUSTOM_SHAPES = get_UserShape_dict()
@@ -5,8 +5,11 @@ This module contains the class Usershape which contains functions to make a cust
5
5
  from collections.abc import Callable, Sequence
6
6
  from numbers import Real
7
7
 
8
+
9
+ #* The type returned by each turtle shape changer function from [[UserShape]]
8
10
  type ReturnShapeType = Sequence[tuple[Real,Real]] | None
9
11
 
12
+ #* The type of the dictionary derived from [[UserShape]]
10
13
  type UserShapeDictType = dict[
11
14
  str,
12
15
  Callable[[], ReturnShapeType]
@@ -53,7 +56,7 @@ class UserShape:
53
56
  """
54
57
 
55
58
  @classmethod
56
- def _list_shapes(cls) -> UserShapeDictType:
59
+ def list_shapes(cls) -> UserShapeDictType:
57
60
  """
58
61
  Creates a dictionary with the functions in UserShape and returns it
59
62
  :return: dictionary containing function names -> function
@@ -9,6 +9,8 @@ from .global_variables import UV, t_shape
9
9
 
10
10
  _screen = None
11
11
 
12
+ #* Retrieves the turtle screen [[turtle.py#Screen]] if one has been made,
13
+ #* else, a new screen is initialized
12
14
  def get_screen():
13
15
  global _screen
14
16
 
@@ -19,13 +21,18 @@ def get_screen():
19
21
 
20
22
  return _screen
21
23
 
24
+ #* Updates the current turtle screen if one exists,
25
+ #* else a new one is created and updated
22
26
  def SU():
23
27
  get_screen().update()
24
28
 
29
+ #* Keeps the turtle window open if one exists,
30
+ #* else a new one is created and kept open
25
31
  def mainloop():
26
32
  get_screen().mainloop()
27
33
 
28
-
34
+ #* Creates a chosen number of turtles with different modes,
35
+ #* also known as the turtle factory by the developer
29
36
  def tls_color(**options):
30
37
 
31
38
  tl_num_name: Final = "tl_num"
@@ -78,7 +85,8 @@ def tls_color(**options):
78
85
  return tls
79
86
  return None
80
87
 
81
-
88
+ #* Resets the provided turtle list,
89
+ #* deletes all turtle drawings and the turtles themselves
82
90
  def reset_tls(tls_list):
83
91
 
84
92
  tls_list_name: Final = "tls_list"
@@ -5,6 +5,7 @@ colors and get a list with them.
5
5
 
6
6
  from ..turtle_heart import ChainTurtle, tl
7
7
 
8
+
8
9
  def get_screen() -> tl.Screen:
9
10
  """
10
11
  Initiates the turtle screen when the function is called.
@@ -0,0 +1,15 @@
1
+ #* UV = UNIVERSAL VARIABLES
2
+ UV = {
3
+ "delay": None, #* Delay for [[turtle_runner.py#user_drawing_ft]]
4
+ "t": 0, #* user_drawing_ft's current turtle
5
+ "tls": [], #* user_drawing_ft's turtle list
6
+ "tls_shape": "arrow", #* turtle's current shape
7
+ }
8
+
9
+ #* Retrieves the current turtle from UV
10
+ def t_now():
11
+ return UV["tls"][UV["t"]]
12
+
13
+ #* Retrieves the current turtle shape
14
+ def t_shape():
15
+ return UV["tls_shape"]
@@ -12,6 +12,8 @@ from typing import Any
12
12
 
13
13
  from ..turtle_heart import ChainTurtle
14
14
 
15
+
16
+ #* The type for the [[global_variables.py]] UV dictionary
15
17
  UV: dict[str, Any]
16
18
 
17
19
  def t_now() -> ChainTurtle:
@@ -5,7 +5,9 @@ from .custom_turtle_shapes import CUSTOM_SHAPES
5
5
  from .global_variables import UV
6
6
 
7
7
 
8
+ #* Class containing turtle shape changer functions
8
9
  class TurtleFct:
10
+ #* Main turtle shape changer function, potentially triggers [[TurtleFct#user_tls_shape_ft]]
9
11
  @classmethod
10
12
  def change_shape(cls, tls_num = None):
11
13
  if tls_num is not None:
@@ -32,6 +34,7 @@ class TurtleFct:
32
34
  else:
33
35
  return cls.user_tls_shape_ft()
34
36
 
37
+ #* Lets the user choose custom shapes from [[UserShape]]
35
38
  @staticmethod
36
39
  def user_tls_shape_ft(tls_num = None):
37
40
  if tls_num is not None:
@@ -4,6 +4,7 @@ This module contains the class TurtleFct which lets the user change the turtle s
4
4
 
5
5
  from ..turtle_heart import ChainTurtle
6
6
 
7
+
7
8
  class TurtleFct:
8
9
  """
9
10
  This class contains a function that lets users change the shape of the turtles that will be created in the future with tls_color.
@@ -22,4 +23,4 @@ class TurtleFct:
22
23
  This function lets the user create custom turtle shapes.
23
24
  :param tls_num: ChainTurtle() or None
24
25
  :return: ChainTurtle() if tls_num is a ChainTurtle(), otherwise None
25
- """
26
+ """
@@ -0,0 +1,8 @@
1
+ #* Imports the [[ChainTurtle]] and [[turtle.py]] from [[turtle_skeleton.py]]
2
+ from .turtle_skeleton import ChainTurtle, tl
3
+
4
+ #* Specifies the classes found in [[turtle_skeleton.py]]
5
+ __all__ = [
6
+ "ChainTurtle",
7
+ "tl",
8
+ ]
@@ -3,6 +3,7 @@ import turtle as tl
3
3
  import uf
4
4
 
5
5
 
6
+ #* Class for chaining the conventional turtle functions [[turtle.py]]
6
7
  class ChainTurtle(tl.Turtle):
7
8
  def fd(self, distance):
8
9
  super().fd(distance)
@@ -96,6 +97,7 @@ class ChainTurtle(tl.Turtle):
96
97
  super().ht()
97
98
  return self
98
99
 
100
+ #* Creates and returns a dictionary with all [[ChainTurtle]] functions
99
101
  @classmethod
100
102
  def list_methods(cls):
101
103
  return uf.classes_to_dict(cls)
@@ -5,6 +5,9 @@ This module contains the class ChainTurtle() which is the foundational object ar
5
5
  from collections.abc import Callable
6
6
  from numbers import Real
7
7
 
8
+
9
+ tl = tl
10
+
8
11
  class ChainTurtle:
9
12
  """This class adds chaining functionality to turtle.Turtle"""
10
13
  def fd(self, distance: Real) -> ChainTurtle:
@@ -73,6 +76,7 @@ class ChainTurtle:
73
76
  """
74
77
  Sets the direction of the turtle starting East, going counterclockwise.
75
78
  :param direction: direction in degrees
79
+ :return: ChainTurtle()
76
80
  """
77
81
 
78
82
  def home(self) -> ChainTurtle:
@@ -120,18 +124,21 @@ class ChainTurtle:
120
124
  :param radius: radius in degrees
121
125
  :param angle: angle in degrees
122
126
  :param sides: number of sides
127
+ :return: ChainTurtle()
123
128
  """
124
129
 
125
130
  def dot(self, radius: Real) -> ChainTurtle:
126
131
  """
127
132
  Makes the turtle draw a colored dot
128
133
  :param radius: radius in pixels
134
+ :return: ChainTurtle()
129
135
  """
130
136
 
131
137
  def color(self, turtle_color: str) -> ChainTurtle:
132
138
  """
133
139
  Lets the user change the color of the turtle trace and turtle color itself
134
140
  :param turtle_color: valid turtle color
141
+ :return: ChainTurtle()
135
142
  """
136
143
 
137
144
  def teleport(self, x: Real, y: Real, *, fill_gap: bool = False) -> ChainTurtle:
@@ -139,12 +146,14 @@ class ChainTurtle:
139
146
  Makes the turtle to go a specific coordinate with no trace
140
147
  :param x: x position in pixels
141
148
  :param y: y position in pixels
149
+ :return: ChainTurtle()
142
150
  """
143
151
 
144
152
  def shape(self, shape_name: str) -> ChainTurtle:
145
153
  """
146
154
  Changes the shape of the turtle shape
147
155
  :param shape_name: name of the shape
156
+ :return: ChainTurtle()
148
157
  """
149
158
 
150
159
  def undo(self) -> ChainTurtle:
@@ -170,4 +179,4 @@ class ChainTurtle:
170
179
  """
171
180
  Creates a dictionary with all ChainTurtle methods and returns it
172
181
  :return: dictionary
173
- """
182
+ """
@@ -1,54 +0,0 @@
1
- """
2
- This package is part of the GeometricalDomination project ecosystem.
3
-
4
- It contains a chainable turtle class called ChainTurtle and a collection of extra provided features along with it:
5
-
6
- 1. tls_color -> this function make a list of colored turtles and returns it
7
- 2. get_screen -> turtle screen initializer function
8
- 3. SU -> screen update function
9
-
10
- And a lot more.
11
-
12
- Author: Miah M. Sabiq
13
- """
14
-
15
- from .foundations import (
16
- CUSTOM_SHAPES,
17
- SU,
18
- UV,
19
- TurtleFct,
20
- UserShape,
21
- get_screen,
22
- get_UserShape_dict,
23
- mainloop,
24
- reset_tls,
25
- t_now,
26
- t_shape,
27
- tls_color,
28
- )
29
- from .turtle_heart import (
30
- ChainTurtle,
31
- tl,
32
- )
33
-
34
- __all__ = [
35
- "UV",
36
- "t_now",
37
- "t_shape",
38
-
39
- "get_screen",
40
- "SU",
41
- "mainloop",
42
- "tls_color",
43
- "reset_tls",
44
-
45
- "UserShape",
46
- "get_UserShape_dict",
47
- "CUSTOM_SHAPES",
48
-
49
- "TurtleFct",
50
-
51
-
52
- "ChainTurtle",
53
- "tl",
54
- ]
@@ -1,14 +0,0 @@
1
- # UV = UNIVERSAL VARIABLES
2
- UV = {
3
- "delay": None, # Delay for user_drawing_ft()
4
- "t": 0, # user_drawing_ft's current turtle
5
- "tls": [], # user_drawing_ft's turtle list
6
- "tls_shape": "arrow", # user_drawing_ft's turtle's current shape
7
- "shape_library": [], # user_drawing_ft's turtle shapes list
8
- }
9
- def t_now():
10
- return UV["tls"][UV["t"]]
11
-
12
- def t_shape():
13
- return UV["tls_shape"]
14
-
@@ -1,6 +0,0 @@
1
- from .turtle_skeleton import ChainTurtle, tl
2
-
3
- __all__ = [
4
- "ChainTurtle",
5
- "tl",
6
- ]
File without changes