This project generates visual scenes containing Pythagorean trees, using OpenCV and NumPy. Each scene can include a sky, earth, sun, moon, and stars, and multiple fractal trees with customizable colors and styles.
PythagoreanTree/
├── main.py
├── tree/
│ ├── __init__.py
│ ├── generator.py
│ ├── drawer.py
│ ├── background.py
│ └── scene_generator.py
├──output/
│ ├── output.png
├── requirements.txt
├──README.md
└──.gitignore
- Python 3.x
- Install dependencies with:
pip install -r requirements.txtTo generate the Pythagorean tree, simply run:
python main.pyThis will generate multiple images with different background
Tree Customization
Each tree can be configured using the following parameters in tree_gen.generate(...):
generate(x, y, length, angle, branch_angle, depth)x, y: starting position of the treelength: length of the base squareangle: starting angle (usuallyπ/2)branch_angle: angle between branches (e.g.,np.pi / 4)depth: recursion depth (e.g.,10)
Each tree dictionary also supports:
start_color: RGB tuple for the base colorend_color: RGB tuple for the top colorgradient: one of"linear","reverse","constant"
Each scene is defined by a dictionary like:
{
"day": True or False, # Background color (day/night)
"sun": True or False, # Show sun
"moon": True or False, # Show moon and stars
"text": "Scene title", # Text label
"file": "output_file.png" # Output file name
}

