Created
February 26, 2015 04:51
-
-
Save autotaker/b4b778a917a59693a7a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Diagrams.Prelude | |
import Diagrams.Backend.SVG.CmdLine | |
import Data.Colour.SRGB | |
sierpinski :: Double -> Int -> Diagram B R2 | |
sierpinski c 0 = triangle c | |
sierpinski c k = | |
let d' = sierpinski c (k-1) | |
l = c * 2^(k-1) | |
z = sqrt 3 / 2 * l / 3 | |
ps = [(0,z*2),(-l/2,-z),(l/2,-z)] in | |
position $ map (\p -> (p2 p,d')) ps | |
main :: IO () | |
main = mainWith d where | |
d c k = pad 1.1 $ sierpinski c k # lcA transparent # fc (sRGB 0.3 0.3 0.3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment