Skip to content

Instantly share code, notes, and snippets.

@yellowflash
Created July 17, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yellowflash/2752f32c3cb37d064d54d683fbe3ab88 to your computer and use it in GitHub Desktop.
Save yellowflash/2752f32c3cb37d064d54d683fbe3ab88 to your computer and use it in GitHub Desktop.
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
appendsEx k n c = appends c (zip (iterateN n (rotateBy (1/(fromIntegral k))) unitX) (repeat circ))
circ = (circle 1 # fc red # lc white # lwL 0.25)
sides = 6
create :: Int -> Diagram B
create n = (create' (n - 1) sides circ) <> strut 30 where
create' n k sofar | n <= k = appendsEx k n sofar
create' n k sofar = create' (n - k) (k + sides) (appendsEx k k sofar)
myCircle :: [(String, Diagram B)]
myCircle = zip (map show [1..100]) (map create [1..100])
main :: IO ()
main = mainWith myCircle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment