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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
import Data.Monoid
import System.IO
import System.Random
import Graphics.Gloss
larg = 320
haut = 200
minX = fromIntegral -2.4
maxX = fromIntegral 2.4
minY = fromIntegral -1.5
maxY = fromIntegral 1.5
rc = [ (minX + (maxX - minX)`div`larg * x) | x <- [0,1..319]]
ic = [ (minY + (maxY - minY)`div`haut * y) | y <- [0,1..199]]
x = [0,1..319]
y = [0,1..199]
main = do
let rz = 1
let iz = 0
affiche rz iz
main
affiche rz iz = display
(InWindow
"Simple Mandel" -- window title
(320, 200) -- window size
(10, 10)) -- window position 20
black -- background color
(picture rz iz) -- picture to display
picture rz iz = pictures (listOfPoints n rz iz r i temoin c l m)
where
n = 1920
r = 0
i = 0
temoin = 0
c = 1
l = 0
m = 0
listOfPoints 0 _ _ _ _ _ _ _ _ = []
listOfPoints n rz iz r i temoin c l m = point : listOfPoints (n-1) rz' iz' r' i' temoin' c' l' m'
where
r' = rz
i' = iz
c' = comptec c n
l' = comptel l c
rz' = r'*r' - i'*i' + (rc !! (l'))
iz' = 2*r'*i' + (ic !! (c'))
temoin' = (rz'*rz' + iz'*iz')
m' = fixem temoin'
point = choixp c' l' m'
fixem temoin'
|temoin' > 4 = 5
|temoin' <= 4 = 3
comptec c n
|n`mod`200 <= 0 = c+1
|n`mod`200 > 0 = c
comptel l c
|c`mod`200 <= 0 = l+1
|c`mod`200 > 0 = l
choixp n c' l' m'
|m' > 4 = translate (x !! (l')) (y !! (c')) (color (myColor(n/2)) (circle (1.0)))
|m' <= 4 = translate (0) (0) (color red (circle (1.0)))
myColor n = ( [ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck,cl,cm,cn,co,cp] !! (round(n/120)) )
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