Skip to main content

L-System Fractals

Implementation of L-System Fractals. This package draws fractals in turtle.

Sample Generations

Sample Colorful Fractal Plant Sample Colorful Koch Curve Sample Colorful Sierpinski Triangle Sample Colorful Sierpinski Arrowhead Curve Sample Colorful Dragon Curve


Table of Contents

  • Why Use l-system?
  • Usage
  • Versions
  • Coming Soon

Why Use l-system-fractals?

This package includes an base LSystem class with in-built subclasses for common l-system fractals:

  • Fractal plant
  • Koch curve
  • Sierpinski triangle
  • Sierpinski arrowhead curve
  • Dragon curve

Usage

Sample Code 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 changes.

Version 0.0.3: Bug fixes.

(Latest) Version 0.0.4: Refactor Code.


Coming Soon

Version 0.0.5: Add support for drawing L-Systems on a specific pen given by the user instead of creating a new pen.

Metadata

Release files for l-system-fractals 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for l-system-fractals 0.0.4
File Size Uploaded
l_system_fractals-0.0.4.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for l-system-fractals 0.0.4
File Interpreter ABI Platform
l_system_fractals-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / l_system_fractals-0.0.4.tar.gz

Download URL l_system_fractals-0.0.4.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e296c0bde01139a220f56d5ae11cf25f9c1c258eb965f3ad455337ae0f8f0482
BLAKE2b-256 checksum
How to use checksums
3e7087e8b5bbe00da7c14a1d4aa2843b3bdf8f382256d6db18af5772f0f01f67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / l_system_fractals-0.0.4-py3-none-any.whl

Download URL l_system_fractals-0.0.4-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25ca9222e3327d77c0d5bf3d325b7224e6b6a9436a69464e4f8dc9118be70f25
BLAKE2b-256 checksum
How to use checksums
4a5735ecddd23afa604d1440bf0baacf06f709a23ca76587cb2a1119af374e15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.0.6

2 release files

0.0.5

2 release files

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page