Skip to content

Instantly share code, notes, and snippets.

@sordina
Created July 13, 2011 14:56
Show Gist options
  • Save sordina/1080459 to your computer and use it in GitHub Desktop.
Save sordina/1080459 to your computer and use it in GitHub Desktop.
Spiral
import Diagrams.AST
import Control.Arrow
import Data.List
main = outputImage "Foo.png" 800 800 image
image = Images $ Atop spiral background
spiral = Modifier (Changes [Align C, Foreground red, LineWidth 0]) $ Shape $ Path Closed $ Offsets poly
background = Modifier (Changes [Scale 1.5 1.5, Align C, Foreground white, LineWidth 0]) $ Shape Square
poly = drop 2 path ++ reverse (map (xx (*1.01)) path)
path = zipWith combine segments (cycle rotations)
segments = take 100 $ iterate (*0.9) 1
rotations = [(1,0),(0,-1),(-1,0),(0,1)]
combine (f) (a,b) = (f * a, f * b)
red = RGBA 1 0 0 1
white = RGBA 1 1 1 1
xx f = f *** f
shuffle x y = concat $ transpose [x, y]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment