Home

Diagrams

I… occasionally just start producing random shapes, colors and transformations or combinations of them, using the diagrams library through the very handy diagrams-pandoc Pandoc filter, like here.

colors = [yellow, pink, violet, blue, white]
fstar k = mconcat
    [ let rest = if k == 0 then circle 0.1 else scale 0.3 (fstar (k-1))
      in (rest ||| (hrule 1 # lc (colors !! max 0 (k-1))) ||| rest) # rotateBy (fromIntegral j/n) # translateX 2
    | j <- [0..(n-1)]
    ]
    where n = 3
fstars = vcat [ fstar i | i <- [1..4] ]
example = mconcat
  [ mconcat
      [ fstars # rotateBy (fromIntegral j/m)
      | j <- [0..(m-1)]
      ] # rotateBy (fromIntegral k/p)
  | k <- [0..(p-1)]
  ] # bg black
    where m = 3
          p = 5
sinPlot = strokeP $ fromVertices
            [ p2 (x, sin x)
            | x <- [-2*pi, -2*pi+0.01 .. 2*pi]
            ]
col1 = darkblue
col2 = red
arm = (translateX 5 $ hrule 10 # lc col1) ||| (sinPlot # lc col2)

grid (a:(b:(c:(d:xs)))) = hcat [a,b,c,d] === grid xs
grid xs = hcat xs

example = return $ grid $
  [ mconcat [ arm # rotateBy (fromIntegral j/fromIntegral n) | j <- [0..(n-1)] ]
  | n <- [3, 5 .. 25]
  ]
sinPlot = strokeP $ fromVertices
            [ p2 (x, sin x)
            | x <- [-2*pi, -2*pi+0.01 .. 2*pi]
            ]
col1 = darkblue
col2 = red
arm = (translateX 5 $ hrule 10 # lc col1) ||| (sinPlot # lc col2)
arm2 = hcat [ mconcat [ arm # rotateBy (fromIntegral j/fromIntegral n) | j <- [0..(n-1)] ]
       | n <- [3, 5 .. 15]
       ]
example = return $ mconcat
  [ arm2 # rotateBy (fromIntegral j/fromIntegral n) | j <- [0..(n-1)]
  ] where n = 13

Posted: