Bonjour,
Je n'arrive pas a terminer ce petit bout de code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Car j'ai le message :
Pascal1.hs:35:17:
No instance for (RealFrac Int) arising from a use of `dessin'
Possible fix: add an instance declaration for (RealFrac Int)
In the expression: dessin n p' coul'
In an equation for `point': point = dessin n p' coul'
In an equation for `listOfPoints':
listOfPoints n p coul
= point : listOfPoints (n - 1) p' coul'
where
p' = calcp n p
coul' = teinte n
point = dessin n p' coul'

La valeur de couleur doit absolument être déterminée selon la formule de teinte, si non pas de Pascal Carpet :
Nom : Pascal2.jpg
Affichages : 162
Taille : 623,1 Ko( une des images obtenues par VB6. )
Alors, au secours !
Ah, en ajoutant fromIntegral devant coul' dans le dessin ça marche. Le dessin n'est pas bon, je doit revoir mes equations, la liste actuelle correspond bien au triangle de Pascal, mais la fractale nécessité une liste obtenue par un algorithme différent.