Giter VIP home page Giter VIP logo

penrose's Introduction

Penrose Tiling Generator

Introduction

This is a highly customizable penrose tiling generator using python.

A penrose tiling is a tiling of shapes (in this code, a thin and a thick rhombus) that has five-fold roational symmetry, reflection symmetry, but not translational symmetry. What this means is that the pattern will never repeat, even if you continue it to infinity.

For more on penrose tilings, you may wish to consult the wiki page.

Examples are at the bottom.

Usage

When running the code, you will be prompted to enter 5 pieces of information:

  • Number of Tiling Layers/Subdivions
    • This code generates the tiling by subdiving triangles, which are in pairs to from the rhombi
    • This gets intricate quickly, and depending on your computer, anything above 10 may not render so quickly
    • Example: 7
  • Zoom
    • You can decide whether or not to zoom in
    • When zoomed in, the entire rectangle is filled with the pattern
    • If you want the whole decagon (currently only with transparent background), you can choose to not zoom in
    • The only valid options are in and out
  • Image Resolution
    • This code will output the tiling as a png file
    • You can specify the resolution of the image
    • The scale of the tiling will remain unaffected
    • Example: 1080 1080
  • Colors
    • Here you can have fun and pick the colors you want the tiling to be in
    • You can choose the color of the thin rhombi, the thick rhombi, and the outline
    • Presets: red, orange, yellow, green, blue, purple, grey, brown, black, white
    • Hex Color Codes are also supported - ex. a48432
    • If you really want to have some fun (or are lazy like me), use random
    • Example: red c27320 random
  • Output Filename
    • This will determine the name of the file that will house your penrose tiling
    • This file is a png and must end in .png
    • Filepaths are in theory supported, though not thoroughly tested
    • Example: example.png

The Code

While the customizability and most of the rendering logistics were created by me, I had help with the mathematical portion of the code.

Preshing.com has a great article here on how the theory behind this works, and some code that I based my own code off of.

A basic rundown of the functionality of my code is:

  1. Prompt the user for the customization options,then parse them and raise errors if they are not correct
  2. Create the 10 large trinagles
  3. Loop to divide each triangle the specified number of times
  4. Color the triangles
  5. Outline the triangles to highlight the rhombi

Examples

2 Tiling Layers

penrose2-1.png  penrose2-2.png penrose2-3.png

5 Tiling Layers

penrose5-1.png

7 Tiling Layers

penrose7-1.png penrose7-2.png penrose7-3.png

10 Tiling Layers

penrose10-1.png

13 Tiling Layers (8k resolution)

penrose13-1.png

penrose's People

Contributors

samm00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

penrose's Issues

Python Version

Hello i am looking to use the penrose pattern as a moving noise generator.
Your code seems to be the only one using vertex information to tile indefinatly.

When i try to run it i get the error.
And i was wondering if my python version has anything to do with it.

    p4 =
         ^
SyntaxError: invalid syntax```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.