ip1tricks 0.1.1__py3-none-any.whl
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.
ip1tricks/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import *
|
ip1tricks/core.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ip1tricks: A simplified wrapper for Python's turtle module.
|
|
3
|
+
|
|
4
|
+
Author: Scrol
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from turtle import *
|
|
8
|
+
import math
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'move', 'turn', 'line', 'polygon', 'circle2', 'arc',
|
|
12
|
+
'setcolor', 'instant', 'set_speed', 'accelerate', 'hide', 'finish'
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
# ---------- MOVEMENT ----------
|
|
16
|
+
|
|
17
|
+
def move(x, y):
|
|
18
|
+
"""
|
|
19
|
+
Moves the turtle to the specified (x, y) coordinates without drawing.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
x (int/float): The x-coordinate to move to.
|
|
23
|
+
y (int/float): The y-coordinate to move to.
|
|
24
|
+
"""
|
|
25
|
+
penup()
|
|
26
|
+
goto(x, y)
|
|
27
|
+
pendown()
|
|
28
|
+
|
|
29
|
+
def turn(angle):
|
|
30
|
+
"""
|
|
31
|
+
Turns the turtle to the left by the specified angle.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
angle (int/float): The angle in degrees to turn left.
|
|
35
|
+
"""
|
|
36
|
+
lt(angle)
|
|
37
|
+
|
|
38
|
+
# ---------- SHAPES ----------
|
|
39
|
+
|
|
40
|
+
def line(length):
|
|
41
|
+
"""
|
|
42
|
+
Draws a straight line of the specified length.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
length (int/float): The distance to move forward.
|
|
46
|
+
"""
|
|
47
|
+
fd(length)
|
|
48
|
+
|
|
49
|
+
def polygon(length, sides):
|
|
50
|
+
"""
|
|
51
|
+
Draws a regular polygon with a given side length and number of sides.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
length (int/float): The length of each side.
|
|
55
|
+
sides (int): The number of sides in the polygon.
|
|
56
|
+
"""
|
|
57
|
+
for i in range(sides):
|
|
58
|
+
fd(length)
|
|
59
|
+
lt(360 / sides)
|
|
60
|
+
|
|
61
|
+
def circle2(radius):
|
|
62
|
+
"""
|
|
63
|
+
Draws a full circle with the specified radius.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
radius (int/float): The radius of the circle.
|
|
67
|
+
"""
|
|
68
|
+
arc(radius, 360)
|
|
69
|
+
|
|
70
|
+
def arc(radius, angle):
|
|
71
|
+
"""
|
|
72
|
+
Draws an arc with a given radius and extent (angle).
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
radius (int/float): The radius of the arc.
|
|
76
|
+
angle (int/float): The extent of the arc in degrees.
|
|
77
|
+
"""
|
|
78
|
+
circumference = 2 * math.pi * radius
|
|
79
|
+
|
|
80
|
+
# Calculate steps to make the arc look smooth
|
|
81
|
+
steps = int(circumference / 4)
|
|
82
|
+
if steps < 1: steps = 1
|
|
83
|
+
|
|
84
|
+
stepangle = angle / steps
|
|
85
|
+
steplength = (circumference * angle / 360) / steps
|
|
86
|
+
|
|
87
|
+
for i in range(steps):
|
|
88
|
+
fd(steplength)
|
|
89
|
+
lt(stepangle)
|
|
90
|
+
|
|
91
|
+
# ---------- UTIL ----------
|
|
92
|
+
|
|
93
|
+
def setcolor(c):
|
|
94
|
+
"""
|
|
95
|
+
Sets the turtle's pen color.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
c (str): The color name (e.g., 'red', '#FF0000').
|
|
99
|
+
"""
|
|
100
|
+
color(c)
|
|
101
|
+
|
|
102
|
+
def instant():
|
|
103
|
+
"""
|
|
104
|
+
Sets the drawing speed to the fastest possible (no animation).
|
|
105
|
+
"""
|
|
106
|
+
speed(0)
|
|
107
|
+
|
|
108
|
+
def set_speed(value):
|
|
109
|
+
"""
|
|
110
|
+
Sets the turtle drawing speed.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
value (int): Speed value from 0 (fastest) to 10 (slowest).
|
|
114
|
+
"""
|
|
115
|
+
speed(value)
|
|
116
|
+
|
|
117
|
+
def accelerate():
|
|
118
|
+
"""
|
|
119
|
+
Increases the speed to the maximum (instant drawing).
|
|
120
|
+
"""
|
|
121
|
+
set_speed(0)
|
|
122
|
+
|
|
123
|
+
def hide():
|
|
124
|
+
"""
|
|
125
|
+
Hides the turtle icon.
|
|
126
|
+
"""
|
|
127
|
+
hideturtle()
|
|
128
|
+
|
|
129
|
+
def finish():
|
|
130
|
+
"""
|
|
131
|
+
Keeps the turtle window open until it is manually closed.
|
|
132
|
+
"""
|
|
133
|
+
mainloop()
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ip1tricks
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A simplified wrapper for Python's turtle module, perfect for beginners.
|
|
5
|
+
Author-email: Scrol <shanrsjmax@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/scr-ol/ip1tricks
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/scr-ol/ip1tricks/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# ip1tricks 🐢
|
|
17
|
+
|
|
18
|
+
**A simplified, beginner-friendly wrapper for Python's Turtle graphics.**
|
|
19
|
+
|
|
20
|
+
Created by **Scrol**.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🌟 Introduction
|
|
25
|
+
|
|
26
|
+
Welcome to `ip1tricks`! If you've ever wanted to create beautiful digital art with Python but found the standard `turtle` module a bit overwhelming, this library is for you. We've simplified the commands so you can focus on your creativity.
|
|
27
|
+
|
|
28
|
+
Whether you're a Python newbie or a seasoned coder looking for a quick way to draw shapes, `ip1tricks` makes it easy to create complex patterns like flowers, spirals, and polygons with just a few lines of code.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚀 Installation
|
|
33
|
+
|
|
34
|
+
You can install `ip1tricks` directly from source:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🎨 Getting Started (For Newbies)
|
|
43
|
+
|
|
44
|
+
In Python Turtle, you control a small "turtle" on a screen. Think of it like a robot with a pen attached to its tail. As the robot moves, it leaves a trail.
|
|
45
|
+
|
|
46
|
+
### The Basic Workflow:
|
|
47
|
+
1. **Import the tools**: `from ip1tricks import *`
|
|
48
|
+
2. **Setup**: `instant()` to make it draw fast.
|
|
49
|
+
3. **Move and Draw**: Use commands like `line()`, `turn()`, and `arc()`.
|
|
50
|
+
4. **Finish**: `hide()` the turtle and `finish()` to keep the window open.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 📚 Core Concepts & Theory
|
|
55
|
+
|
|
56
|
+
### 1. The Coordinate System
|
|
57
|
+
The screen is a grid. The center is `(0, 0)`.
|
|
58
|
+
- Moving **Forward** means moving in the direction the turtle is facing.
|
|
59
|
+
- **Turning** changes the turtle's direction (Heading).
|
|
60
|
+
|
|
61
|
+
### 2. Angles and Shapes
|
|
62
|
+
- A full circle is **360 degrees**.
|
|
63
|
+
- To draw a **Square**, you turn 90 degrees four times (360 / 4).
|
|
64
|
+
- To draw a **Triangle**, you turn 120 degrees three times (360 / 3).
|
|
65
|
+
- **The Rule**: To draw a polygon with `n` sides, you turn `360 / n` degrees at each corner.
|
|
66
|
+
|
|
67
|
+
### 3. How Arcs Work
|
|
68
|
+
An arc is a piece of a circle. We calculate the `circumference` (the total distance around a circle) using `2 * π * radius`. To make the drawing look smooth, we break the arc into many tiny straight lines.
|
|
69
|
+
- **Radius**: How big the circle would be.
|
|
70
|
+
- **Angle**: How much of the circle to draw (e.g., 180 for a semi-circle).
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 🛠 Function Reference
|
|
75
|
+
|
|
76
|
+
| Function | What it does | Example |
|
|
77
|
+
| :--- | :--- | :--- |
|
|
78
|
+
| `move(x, y)` | teleports the turtle to (x, y) without drawing. | `move(100, 50)` |
|
|
79
|
+
| `line(length)` | Draws a straight line forward. | `line(100)` |
|
|
80
|
+
| `turn(angle)` | Turns left by a number of degrees. | `turn(90)` |
|
|
81
|
+
| `polygon(len, sides)` | Draws a shape with equal sides. | `polygon(50, 6)` |
|
|
82
|
+
| `arc(radius, angle)` | Draws a curved line. | `arc(100, 60)` |
|
|
83
|
+
| `circle2(radius)` | Draws a full circle. | `circle2(50)` |
|
|
84
|
+
| `setcolor(c)` | Changes the pen color. | `setcolor('red')` |
|
|
85
|
+
| `instant()` | Makes the drawing happen immediately. | `instant()` |
|
|
86
|
+
| `accelerate()` | Same as `instant()`, for faster drawing! | `accelerate()` |
|
|
87
|
+
| `hide()` | Makes the turtle icon disappear. | `hide()` |
|
|
88
|
+
| `finish()` | Stops the window from closing. | `finish()` |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🌈 Examples
|
|
93
|
+
|
|
94
|
+
### 1. The Classic Flower 🌸
|
|
95
|
+
This example uses overlapping `arc()` commands to create a beautiful floral pattern.
|
|
96
|
+
|
|
97
|
+
**How it works:**
|
|
98
|
+
1. We draw two arcs to create one "petal".
|
|
99
|
+
2. We turn slightly (36 degrees).
|
|
100
|
+
3. We repeat this 10 times (10 * 36 = 360) to complete the flower.
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from ip1tricks import *
|
|
104
|
+
|
|
105
|
+
instant()
|
|
106
|
+
setcolor('red')
|
|
107
|
+
|
|
108
|
+
for i in range(10):
|
|
109
|
+
# Draw a petal
|
|
110
|
+
arc(100, 60)
|
|
111
|
+
turn(120)
|
|
112
|
+
arc(100, 60)
|
|
113
|
+
turn(120)
|
|
114
|
+
|
|
115
|
+
# Rotate for the next petal
|
|
116
|
+
turn(36)
|
|
117
|
+
|
|
118
|
+
hide()
|
|
119
|
+
finish()
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+

|
|
123
|
+
|
|
124
|
+
### 2. The Vibrant Spiral 🌀
|
|
125
|
+
Spirals are created by drawing and turning, but slightly increasing the size or angle each time.
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from ip1tricks import *
|
|
129
|
+
|
|
130
|
+
instant()
|
|
131
|
+
|
|
132
|
+
for i in range(100):
|
|
133
|
+
setcolor(['red', 'purple', 'blue', 'green'][i % 4])
|
|
134
|
+
line(i * 2)
|
|
135
|
+
turn(91)
|
|
136
|
+
|
|
137
|
+
hide()
|
|
138
|
+
finish()
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+

|
|
142
|
+
|
|
143
|
+
---
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ip1tricks/__init__.py,sha256=nE8jJjGJaKuJKCyuf6QLfrj8xPj8IqGKeH2VXP3FMzY,21
|
|
2
|
+
ip1tricks/core.py,sha256=9DuMsS73_hT7PUi_jjoUIap0DakWxH0yRqX2PaTcPG0,2873
|
|
3
|
+
ip1tricks-0.1.1.dist-info/licenses/LICENSE,sha256=wOfRcNiyl7QmR-9PzI7MakbhJYYjMElMKsXXrff441k,1084
|
|
4
|
+
ip1tricks-0.1.1.dist-info/METADATA,sha256=1uKuxVOXBQXJRXJnUmwcTEIxfY_ezOOMQs19Bf7NfKw,4540
|
|
5
|
+
ip1tricks-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
ip1tricks-0.1.1.dist-info/top_level.txt,sha256=g-2Og-U0MPuGAOEyvcct_OuLipQyR1TVqXlb-FSLoG8,10
|
|
7
|
+
ip1tricks-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 scr-ol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ip1tricks
|