1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| import Data.Monoid
import System.IO
import System.Random
import Graphics.Gloss
a = take 11250 (iterate ( \row -> zipWith (+) ([0] ++ row) (row ++ [0])) [1])
b :: [Int]
b = concat a
c = [0..150] :: [Float]
d = [0..150] :: [Float]
e = [(x, y) | x <- c, y <- d]
main = do
affiche
affiche = display
(InWindow
"Pascal"
(300, 300)
(10, 10))
black
(picture)
picture = pictures (listOfPoints n p coul)
where
n = 91200
p = 0
coul = 0
listOfPoints 0 _ _ = []
listOfPoints n p coul = point : listOfPoints (n-1) p' coul'
where
p' = calcp n p
coul' = teinte n
point = dessin n p' coul'
teinte n
|(b !! n) < 128 = ((256`mod`(256 - 2*(b !! n)))`mod`13)
|otherwise = 0
dessin n p' coul'
|fst(e !! p') > snd(e !! p') = translate (0) (0) (color black (circle 0.0))
|n <= 11400 = translate (fst(e !! p')) (snd(e !! p')) (color (myColor (coul'))(circle 1.0))
|n <= 22800 = translate (-fst(e !! p')) (snd(e !! p')) (color (myColor (coul'))(circle 1.0))
|n <= 34200 = translate (fst(e !! p')) (-snd(e !! p')) (color (myColor (coul'))(circle 1.0))
|n <= 45600 = translate (-fst(e !! p')) (-snd(e !! p')) (color (myColor (coul'))(circle 1.0))
|n <= 57000 = translate (snd(e !! p')) (fst(e !! p')) (color (myColor (coul'))(circle 1.0))
|n <= 68400 = translate (-snd(e !! p')) (fst(e !! p')) (color (myColor (coul'))(circle 1.0))
|n <= 79800 = translate (snd(e !! p')) (-fst(e !! p')) (color (myColor (coul'))(circle 1.0))
|otherwise = translate (-snd(e !! p')) (-fst(e !! p')) (color (myColor (coul'))(circle 1.0))
calcp n p
|n == 0 = 0
|n`mod`11400 == 0 = 0
|otherwise = p + 2
myColor coul' = ( [ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck,cl,cm,cn,co,cp] !! abs(round(coul')) )
ca = white
cb = light(light yellow)
cc = light yellow
cd = yellow
ce = light(light orange)
cf = light orange
cg = orange
ch = light (dark orange)
ci = light red
cj = red
ck = dark red
cl = light violet
cm = violet
cn = light(light (dark violet))
co = light ( dark violet)
cp = blue |
Partager