Turtex
This is an extension for the built-in turtle module. It provides functions for ease of development.
Installation
Run the following to install:
pip install turtex
Usage
Different Functions
- draw_poly
- draw_line
- draw_x
draw_poly(number_of_sides, length, turtle_obj = None)
Draws regular polygons (shapes) from the current position which will become the bottom left / top right corner of the shape (It depends on the orientation of the turtle).
| Arguments | Description |
|---|---|
| number_of_sides | An integer indicating number of sides of the polygon to be drawn. |
| length | An integer indicating the length of each side in pixels. |
| turtle_obj | A turtle object to draw with. The default value is the default turtle in the turtle module. |
Implementation
import turtex
# Configure the turtle to draw different coloured lines and of different thickness.
t = turtex.Turtle()
t.pensize(5)
t.color("black")
# The following code draws a pentagon (shape with 5 sides) with each side of length 15 using t as turtle_obj.
turtex.draw_poly(5, 15, t)
draw_line(start_pos, length, direction_in_angle, turtle_obj = None)
Draws a line from a given point. Turtle object remains at the end of the line after drawing it.
| Arguments | Description |
|---|---|
| start_pos | A list/tuple indicating the starting position of the line. |
| length | An integer or float indicating the length of the line in pixels. |
| direction_in_angle | An integer or float indicating the direction of the line in degrees. Follow table below for general directions. |
| turtle_obj | A turtle object to draw with. The default value is the default turtle in the turtle module. |
| Standard Mode | Logo Mode |
|---|---|
| 0 - East | 0 - North |
| 90 - North | 90 - East |
| 180 - West | 180 - South |
| 270 - South | 270 - West |
Implementation
import turtex
# Configure the turtle to draw different coloured line and of different thickness.
t = turtex.Turtle()
t.pensize(5)
t.color("black")
# The following code produces a line from (0, 0) of 50 length at 90 degrees(North) using t as turtle_obj.
turtex.draw_line((0, 0), 50, 90, t)
draw_x(start_pos, length, line_colour_top_left, line_colour_top_right, line_colour_bottom_left, line_colour_bottom_right, turtle_obj = None)
Draws an 'x' shape.
| Arguments | Description |
|---|---|
| start_pos | A list/tuple indicating the starting position of the 'x'. This is the center of the 'x'. |
| length | An integer or float indicating the length of each line in pixels. |
| line_colour_top_left | A list/tuple of rgb values if the colormode is 255 else a string indicating the colour of the top left line. |
| line_colour_top_right | A list/tuple of rgb values if the colormode is 255 else a string indicating the colour of the top right line. |
| line_colour_bottom_left | A list/tuple of rgb values if the colormode is 255 else a string indicating the colour of the bottom left line. |
| line_colour_bottom_right | A list/tuple of rgb values if the colormode is 255 else a string indicating the colour of the bottom right line. |
| turtle_obj | A turtle object to draw with. The default value is the default turtle in the turtle module. |
Implementation
import turtex
# Configure the turtle to draw lines of different thickness.
t = turtex.Turtle()
t.pensize(5)
# The following code produces a line from (0, 0) of 50 length with
# colors red, orange, yellow, green for the top_left, top_right, bottom_left,
# bottom_right lines respectively using t as turtle_obj.
turtex.draw_x((0, 0), 50, "red", "orange", "yellow", "green", t)
# Changing colormode to enter colors in rgb values.
turtex.colormode(255)
turtex.draw_x((0, 0), 50, (255, 0, 0), (255, 127, 0), (255, 255, 0), (0, 255, 0), t)
Metadata
Release files for turtex 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| turtex-0.0.3.tar.gz | 4.3 kB | Without provenance | Details for turtex-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| turtex-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for turtex-0.0.3-py3-none-any.whl |
Total release size: 8.3 kB
Release files / turtex-0.0.3.tar.gz
| Download URL | turtex-0.0.3.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
062633cd7d1f48d85b251592939e4872b21f112aba4980a815812fe20d9187a2
|
|
BLAKE2b-256 checksum How to use checksums |
c115b5885491c268f4831c3d0215cf864a1e80794e64e5e5bcda0b85e7d05469
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.3
|
Release files / turtex-0.0.3-py3-none-any.whl
| Download URL | turtex-0.0.3-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8209e36fd754ffeaacfbfc39c84819293373fa09da39205a08b8b5fca86123a
|
|
BLAKE2b-256 checksum How to use checksums |
be7d93fea2d960cffec2127c52c151a1784bae677d1314ac130ccd66cb0e955f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.3
|
Security for turtex 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.