Code Monkey home page Code Monkey logo

spiro's Introduction

Spiro

A programm that draws spirograph patterns using up to 4 different Trochoids: Hypotrochoids, Epitrochoids, Hypocycloid and Epicycloids. Here are some example images generated with Spiro:

spiro1 spiro7 spiro8 spiro4 spiro3 spiro5 spiro10 spiro6 spiro2

Build / Install

Make sure you have gloss installed. To install gloss use:
$ cabal update
$ cabal install gloss

Clone this repo:
$ git clone https://github.com/lkamil/spiro.git
$ cd spiro

Compile and run Spiro.hs using:
$ ghc -o spiro Spiro.hs && ./spiro

Usage

To create different patterns play around with the 5 parameters: density, innerRadius, outerRadius, distance and loops.
Here you can look up what these parameters mean in detail.

-- parameters
innerRadius = 1     -- radius of the inner circle
outerRadius = 112   -- radius of the outer circle
distance    = 100   -- distance from the centre of the inner circle
loops       = 2     -- count of 360° loops
density     = 2000  -- higher density results in smoother lines

To generate a pattern you can combine all 4 trochoids or less. To add or delete a trochoid modify the array in the
function spiro.

-- this version of spiro draws a dark blue epitrochoid on top of a light green epicycloid
-- on top of a ... you get the point :)
spiro :: Picture
spiro = pictures
    [ color darkred $ line drawHypotrochoid
    , color rosee $ line drawHypocycloid
    , color lightgreen $ line drawEpicycloid
    , color darkblue $ line drawEpitrochoid
    ]

Feel free to change the colors or add new colors using the function makeColorI that takes 3 RGB values (from 0 to 255) and an alpha value that sets the transparency.

seagrean = makeColorI 32 178 170 255

spiro's People

Contributors

lkamil avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.