Rule based images infrastructure. Generate PPM format text file, then convert it to an actual jpg w/ ImageMagick. % cat Foo.hs #!/usr/bin/env runhaskell import Data.List pri :: Show a => [a] -> String pri as = concat $ intersperse " " $ map show as prip :: (Int,Int,Int) -> String prip (r,g,b) = pri [r,g,b] size :: Int size = 50 wrap :: (Int,Int,Int) -> (Int,Int,Int) wrap (r, g, b) = (r `mod` 256, g `mod` 256, b `mod` 256) black :: (Int,Int,Int) black = (0,0,0) comb :: (Int,Int,Int) -> (Int,Int,Int) -> (Int,Int,Int) comb (r1,g1,b1) (r2,g2,b2) = wrap (r1+r2,g1+g2,b1+b2) comb2 :: (Int,Int,Int) -> (Int,Int,Int) -> (Int,Int,Int) comb2 (r1,g1,b1) (r2,g2,b2) = wrap (r1 `mod` 64 +b2 `mod` 196,g1 `mod` 32+r2 `mod` 128,(1+b1 `mod` 16)*(1+g2 `mod` 16)) i :: Int -> [(Int,Int,Int)] i wi = map wrap $ map (\i -> (11*i,truncate(sqrt(fromIntegral(7*i))),truncate((sin(fromIntegral(i))+fromIntegral(1))*fromIntegral(101)))) [1..wi] wi :: [(Int,Int,Int)] -> [[(Int,Int,Int)]] wi [] = [] wi ps = transpose [ take (length ps) (drop (length ps - 1) (cycle ps)) , ps , take (length ps) (drop 1 (cycle ps)) ] step :: [(Int,Int,Int)] -> [(Int,Int,Int)] step ps = map (\ps -> foldl comb black (drop 1 ps)) $ wi ps alg :: [[(Int,Int,Int)]] -> [[(Int,Int,Int)]] alg [] = [i size] alg (h:t) = (step h):h:t main = do putStrLn "P3" putStrLn $ pri [size, size] putStrLn $ "255" mapM_ putStrLn $ map prip $ concat $ iterate alg [] !! size % ./Foo.hs > 0119.ppm && convert 0119.ppm -filter box -resize 1600% 0119.jpg %