Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

nisanMan/PythagoreanTree

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pythagorean Tree Generator

Overview

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.

Project Structure

PythagoreanTree/
├── main.py
├── tree/
│   ├── __init__.py
│   ├── generator.py
│   ├── drawer.py
│   ├── background.py
│   └── scene_generator.py
├──output/
│   ├── output.png
├── requirements.txt
├──README.md
└──.gitignore

Libraries

Requirements

  • Python 3.x
  • Install dependencies with:
pip install -r requirements.txt

Example .png Output

Tree Base Sunny Scene

Usage

To generate the Pythagorean tree, simply run:

python main.py

This will generate multiple images with different background

settings and tree designs.

Tree Customization Each tree can be configured using the following parameters in tree_gen.generate(...):

generate(x, y, length, angle, branch_angle, depth)

Tree Generation Parameters

  • x, y: starting position of the tree
  • length: length of the base square
  • angle: starting angle (usually π/2)
  • branch_angle: angle between branches (e.g., np.pi / 4)
  • depth: recursion depth (e.g., 10)

Tree Styling

Each tree dictionary also supports:

  • start_color: RGB tuple for the base color
  • end_color: RGB tuple for the top color
  • gradient: one of "linear", "reverse", "constant"

Scene Configuration

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
}

generator.py

Alt Text

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.