Skip to main content

Package for generating and rendering Lsystems

Project description

Lsystem generator python lib

Current version: 1.0

This package enable to generate Lsystem representation by providing:

  • Axioms (e.g. : "F")
  • Rules of generation (e.g. F -> F+F--F+F)
  • Generation (e.g. 2 for the second generation)
  • Rules of display (using the turtle analogy)

Installation

pip install lsystem-generator==1.0

Usage

from lsystem.lsys_generator import Lsystem

if __name__=="__main__":
    lsys = Lsystem("F",("F", "F-Y-F"), ("Y", "Y+F+Y"))

    lsys.generate(2)
    image = lsys.render(("+",80), ("-",-80))
    image.show()

    lsys.generate(5)
    image = lsys.render(("+",60), ("-",-60))
    image.show()

note fore the user: after declaring a Lsystem, multiple generation generate() can be created and different representation can be obtained render()

help(Lsystem) gives a detailed documentation on how to create Lsystems, generate and render image representations

Performance limits

The programm is performing at generate lsystem in the first 10-15 generation, depending on the lenght of the rule for generation and the number of axioms and rules. At generation n+1 the lenght of the generated sequence will be:

    l_1 = number of axioms in sequence_n * lenght of the rule for generation for each axiom + characters that are not axioms in the sequence_n  

    = sum(number of axiom i in sequence_n * lenght of the rule i for this axiom) + (lenght of the sequence - sum(number of axiom i in sequence_n))

    = sum((l / l_rule_i * occ_a_i) * l_rule_i) + (l - sum(l / l_rule_i * occ_a_i) )  

with:

  • l: lenght of the sequence at generation n
  • l+1: lenght of the sequence at generation n
  • l_rule_i: lenght of the rule i for generation
  • occ_a_i: number of occurences of the axiom i in the rule i for generation
  • i: index of the pair (axiom, rule) defined in the Lsystem

The RAM available will depend on the system and the python installation you are running the lib with, the maximum string length that can be generated and thus the number of generation that can be produced will vary. If higher generation needs to be produced, a different implementation would be required.

Development

After downloading the sources run pip install -e . We recommand using a virtulanv to install pip dependencies

Running unit test (in development mode)

To run the tests execute from the root folder: pytest --testdox

if you encounter import difficulites, make sure the root directory, lsystem and tests dir are in the $PYTHONPATH. Run source .env to add them

License

Shield: CC BY-SA 4.0

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lsystem_generator-1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file lsystem_generator-1.0-py3-none-any.whl.

File metadata

  • Download URL: lsystem_generator-1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for lsystem_generator-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e996e16f233e52b6efa416cb3d40763bbc23278f6152c62185cb3b5b6a913e7
MD5 d81961b121e293de1b83e4e48b194aa1
BLAKE2b-256 39e686dc15986e19992060cf885602a60ab4afb80eaae60c6ee430d2641698e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page