Vikrant

0 - I have created new universe out of nothing, come have a look at it!

Fractals

It took few beautiful lines of haskell code to generate these beautiful shapes :)

sierpinskie Triangle

Sierpinskie Triangle

module Main
where
import Graphics.HGL

fillTri::Window->Int->Int->Int->IO()
fillTri w x y size =
    drawInWindow w ( withColor Blue
    (polygon [(x,y),(x+size,y),(x,y-size)]))


minSize::Int
minSize = 8

sierpinskiTri::Window->Int->Int->Int->IO()
sierpinskiTri w x y size = 
    if size < minSize
    then fillTri w x y size
    else let size2 = size `div` 2
      in do sierpinskiTri w x y size2
        sierpinskiTri w (x+size2) y size2
        sierpinskiTri w x (y-size2) size2

main =  runGraphics(
    do w <- openWindow "Sierpinski Triangle" (400,400)
       sierpinskiTri w 50 300 256
       k <- getKey w
       closeWindow w
    )

Snowflake

Snowflake

Snowflake

Snowflake

Comments

why don't you put the code also here?

int i, j for i=0 to 256 do for j=0 to 256 do plot (i, i and j) endfor endfor and you get the sierpinski triangle :) Sed.