module Main where

import Data.List
import Graphics.Rendering.Diagrams

numCols,numRows :: Int
numCols = 23
numRows = 5

main :: IO ()
main = renderAs SVG "out2.svg" (Width width) dgram
    where width = (fromIntegral numCols) * 30

-- The diagram
dgram :: Diagram
dgram = vcat $ take numRows rows
    where rows = map hcat $ plines crps

-- The rows of polygons
plines :: [Diagram] -> [[Diagram]]
plines [] = []
plines pls = let (l,ls) = splitAt numCols pls
             in l : (plines ls)

-- Colored and rotated polygons
crps :: [Diagram]
crps = zipWith fillColor cs rps
    where rps = zipWith rotate rs ps
          rs = cycle . map (/ 4) $ [1..4]                 -- 4 rotations
          ps = cycle . map (flip regPoly 1) $ [3..7]      -- 5 polygons
          cs = cycle [red,black,green,blue,yellow,violet] -- 6 colors


