Implements l-system fractals. Has common ones such as fractal plant and Koch curve.
Project description
L-System Fractals
Implementation of L-System Fractals. This package draws fractals in turtle.
Sample Generations
Table of Contents
- Installation
- Why Use l-system?
- Usage
- Versions
- Coming Soon
Installation
pip install l-system-fractals
Why Use l-system-fractals?
This package includes an base LSystem class with default subclasses for common l-system fractals:
- Fractal plant
- Koch curve
- Sierpinski triangle
- Sierpinski arrowhead curve
- Dragon curve
Usage
Example 1
Drawing custom L-Systems using the LSystem Class
from l_system_fractals import *
my_l_system = LSystem(
iterations=5,
start="X",
rules=[("X", "-F+X"), ("F", "-F-[X+F]+F")],
variable_rules=[("F", DRAW_FORWARD), ("X", MOVE_FORWARD)],
constant_rules=[("-", TURN_RIGHT), ("+", TURN_LEFT), ("[", SAVE_POS_AND_ANGLE), ("]", GO_TO_POS_ANGLE_AND_RESET_THEM)],
angle=30,
scale=2,
thickness=2,
start_angle=10
)
my_l_system.draw_turtle(pos=(0, 0), speed=0, end_turtle=True, instant=False, make_colorful=True, color_density=10)
Example 2
Drawing custom L-Systems using subclass of LSystem Class
from l_system_fractals import *
class MyLSystem(LSystem):
def __init__(self):
super().__init__(
iterations=5,
start="X",
rules=[("X", "-F+X"), ("F", "-F-[X+F]+F")],
variable_rules=[("F", DRAW_FORWARD), ("X", MOVE_FORWARD)],
constant_rules=[("-", TURN_RIGHT), ("+", TURN_LEFT), ("[", SAVE_POS_AND_ANGLE), ("]", GO_TO_POS_ANGLE_AND_RESET_THEM)],
angle=30,
scale=2,
thickness=2,
start_angle=10
)
my_l_system = MyLSystem()
my_l_system.draw_turtle(pos=(0, 0), speed=0, end_turtle=True, instant=False, make_colorful=True, color_density=10)
Example 3
Drawing L-System using pre-made classes
from l_system_fractals import *
my_l_system = FractalPlant(iterations=6, start = "X", scale = 3, thickness = 1, start_angle = 0)
my_l_system.draw_turtle(pos=(0, -300), speed=0, end_turtle=True, instant=False, make_colorful=True, color_density=10)
Versions
Version 0.0.1: Main code for l-system added. Version 0.0.2: README fixed. (Latest) Version 0.0.3: rename project name.
Coming Soon
Version 0.0.4: Add support for drawing L-Systems on a specific pen given by the user instead of creating a new pen.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file l_system_fractals-0.0.3.tar.gz.
File metadata
- Download URL: l_system_fractals-0.0.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0c4d4639a533b91443dd48329a7d6b26c1a2d8db8bb1719226a085691338452
|
|
| MD5 |
c196a4bc389c6e03a2ef76d72912e905
|
|
| BLAKE2b-256 |
9c133344f10752d70328577f22fa3e600570a5e64a578cda7719e9010061ca5a
|
File details
Details for the file l_system_fractals-0.0.3-py3-none-any.whl.
File metadata
- Download URL: l_system_fractals-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26a39f1d3a0c4d8c0b769a4f3c91078a0498c0e73750633df72bdcacb93a15bb
|
|
| MD5 |
3bc1d8c85db1ebd14d770ed41da2dd3e
|
|
| BLAKE2b-256 |
5edc340236f85b3d6e58cd58975575dff4ecbb21d1d801996a6ead3d5b1c1780
|