Coder Social home page Coder Social logo

pynrose's Introduction

pynrose - P3 Penrose Tiling Generator

This is a python library and stand-alone program to generate P3 penrose tilings.

Installation

pip install pynrose

Stand-alone program

As a stand-alone program, this is able to generate P3 penrose tilings to SVG. It supports a two modes of operation.

The SVG mode outputs each rhombus as a separate closed path, with different styles applied to thick and thin rhombii. This is intended for visual/display applications.

example svg output

The SVGLINE mode outputs each rhombus edge as a separate path, and ensures the edges are deduplicated, to avoid re-cutting/etching the same line multiple times, for CNC/laser etching types of applications.

example svgline output

In both modes, the tiling can be split up into multiple smaller tilings that can be recombined with no overlaps or missing rhombii. This allows a tiling to be split up into multiple smaller parts, based on the constraints of the manufacturing process, and then assembled into a single large tiling.

CLI Usage

To generate a random penrose tiling as an SVG

pynrose > tiling.svg

To explore more of the options that are available, you can use --help or -?

pynrose --help

API Usage

This also exposes an API that can be used to generate P3 penrose tilings programatically for any other use you may have.

The API documentation can be found at https://pynrose.readthedocs.io

from pynrose import Tiling, Grid, Vector

# generate a new tiling with random offsets
tiling = Tiling()
grid = Grid(Vector(0, 0), Vector(20, 20))

# iterate over all rhombii whose midpoints are in the grid cell from (0, 0) to (20, 20)
for rhombus in tiling.rhombii(grid.cell(0, 0)):
    print(rhombus.vertices)

Generation Algorithm

The generation algorithm is based on the de Bruijn method, where there are 5 families of equally spaced parallel lines, and each line intersection represents a rhombus in the penrose tiling.

You can read more at

pynrose's People

Contributors

jesusfreke avatar

Watchers

 avatar  avatar

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.