TurtleExtension 2.0.0__tar.gz → 2.2.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.
- {turtleextension-2.0.0 → turtleextension-2.2.0}/PKG-INFO +1 -1
- {turtleextension-2.0.0 → turtleextension-2.2.0}/TurtleExtension.egg-info/PKG-INFO +1 -1
- {turtleextension-2.0.0 → turtleextension-2.2.0}/pyproject.toml +1 -1
- turtleextension-2.2.0/turtle_extension/__init__.py +63 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/__init__.py +10 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/custom_turtle_shapes.py +13 -8
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/custom_turtle_shapes.pyi +13 -3
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/global_functions.py +10 -2
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/global_functions.pyi +8 -1
- turtleextension-2.2.0/turtle_extension/foundations/global_variables.py +15 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/global_variables.pyi +2 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/turtle_functions.py +3 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/turtle_functions.pyi +6 -1
- turtleextension-2.2.0/turtle_extension/turtle_heart/__init__.py +8 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/turtle_heart/turtle_skeleton.py +2 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/turtle_heart/turtle_skeleton.pyi +58 -2
- turtleextension-2.0.0/turtle_extension/__init__.py +0 -54
- turtleextension-2.0.0/turtle_extension/foundations/global_variables.py +0 -14
- turtleextension-2.0.0/turtle_extension/turtle_heart/__init__.py +0 -6
- {turtleextension-2.0.0 → turtleextension-2.2.0}/LICENSE +0 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/README.md +0 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/TurtleExtension.egg-info/SOURCES.txt +0 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/TurtleExtension.egg-info/dependency_links.txt +0 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/TurtleExtension.egg-info/requires.txt +0 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/TurtleExtension.egg-info/top_level.txt +0 -0
- {turtleextension-2.0.0 → turtleextension-2.2.0}/setup.cfg +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "TurtleExtension"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.2.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",
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/custom_turtle_shapes.py
RENAMED
|
@@ -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
|
|
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.
|
|
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]
|
|
@@ -21,6 +24,7 @@ class UserShape:
|
|
|
21
24
|
def custom_circle() -> ReturnShapeType:
|
|
22
25
|
"""
|
|
23
26
|
Creates a custom circle turtle shape.
|
|
27
|
+
|
|
24
28
|
:return: the custom shape
|
|
25
29
|
"""
|
|
26
30
|
|
|
@@ -28,6 +32,7 @@ class UserShape:
|
|
|
28
32
|
def custom_square() -> ReturnShapeType:
|
|
29
33
|
"""
|
|
30
34
|
Creates a custom square turtle shape.
|
|
35
|
+
|
|
31
36
|
:return: the custom shape
|
|
32
37
|
"""
|
|
33
38
|
|
|
@@ -35,6 +40,7 @@ class UserShape:
|
|
|
35
40
|
def custom_triangle() -> ReturnShapeType:
|
|
36
41
|
"""
|
|
37
42
|
Creates a custom equilateral triangle turtle shape.
|
|
43
|
+
|
|
38
44
|
:return: the custom shape
|
|
39
45
|
"""
|
|
40
46
|
|
|
@@ -42,6 +48,7 @@ class UserShape:
|
|
|
42
48
|
def custom_poly() -> ReturnShapeType:
|
|
43
49
|
"""
|
|
44
50
|
Creates a custom regular polygon turtle shape.
|
|
51
|
+
|
|
45
52
|
:return: the custom shape
|
|
46
53
|
"""
|
|
47
54
|
|
|
@@ -49,19 +56,22 @@ class UserShape:
|
|
|
49
56
|
def custom_SOD() -> ReturnShapeType:
|
|
50
57
|
"""
|
|
51
58
|
Creates a custom star of David turtle shape.
|
|
59
|
+
|
|
52
60
|
:return: the custom shape
|
|
53
61
|
"""
|
|
54
62
|
|
|
55
63
|
@classmethod
|
|
56
|
-
def
|
|
64
|
+
def list_shapes(cls) -> UserShapeDictType:
|
|
57
65
|
"""
|
|
58
|
-
Creates a dictionary with the functions in UserShape and returns it
|
|
66
|
+
Creates a dictionary with the functions in UserShape and returns it.
|
|
67
|
+
|
|
59
68
|
:return: dictionary containing function names -> function
|
|
60
69
|
"""
|
|
61
70
|
|
|
62
71
|
def get_UserShape_dict() -> UserShapeDictType:
|
|
63
72
|
"""
|
|
64
|
-
Takes all custom turtle functions in UserShape and returns a dictionary with them
|
|
73
|
+
Takes all custom turtle functions in UserShape and returns a dictionary with them.
|
|
74
|
+
|
|
65
75
|
:return: dictionary mapping function names to functions
|
|
66
76
|
"""
|
|
67
77
|
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/global_functions.py
RENAMED
|
@@ -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"
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/global_functions.pyi
RENAMED
|
@@ -5,34 +5,40 @@ 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.
|
|
12
|
+
|
|
11
13
|
:return: turtle screen object
|
|
12
14
|
"""
|
|
13
15
|
|
|
14
16
|
def SU() -> None:
|
|
15
17
|
"""
|
|
16
18
|
This function updates the turtle screen.
|
|
19
|
+
|
|
17
20
|
:return: None
|
|
18
21
|
"""
|
|
19
22
|
|
|
20
23
|
def mainloop() -> None:
|
|
21
24
|
"""
|
|
22
25
|
This function keeps the turtle screen open.
|
|
26
|
+
|
|
23
27
|
:return: None
|
|
24
28
|
"""
|
|
25
29
|
|
|
26
30
|
type TurtleListType = list[ChainTurtle]
|
|
27
31
|
|
|
28
32
|
def tls_color(**options) -> int | tuple[TurtleListType, int] | TurtleListType | None:
|
|
29
|
-
"""
|
|
33
|
+
"""
|
|
34
|
+
This function creates a turtle list with their colors or adds newly creates turtles to the UV["tls"] list
|
|
30
35
|
to be used for the user_drawing_ft()
|
|
31
36
|
|
|
32
37
|
USERS NOTICE: it is HIGHLY recommended to NOT enter a turtles count of MORE than a few hundred (max. 200) unless required!!!
|
|
33
38
|
|
|
34
39
|
:param options: tl_num -> number of turtles to create, entry -> input string, index -> number of turtles to be created for user_drawing_ft()
|
|
35
40
|
& it returns the index of the last turtle
|
|
41
|
+
|
|
36
42
|
:return: tls_num: turtle list with colored turtles, entry: list with colored turtles + number of turtles ,otherwise: index of last turtle
|
|
37
43
|
"""
|
|
38
44
|
|
|
@@ -41,6 +47,7 @@ def reset_tls(tls_list: TurtleListType) -> list:
|
|
|
41
47
|
This function deletes the drawings of given turtle list + turtles
|
|
42
48
|
|
|
43
49
|
>>> tls = [ChainTurtle(), ChainTurtle()]
|
|
50
|
+
|
|
44
51
|
>>> reset_tls(tls)
|
|
45
52
|
[]
|
|
46
53
|
|
|
@@ -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"]
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/turtle_functions.py
RENAMED
|
@@ -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:
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/foundations/turtle_functions.pyi
RENAMED
|
@@ -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.
|
|
@@ -12,7 +13,9 @@ class TurtleFct:
|
|
|
12
13
|
def change_shape(cls, tls_num: ChainTurtle|None = None) -> ChainTurtle | str:
|
|
13
14
|
"""
|
|
14
15
|
This function lets the user choose different turtles shapes, including a custom option.
|
|
16
|
+
|
|
15
17
|
:param tls_num: ChainTurtle() or None
|
|
18
|
+
|
|
16
19
|
:return: ChainTurtle() if tls_num is a ChainTurtle(), otherwise None
|
|
17
20
|
"""
|
|
18
21
|
|
|
@@ -20,6 +23,8 @@ class TurtleFct:
|
|
|
20
23
|
def user_tls_shape_ft(tls_num: ChainTurtle | None = None) -> ChainTurtle | str:
|
|
21
24
|
"""
|
|
22
25
|
This function lets the user create custom turtle shapes.
|
|
26
|
+
|
|
23
27
|
:param tls_num: ChainTurtle() or None
|
|
28
|
+
|
|
24
29
|
:return: ChainTurtle() if tls_num is a ChainTurtle(), otherwise None
|
|
25
|
-
"""
|
|
30
|
+
"""
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/turtle_heart/turtle_skeleton.py
RENAMED
|
@@ -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)
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/turtle_extension/turtle_heart/turtle_skeleton.pyi
RENAMED
|
@@ -5,97 +5,127 @@ 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
|
+
"""
|
|
13
|
+
This class adds chaining functionality to turtle.Turtle
|
|
14
|
+
|
|
15
|
+
"""
|
|
10
16
|
def fd(self, distance: Real) -> ChainTurtle:
|
|
11
17
|
"""
|
|
12
18
|
Makes the turtle go forward with trace.
|
|
19
|
+
|
|
13
20
|
:param distance: distance in pixels
|
|
21
|
+
|
|
14
22
|
:return: ChainTurtle()
|
|
15
23
|
"""
|
|
16
24
|
|
|
17
25
|
def fd_inv(self, distance: Real) -> ChainTurtle:
|
|
18
26
|
"""
|
|
19
27
|
Makes the turtle go forward with no trace.
|
|
28
|
+
|
|
20
29
|
:param distance: distance in pixels
|
|
30
|
+
|
|
21
31
|
:return: ChainTurtle()
|
|
22
32
|
"""
|
|
23
33
|
|
|
24
34
|
def bk(self, distance: Real) -> ChainTurtle:
|
|
25
35
|
"""
|
|
26
36
|
Makes the turtle go backwards with trace.
|
|
37
|
+
|
|
27
38
|
:param distance: distance in pixels
|
|
39
|
+
|
|
28
40
|
:return: ChainTurtle()
|
|
29
41
|
"""
|
|
30
42
|
|
|
31
43
|
def bk_inv(self, distance: Real) -> ChainTurtle:
|
|
32
44
|
"""
|
|
33
45
|
Makes the turtle go backward with no trace.
|
|
46
|
+
|
|
34
47
|
:param distance: distance in pixels
|
|
48
|
+
|
|
35
49
|
:return: ChainTurtle()
|
|
36
50
|
"""
|
|
37
51
|
|
|
38
52
|
def rt(self, angle: Real) -> ChainTurtle:
|
|
39
53
|
"""
|
|
40
54
|
Makes the turtle turn right.
|
|
55
|
+
|
|
41
56
|
:param angle: angle in degrees
|
|
57
|
+
|
|
42
58
|
:return: ChainTurtle()
|
|
43
59
|
"""
|
|
44
60
|
|
|
45
61
|
def lt(self, angle: Real) -> ChainTurtle:
|
|
46
62
|
"""
|
|
47
63
|
Makes the turtle turn left.
|
|
64
|
+
|
|
48
65
|
:param angle: angle in degrees
|
|
66
|
+
|
|
49
67
|
:return: ChainTurtle()
|
|
50
68
|
"""
|
|
51
69
|
|
|
52
70
|
def setpos(self, x_val: Real, y_val: Real) -> ChainTurtle:
|
|
53
71
|
"""
|
|
54
72
|
Makes the turtle go to a specific position with a trace.
|
|
73
|
+
|
|
55
74
|
:param x_val: x position in pixels
|
|
75
|
+
|
|
56
76
|
:param y_val: y position in pixels
|
|
77
|
+
|
|
57
78
|
:return: ChainTurtle()
|
|
58
79
|
"""
|
|
59
80
|
|
|
60
81
|
def pu(self) -> ChainTurtle:
|
|
61
82
|
"""
|
|
62
83
|
Puts the pen down to leave a trace.
|
|
84
|
+
|
|
63
85
|
:return: ChainTurtle()
|
|
64
86
|
"""
|
|
65
87
|
|
|
66
88
|
def pd(self) -> ChainTurtle:
|
|
67
89
|
"""
|
|
68
90
|
Puts the pen up to not leave a trace.
|
|
91
|
+
|
|
69
92
|
:return: ChainTurtle()
|
|
70
93
|
"""
|
|
71
94
|
|
|
72
95
|
def seth(self, direction: Real) -> ChainTurtle:
|
|
73
96
|
"""
|
|
74
97
|
Sets the direction of the turtle starting East, going counterclockwise.
|
|
98
|
+
|
|
75
99
|
:param direction: direction in degrees
|
|
100
|
+
|
|
101
|
+
:return: ChainTurtle()
|
|
76
102
|
"""
|
|
77
103
|
|
|
78
104
|
def home(self) -> ChainTurtle:
|
|
79
105
|
"""
|
|
80
106
|
Sets the position of the turtle to home (0, 0) with trace, heading = 0 .
|
|
107
|
+
|
|
81
108
|
:return: ChainTurtle()
|
|
82
109
|
"""
|
|
83
110
|
|
|
84
111
|
def home_inv(self) -> ChainTurtle:
|
|
85
112
|
"""
|
|
86
113
|
Sets the position of the turtle to home (0, 0) without trace, heading = 0 .
|
|
114
|
+
|
|
87
115
|
:return: ChainTurtle()
|
|
88
116
|
"""
|
|
89
117
|
|
|
90
118
|
def begin_fill(self) -> ChainTurtle:
|
|
91
119
|
"""
|
|
92
120
|
Makes the turtle begin fill for a closed shape.
|
|
121
|
+
|
|
93
122
|
:return: ChainTurtle()
|
|
94
123
|
"""
|
|
95
124
|
|
|
96
125
|
def end_fill(self) -> ChainTurtle:
|
|
97
126
|
"""
|
|
98
127
|
Ends the turtle fill for a closed shape, therefore fills the shapes.
|
|
128
|
+
|
|
99
129
|
:return: ChainTurtle()
|
|
100
130
|
"""
|
|
101
131
|
|
|
@@ -105,9 +135,13 @@ class ChainTurtle:
|
|
|
105
135
|
steps: int | None = None) -> ChainTurtle:
|
|
106
136
|
"""
|
|
107
137
|
Makes the turtle draw a circle
|
|
138
|
+
|
|
108
139
|
:param radius: radius in pixels
|
|
140
|
+
|
|
109
141
|
:param extent: extent in degrees
|
|
142
|
+
|
|
110
143
|
:param steps: number of sides
|
|
144
|
+
|
|
111
145
|
:return: ChainTurtle()
|
|
112
146
|
"""
|
|
113
147
|
|
|
@@ -117,51 +151,72 @@ class ChainTurtle:
|
|
|
117
151
|
sides: int | None = None) -> ChainTurtle:
|
|
118
152
|
"""
|
|
119
153
|
Makes the turtle draw a circle and fills it
|
|
154
|
+
|
|
120
155
|
:param radius: radius in degrees
|
|
156
|
+
|
|
121
157
|
:param angle: angle in degrees
|
|
158
|
+
|
|
122
159
|
:param sides: number of sides
|
|
160
|
+
|
|
161
|
+
:return: ChainTurtle()
|
|
123
162
|
"""
|
|
124
163
|
|
|
125
164
|
def dot(self, radius: Real) -> ChainTurtle:
|
|
126
165
|
"""
|
|
127
166
|
Makes the turtle draw a colored dot
|
|
167
|
+
|
|
128
168
|
:param radius: radius in pixels
|
|
169
|
+
|
|
170
|
+
:return: ChainTurtle()
|
|
129
171
|
"""
|
|
130
172
|
|
|
131
173
|
def color(self, turtle_color: str) -> ChainTurtle:
|
|
132
174
|
"""
|
|
133
175
|
Lets the user change the color of the turtle trace and turtle color itself
|
|
176
|
+
|
|
134
177
|
:param turtle_color: valid turtle color
|
|
178
|
+
|
|
179
|
+
:return: ChainTurtle()
|
|
135
180
|
"""
|
|
136
181
|
|
|
137
182
|
def teleport(self, x: Real, y: Real, *, fill_gap: bool = False) -> ChainTurtle:
|
|
138
183
|
"""
|
|
139
184
|
Makes the turtle to go a specific coordinate with no trace
|
|
185
|
+
|
|
140
186
|
:param x: x position in pixels
|
|
187
|
+
|
|
141
188
|
:param y: y position in pixels
|
|
189
|
+
|
|
190
|
+
:return: ChainTurtle()
|
|
142
191
|
"""
|
|
143
192
|
|
|
144
193
|
def shape(self, shape_name: str) -> ChainTurtle:
|
|
145
194
|
"""
|
|
146
195
|
Changes the shape of the turtle shape
|
|
196
|
+
|
|
147
197
|
:param shape_name: name of the shape
|
|
198
|
+
|
|
199
|
+
:return: ChainTurtle()
|
|
148
200
|
"""
|
|
149
201
|
|
|
150
202
|
def undo(self) -> ChainTurtle:
|
|
151
203
|
"""
|
|
152
204
|
Undoes the last turtle command.
|
|
205
|
+
|
|
153
206
|
:return: ChainTurtle()
|
|
154
207
|
"""
|
|
155
208
|
|
|
156
209
|
def clear(self) -> ChainTurtle:
|
|
157
210
|
"""
|
|
158
211
|
Deletes the turtles drawings.
|
|
212
|
+
|
|
159
213
|
:return: ChainTurtle()
|
|
160
214
|
"""
|
|
161
215
|
|
|
162
216
|
def ht(self) -> ChainTurtle:
|
|
163
217
|
"""
|
|
164
218
|
Hides the turtle.
|
|
219
|
+
|
|
165
220
|
:return: ChainTurtle()
|
|
166
221
|
"""
|
|
167
222
|
|
|
@@ -169,5 +224,6 @@ class ChainTurtle:
|
|
|
169
224
|
def list_methods(cls) -> dict[str, Callable]:
|
|
170
225
|
"""
|
|
171
226
|
Creates a dictionary with all ChainTurtle methods and returns it
|
|
227
|
+
|
|
172
228
|
:return: dictionary
|
|
173
|
-
"""
|
|
229
|
+
"""
|
|
@@ -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
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{turtleextension-2.0.0 → turtleextension-2.2.0}/TurtleExtension.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|