Pour répondre à une question que j'ai lu plus haut (plus une demande d'avis), le coloriage c'est pas facile !
Voici un code pour produire la courbe du dragon.
pour avancer dans les itérations [Left], pour dessiner le résultat [F1].
Malheureusement ça n'est pas obtimisé car j'ai fais ça il y a quelques années..
on peut obtenir ce genre d'image avec de la patience :

J'espère que j'ai pas coupé votre conversation

Code : Tout sélectionner
Global screen.point, tot.l = 20, mode.l, mini.l = 3, mode1.l = -1, milieumax.l = 1
; screen\x = 800
; screen\y = 600
screen\x = 1600
screen\y = 1000
#Cos_PI_4 = 0.70710678118
#Sin_PI_4 = 0.70710678118
Structure POINT_d
x.d
y.d
EndStructure
Structure Triangle
A.POINT_d
B.POINT_d
C.POINT_d
color_A.d
color_B.d
color_C.d
EndStructure
Procedure ls_GetColorPalette(abscisse.f, Ordonne.f, max.f, maxY.f); retourne la couleur d'une palette aux coordonnée specifie
Protected couleur, taux.f, index1.f, index2.f, index3.f, index4.f, index5.f
index1.f = max / 6
index2.f = 2 * max / 6
index3.f = 3 * max / 6
index4.f = 4 * max / 6
index5.f = 5 * max / 6
If Ordonne * 2 / maxY > 1
abscisse - index1
If abscisse < 0 : abscisse + max : EndIf
EndIf
If abscisse >= 0 And abscisse <= index1
couleur = RGB(255, (((abscisse * max) / index1) * 255) / max, 0)
EndIf
If abscisse > index1 And abscisse <= index2
couleur = RGB(((max - ((abscisse - index1) * max) / index1) * 255) / max, 255, 0)
EndIf
If abscisse > index2 And abscisse <= index3
couleur = RGB(0, 255, ((((abscisse - index2) * max) / index1) * 255) / max)
EndIf
If abscisse > index3 And abscisse <= index4
couleur = RGB(0, ((max - ((abscisse - index3) * max) / index1) * 255) / max, 255)
EndIf
If abscisse > index4 And abscisse <= index5
couleur = RGB(((abscisse - index4) * 255) / index1, 0, 255)
EndIf
If abscisse > index5 And abscisse <= max
couleur = RGB(255, 0, ((max - ((abscisse - index5) * max) / index1) * 255) / max)
EndIf
taux.f = Ordonne * 2 / maxY
If taux <= 1
couleur = RGB(taux * Red(couleur), taux * Green(couleur), taux * Blue(couleur))
Else
taux - 2
couleur = RGB(255 + taux * Green(couleur), 255 + taux * Blue(couleur), 255 + taux * Red(couleur))
EndIf
ProcedureReturn couleur
EndProcedure
ProcedureDLL CopySpriteToImage(Sprite, ImageID) ; par Drac version 4.02 par Dobro
hdc= StartDrawing ( SpriteOutput (Sprite))
bmp.BITMAP\bmWidth= SpriteWidth (Sprite)
bmp\bmHeight= SpriteHeight (Sprite)
bmp\bmPlanes=1
bmp\bmBitsPixel= GetDeviceCaps_ (hdc, #BITSPIXEL )
bmp\bmBits= DrawingBuffer ()
bmp\bmWidthBytes= DrawingBufferPitch ()
hBmp= CreateBitmapIndirect_ (bmp)
StopDrawing ()
;UseImage(ImageID)
StartDrawing ( ImageOutput ( ImageID ))
DrawImage (hBmp,0,0)
StopDrawing ()
DeleteObject_ (hBmp)
EndProcedure
If InitSprite() = 0 Or InitKeyboard() = 0 : End : EndIf
If OpenWindow(0, 0, 0, screen\x, screen\y, "Fractale - Courbe du Dragon", #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, screen\x, screen\y, 0, 0, 0)
Global NewList aze.triangle()
Global NewList qsd.triangle()
AddElement(aze())
result = Val(InputRequester("", "Base = ", "400"))
result1 = Val(InputRequester("", "Hauteur = ", "200"))
tot = Val(InputRequester("", "Nombre prévu d'itération = ", "10"))
offset.POINT\x = 0
offset\y = -100
aze()\a\x = (screen\x - result) / 2
aze()\a\y = (screen\y - result1) / 2 + result1 + offset\y
aze()\b\x = (screen\x - result) / 2 + result
aze()\b\y = (screen\y - result1) / 2 + result1 + offset\y
aze()\c\x = (screen\x - result) / 2 + result / 2
aze()\c\y = (screen\y - result1) / 2 + offset\y
aze()\color_A = 0
aze()\color_B = 0
aze()\color_C = 0
AddElement(aze())
aze()\a\x = (screen\x - result) / 2
aze()\a\y = (screen\y - result1) / 2 + result1 + offset\y
aze()\b\x = (screen\x - result) / 2
aze()\b\y = (screen\y - result1) / 2 + result1 + result + offset\y
aze()\c\x = (screen\x - result) / 2 + result1
aze()\c\y = (screen\y - result1) / 2 + result / 2 + result1 + offset\y
aze()\color_A = 0
aze()\color_B = 0
aze()\color_C = 0
Else
End
EndIf
Else
End
EndIf
Global milieu.l = result1
Global NewList Bord.POINT()
Procedure DrawTriangle(List lk.Triangle(), x, y, rapport1, pourcent = 0)
If mode = 4
color_1 = ls_GetColorPalette(pourcent, 125, 255, 255)
a_x.f = (lk()\a\x - x) * rapport1
a_y.f = (lk()\a\y - y) * rapport1
b_x.f = (lk()\b\x - x) * rapport1
b_y.f = (lk()\b\y - y) * rapport1
c_x.f = (lk()\c\x - x) * rapport1
c_y.f = (lk()\c\y - y) * rapport1
LineXY(a_x, a_y, b_x, b_y, color_1)
LineXY(b_x, b_y, c_x, c_y, color_1)
LineXY(c_x, c_y, a_x, a_y, color_1)
FillArea((a_x + b_x + c_x) / 3, (a_y + b_y + c_y) / 3, color_1, color_1)
ElseIf (mode = 0 Or mode = 2 Or mode = 3) And mode1 = -1
moy_AB = (lk()\color_A + lk()\color_B) / 2
moy_BC = (lk()\color_C + lk()\color_B) / 2
moy_CA = (lk()\color_A + lk()\color_C) / 2
color_AB = ls_GetColorPalette(255 - moy_AB, 125, 255, 255)
color_BC = ls_GetColorPalette(255 - moy_BC, 125, 255, 255)
color_CA = ls_GetColorPalette(255 - moy_CA, 125, 255, 255)
a_x.f = (lk()\a\x - x) * rapport1
a_y.f = (lk()\a\y - y) * rapport1
b_x.f = (lk()\b\x - x) * rapport1
b_y.f = (lk()\b\y - y) * rapport1
c_x.f = (lk()\c\x - x) * rapport1
c_y.f = (lk()\c\y - y) * rapport1
If mode >= 2
LineXY(a_x, a_y, b_x, b_y, color_AB)
LineXY(b_x, b_y, c_x, c_y, color_AB)
LineXY(c_x, c_y, a_x, a_y, color_AB)
FillArea((a_x + b_x + c_x) / 3, (a_y + b_y + c_y) / 3, color_AB, color_AB)
If mode = 3
; Else
Circle(a_x, a_y, 2, color_AB)
Circle(b_x, b_y, 2, color_AB)
Circle(c_x, c_y, 2, color_AB)
EndIf
Else
LineXY(a_x, a_y, b_x, b_y, color_AB)
LineXY(b_x, b_y, c_x, c_y, color_BC)
LineXY(c_x, c_y, a_x, a_y, color_CA)
EndIf
ElseIf mode = 1 And mode1 = -1
a_x.f = (lk()\a\x - x) * rapport1
a_y.f = (lk()\a\y - y) * rapport1
b_x.f = (lk()\b\x - x) * rapport1
b_y.f = (lk()\b\y - y) * rapport1
c_x.f = (lk()\c\x - x) * rapport1
c_y.f = (lk()\c\y - y) * rapport1
Line(a_x, a_y, 1, 1, ls_GetColorPalette(255 - lk()\color_A, 125, 255, 255))
Line(b_x, b_y, 1, 1, ls_GetColorPalette(255 - lk()\color_B, 125, 255, 255))
Line(c_x, c_y, 1, 1, ls_GetColorPalette(255 - lk()\color_C, 125, 255, 255))
ElseIf mode1 = 1
a_x.f = (lk()\a\x - x) * rapport1
a_y.f = (lk()\a\y - y) * rapport1
b_x.f = (lk()\b\x - x) * rapport1
b_y.f = (lk()\b\y - y) * rapport1
c_x.f = (lk()\c\x - x) * rapport1
c_y.f = (lk()\c\y - y) * rapport1
xa.d = (a_x + b_x + c_x) / 3
ya.d = (a_y + b_y + c_y) / 3
dd.d = screen\x
ForEach Bord()
d.d = Sqr(Pow(xa - Bord()\x, 2) + Pow(ya - Bord()\y, 2))
If dd > d : dd = d : EndIf
Next
If dd > milieumax : milieumax = dd : EndIf
color = ls_GetColorPalette(255*(1 - dd.d / milieu), 125, 255, 255)
; color = RGB(255*(1 - dd.d / milieu), 0, 0)
If mode >= 2
LineXY(a_x, a_y, b_x, b_y, color)
LineXY(b_x, b_y, c_x, c_y, color)
LineXY(c_x, c_y, a_x, a_y, color)
FillArea((a_x + b_x + c_x) / 3, (a_y + b_y + c_y) / 3, color, color)
If mode = 3
; Else
Circle(a_x, a_y, 2, color)
Circle(b_x, b_y, 2, color)
Circle(c_x, c_y, 2, color)
EndIf
ElseIf mode = 1
Line(a_x, a_y, 1, 1, color)
Line(b_x, b_y, 1, 1, color)
Line(c_x, c_y, 1, 1, color)
EndIf
EndIf
EndProcedure
List = 1
modif = -1
CreateSprite(0, screen\x / 20, screen\y / 20)
limit.POINT\x = (mini - 1) * screen\x / mini
limit\y = 0
limit_ex.point\x = screen\x
limit_ex.point\y = screen\y / mini
niveau = 0
;{ grille
Dim grille.POINT(7)
grille(0)\x = -1
grille(0)\y = 0
grille(1)\x = -1
grille(1)\y = 1
grille(2)\x = 0
grille(2)\y = 1
grille(3)\x = 1
grille(3)\y = 1
grille(4)\x = 1
grille(4)\y = 0
grille(5)\x = 1
grille(5)\y = -1
grille(6)\x = 0
grille(6)\y = -1
grille(7)\x = -1
grille(7)\y = -1
;}
Repeat
event = WaitWindowEvent()
ExamineKeyboard()
;{ Zoom
If event = #WM_LBUTTONDOWN
x.d = WindowMouseX(0)
y.d = WindowMouseY(0)
If x > limit\x And x < limit_ex\x And y > limit\y And y < limit_ex\y
GrabSprite(1, 0, 0, screen\x, screen\y)
Repeat
event = WaitWindowEvent()
If event = #PB_Event_CloseWindow : End : EndIf
x1.l = WindowMouseX(0)
y1.l = WindowMouseY(0)
If x1 > limit_ex\x : x1 = limit_ex\x : EndIf
If x1 < limit\x : x1 = limit\x : EndIf
If y1 > limit_ex\y : y1 = limit_ex\y : EndIf
If y1 < limit\y : y1 = limit\y : EndIf
SetCursorPos_(x1 + WindowX(0) + 3, y1 + WindowY(0) + 25)
DisplaySprite(1, 0, 0)
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Outlined)
Box(x, y, x1 - x, y1 - y, RGB(255, 255, 255))
DrawingMode(#PB_2DDrawing_Default)
StopDrawing()
FlipBuffers()
Until event = #WM_LBUTTONDOWN And x > limit\x And x < limit_ex\x And y > limit\y And y < limit_ex\y
x = (x - limit\x) * mini
y = (y - limit\y) * mini
x1 = (x1 - limit\x) * mini
y1 = (y1 - limit\y) * mini
rapport.f = screen\x / screen\y
If Abs((x - x1) / (y - y1)) >= rapport
dy = Abs(x - x1) / rapport
y = (y + y1) / 2 - dy / 2
y1 = y + dy
Else
dx = Abs(y - y1) * rapport
x = (x + x1) / 2 - dx / 2
x1 = x + dx
EndIf
rapport1.f = screen\x / (x1 - x)
ClearScreen(0)
If StartDrawing(ScreenOutput())
If List = 1
nb = ListSize(aze()) - 1
For a = 0 To nb
SelectElement(aze(), a)
StopDrawing()
FlipBuffers()
StartDrawing(ScreenOutput())
DrawTriangle(aze(), x, y, rapport1)
If nb <> 0 : Box(0, screen\y - 10, screen\x * a / nb, 10, RGB(255, 255, 255)) : EndIf
If WindowEvent() = #PB_Event_CloseWindow : End : EndIf
Next
Else
nb = ListSize(qsd()) - 1
For a = 0 To nb
SelectElement(qsd(), a)
StopDrawing()
FlipBuffers()
StartDrawing(ScreenOutput())
DrawTriangle(qsd(), x, y, rapport1)
Box(0, screen\y - 10, screen\x * a / nb, 10, RGB(255, 255, 255))
If WindowEvent() = #PB_Event_CloseWindow : End : EndIf
Next
EndIf
DrawText(0, 0, "Nombre de Triangle = " + Str(a) + " Temps de calcul = " + Str(timer) + " ms")
StopDrawing()
EndIf
DisplaySprite(0, (mini - 1) * screen\x / mini, 0)
FlipBuffers()
modif = 0
EndIf
EndIf
;}
If KeyboardReleased(#PB_Key_F1) : mode = 0 : modif = -1 : EndIf
If KeyboardReleased(#PB_Key_F2) : mode = 1 : modif = -1 : EndIf
If KeyboardReleased(#PB_Key_F3) : mode = 2 : modif = -1 : EndIf
If KeyboardReleased(#PB_Key_F4) : mode = 3 : modif = -1 : EndIf
If KeyboardReleased(#PB_Key_F6) : mode = 4 : modif = -1 : EndIf
If KeyboardReleased(#PB_Key_F5) : mode1 = -mode1 : modif = -1 : EndIf
;{ display bord
If KeyboardReleased(#PB_Key_X)
ForEach Bord()
event = WindowEvent()
If event = #PB_Event_CloseWindow : Break : EndIf
If StartDrawing(ScreenOutput())
Line(Bord()\x, Bord()\y, 1, 1, #Green)
StopDrawing()
EndIf
FlipBuffers()
Next
EndIf
;}
;{ test entoure
If KeyboardReleased(#PB_Key_C)
; NewList Bord.POINT()
ClearList(Bord())
LastElement(aze())
If List = 1
x.d = aze()\a\x
y.d = aze()\a\y
Else
x.d = qsd()\a\x
y.d = qsd()\a\y
EndIf
ddd.d = Sqr(Pow(aze()\a\x - aze()\b\x, 2) + Pow(aze()\a\y - aze()\b\y, 2))
x - 2 * (aze()\b\x - aze()\a\x) / ddd
y - 2 * (aze()\b\y - aze()\a\y) / ddd
depart = 0
tim = 0
Repeat
event = WindowEvent()
ExamineKeyboard()
Delay(5)
pb1 = 0
pb2 = 0
;{ test1
If StartDrawing(ScreenOutput())
If Point(x - 1, y) = 0; Or Point(x - 1, y) = #Green
x1.l = x - 1
y1.l = y
ElseIf Point(x - 1, y + 1) = 0; Or Point(x - 1, y + 1) = #Green
x1.l = x - 1
y1.l = y + 1
ElseIf Point(x, y + 1) = 0; Or Point(x, y + 1) = #Green
x1.l = x
y1.l = y + 1
ElseIf Point(x + 1, y + 1) = 0; Or Point(x + 1, y + 1) = #Green
x1.l = x + 1
y1.l = y + 1
ElseIf Point(x + 1, y) = 0; Or Point(x + 1, y) = #Green
x1.l = x + 1
y1.l = y
ElseIf Point(x + 1, y - 1) = 0; Or Point(x + 1, y - 1) = #Green
x1.l = x + 1
y1.l = y - 1
ElseIf Point(x, y - 1) = 0; Or Point(x, y - 1) = #Green
x1.l = x
y1.l = y - 1
ElseIf Point(x - 1, y - 1) = 0; Or Point(x - 1, y - 1) = #Green
x1.l = x - 1
y1.l = y - 1
Else
pb1 = 1
EndIf
AddElement(Bord())
Bord()\x = x1
Bord()\y = y1
If Point(x1 - 1, y1) And Point(x1 - 1, y1) <> #Green And Point(x1 - 1, y1) <> #Yellow; And x <> x1 - 1 And y <> y1
x = x1 - 1
y = y1
ElseIf Point(x1 - 1, y1 + 1) And Point(x1 - 1, y1 + 1) <> #Green And Point(x1 - 1, y1 + 1) <> #Yellow; And x <> x1 - 1 And y <> y1 + 1
x = x1 - 1
y = y1 + 1
ElseIf Point(x1, y1 + 1) And Point(x1, y1 + 1) <> #Green And Point(x1, y1 + 1) <> #Yellow; And x <> x1 And y <> y1 - 1
x = x1
y = y1 + 1
ElseIf Point(x1 + 1, y1 + 1) And Point(x1 + 1, y1 + 1) <> #Green And Point(x1 + 1, y1 + 1) <> #Yellow; And x <> x1 + 1 And y <> y1 + 1
x = x1 + 1
y = y1 + 1
ElseIf Point(x1 + 1, y1) And Point(x1 + 1, y1) <> #Green And Point(x1 + 1, y1) <> #Yellow; And x <> x1 + 1 And y <> y1
x = x1 + 1
y = y1
ElseIf Point(x1 + 1, y1 - 1) And Point(x1 + 1, y1 - 1) <> #Green And Point(x1 + 1, y1 - 1) <> #Yellow; And x <> x1 + 1 And y <> y1 - 1
x = x1 + 1
y = y1 - 1
ElseIf Point(x1, y1 - 1) And Point(x1, y1 - 1) <> #Green And Point(x1, y1 - 1) <> #Yellow; And x <> x1 And y <> y1 - 1
x = x1
y = y1 - 1
ElseIf Point(x1 - 1, y1 - 1) And Point(x1 - 1, y1 - 1) <> #Green And Point(x1 - 1, y1 - 1) <> #Yellow; And x <> x1 - 1 And y <> y1 - 1
x = x1 - 1
y = y1 - 1
Else
pb2 = 1
EndIf
Box(x1, y1, 1, 1, #Green)
Box(x, y, 1, 1, #Yellow)
StopDrawing()
EndIf
;}
;{ test2
; If StartDrawing(ScreenOutput())
;
; For g = 0 To 7
; If Point(x + grille(g)\x, y + grille(g)\y) = 0 Or Point(x + grille(g)\x, y + grille(g)\y) = #Green
;
; For g1 = 0 To 7
; If Point(x + grille(g)\x + grille(g1)\x, y + grille(g)\y + grille(g1)\y) And Point(x + grille(g)\x + grille(g1)\x, y + grille(g)\y + grille(g1)\y) <> #Green
;
; x1 = x + grille(g)\x
; y1 = y + grille(g)\y
;
; x = x1 + grille(g1)\x
; y = y1 + grille(g1)\y
;
; Break
;
; EndIf
; Next
;
; Break
; EndIf
; Next
;
; If x2 = x1 And y2 = y1
;
; x = x1
; y = y1
;
; For g = 0 To 7
; If Point(x + grille(g)\x, y + grille(g)\y) And Point(x + grille(g)\x, y + grille(g)\y) <> #Green
;
; For g1 = 0 To 7
; If Point(x + grille(g)\x + grille(g1)\x, y + grille(g)\y + grille(g1)\y) = 0 Or Point(x + grille(g)\x + grille(g1)\x, y + grille(g)\y + grille(g1)\y) = #Green
;
; x = x + grille(g)\x
; y = y + grille(g)\y
;
; x1 = x + grille(g1)\x
; y1 = y + grille(g1)\y
;
; Break
;
; EndIf
; Next
;
; Break
; EndIf
; Next
; EndIf
;
;
; AddElement(Bord())
;
; Bord()\x = x1
; Bord()\y = y1
;
; x2 = x1
; y2 = y1
;
; Box(x1, y1, 1, 1, #Green)
; StopDrawing()
; EndIf
;}
;{ test3
; If StartDrawing(ScreenOutput())
;
; c = depart
; d = 7
;
; go = 0
;
; x2 = 0
; y2 = 0
;
; For g = c To d
; If Point(x + grille(g)\x, y + grille(g)\y) = 0 Or Point(x + grille(g)\x, y + grille(g)\y) = #Green
; go = 1
;
; x2 = x1
; y2 = y1
;
; x1 = x + grille(g)\x
; y1 = y + grille(g)\y
;
; If Point(x1, y1) <> #Green
; AddElement(Bord())
;
; Bord()\x = x1
; Bord()\y = y1
;
; Box(x1, y, 1, 1, #Green)
; EndIf
;
; ElseIf go = 1
;
; dfx = x2 - x1
; dfy = y2 - y1
;
; If dfx = 1 And dfy = 0
; depart1 = 4
; ElseIf dfx = 1 And dfy = 1
; depart1 = 3
; ElseIf dfx = 0 And dfy = 1
; depart1 = 2
; ElseIf dfx = -1 And dfy = 1
; depart1 = 1
; ElseIf dfx = -1 And dfy = 0
; depart1 = 0
; ElseIf dfx = -1 And dfy = -1
; depart1 = 7
; ElseIf dfx = 0 And dfy = -1
; depart1 = 6
; ElseIf dfx = 1 And dfy = -1
; depart1 = 5
; EndIf
;
; c1 = depart1
; d1 = 7
;
; For g1 = c1 To d1
; If Point(x1 + grille(g1)\x, y1 + grille(g1)\y) <> 0 And Point(x1 + grille(g1)\x, y1 + grille(g1)\y) <> #Green
; x = x1 + grille(g1)\x
; y = y1 + grille(g1)\y
;
; depart = g1 + 1
;
; If depart > 7 : depart = 0 : EndIf
;
; Break
; EndIf
;
; If g1 = 7 And depart1 > 0
; g1 = 0
;
; c1 = 0
; d1 = depart1 - 1
; EndIf
;
; Next
;
; Break
; EndIf
;
; If g = 7 And depart > 0
; g = 0
;
; c = 0
; d = depart - 1
; EndIf
; Next
;
;
;
;
; StopDrawing()
; EndIf
;}
FlipBuffers()
If pb1 = 1 And pb2 = 1
tim + 1
x = Bord()\x
y = Bord()\y
Else
tim = 0
EndIf
Until event = #PB_Event_CloseWindow Or KeyboardReleased(#PB_Key_Escape) Or (pb1 = 1 And pb2 = 1 And tim = 4)
EndIf
;}
;{ Enregistrement
If KeyboardPushed(#PB_Key_S)
If OpenWindow(1, 0, 0, 400, 20, "Sauvegarder", #PB_Window_ScreenCentered)
If List = 2 : nb = ListSize(qsd()) - 1 : EndIf
If List = 1 : nb = ListSize(aze()) - 1 : EndIf
ProgressBarGadget(0, 0, 0, 400, 20, 0, nb)
file$ = SaveFileRequester("Sauver la courbe", "", "Fractale (.frtl)", 0)
If file$
If CreateFile(0, file$)
FileBuffersSize(0, 0)
WriteStringN(0, Str(niveau))
WriteStringN(0, Str(tot))
WriteStringN(0, Str(List))
WriteStringN(0, Str(nb))
For a = 0 To nb
WindowEvent()
SetGadgetState(0, a)
If event = #PB_Event_CloseWindow : CloseFile(0) : DeleteFile(file$) : End : EndIf
If List = 2 : SelectElement(qsd(), a) : *az.Triangle = qsd() : EndIf
If List = 1 : SelectElement(aze(), a) : *az.Triangle = aze() : EndIf
string.s = StrD(*az\a\x)
WriteStringN(0, String)
string = StrD(*az\a\y)
WriteStringN(0, String)
string = StrD(*az\b\x)
WriteStringN(0, String)
string = StrD(*az\b\y)
WriteStringN(0, String)
string = StrD(*az\c\x)
WriteStringN(0, String)
string = StrD(*az\c\y)
WriteStringN(0, String)
string = Str(*az\color_a)
WriteStringN(0, String)
string = Str(*az\color_b)
WriteStringN(0, String)
string = Str(*az\color_c)
WriteStringN(0, String)
Next
CloseFile(0)
Else
MessageRequester("Attention", "Impossible de créer le fichier")
EndIf
EndIf
CloseWindow(1)
EndIf
EndIf
;}
;{ chargement
If KeyboardPushed(#PB_Key_O)
If OpenWindow(1, 0, 0, 400, 20, "Charger", #PB_Window_ScreenCentered)
file$ = OpenFileRequester("Charger la courbe", "", "Fractale (.frtl)", 0)
If file$
If ReadFile(0, file$)
niveau = Val(ReadString(0))
tot = Val(ReadString(0))
List = Val(ReadString(0))
nb = Val(ReadString(0))
Debug "niveau=" + Str(niveau)
Debug "tot=" + Str(tot)
Debug "list=" + Str(List)
Debug "nb=" + Str(nb)
ProgressBarGadget(0, 0, 0, 400, 20, 0, nb)
ClearList(aze())
ClearList(qsd())
For a = 0 To nb
WindowEvent()
SetGadgetState(0, a)
If event = #PB_Event_CloseWindow : CloseFile(0) : End : EndIf
If List = 2 : qsd()
AddElement(qsd())
qsd()\a\x = ValD(ReadString(0))
qsd()\a\y = ValD(ReadString(0))
qsd()\b\x = ValD(ReadString(0))
qsd()\b\y = ValD(ReadString(0))
qsd()\c\x = ValD(ReadString(0))
qsd()\c\y = ValD(ReadString(0))
qsd()\color_a = Val(ReadString(0))
qsd()\color_b = Val(ReadString(0))
qsd()\color_c = Val(ReadString(0))
ElseIf List = 1
AddElement(aze())
aze()\a\x = ValD(ReadString(0))
aze()\a\y = ValD(ReadString(0))
aze()\b\x = ValD(ReadString(0))
aze()\b\y = ValD(ReadString(0))
aze()\c\x = ValD(ReadString(0))
aze()\c\y = ValD(ReadString(0))
aze()\color_a = Val(ReadString(0))
aze()\color_b = Val(ReadString(0))
aze()\color_c = Val(ReadString(0))
EndIf
Next
CloseFile(0)
modif = -1
Else
MessageRequester("Attention", "Impossible de lire le fichier")
EndIf
EndIf
CloseWindow(1)
EndIf
EndIf
;}
; If KeyboardReleased(#PB_Key_Right) : modif = 1 : EndIf
If KeyboardPushed(#PB_Key_Right) : modif = 1 : EndIf
;{ calculs de l'itération suivante
If List = 1 And modif = 1
ClearScreen(0)
ClearList(qsd())
; mode = 0
timer = ElapsedMilliseconds()
niveau = 1
nb = ListSize(aze()) - 1
For a = 0 To nb
SelectElement(aze(), a)
AddElement(qsd())
qsd()\a\x = aze()\b\x
qsd()\a\y = aze()\b\y
qsd()\color_A = aze()\color_B
qsd()\b\x = aze()\c\x
qsd()\b\y = aze()\c\y
qsd()\color_B = aze()\color_C
qsd()\c\x = (aze()\a\x + aze()\b\x) / 2
qsd()\c\y = (aze()\a\y + aze()\b\y) / 2
qsd()\color_C = 255 * niveau / tot
c_x.d = qsd()\c\x
c_y.d = qsd()\c\y
AddElement(qsd())
qsd()\a\x = aze()\a\x
qsd()\a\y = aze()\a\y
qsd()\color_A = aze()\color_A
qsd()\b\x = aze()\c\x
qsd()\b\y = aze()\c\y
qsd()\color_B = aze()\color_C
qsd()\c\x = c_x + aze()\c\x - aze()\b\x
qsd()\c\y = c_y + aze()\c\y - aze()\b\y
qsd()\color_C = 255 * niveau / tot
; If StartDrawing(ScreenOutput())
; Box(0, screen\y - 10, (a + 1) * screen\x / (nb + 1), 10, RGB(255, 255, 255))
;
; PreviousElement(qsd())
;
; If nb <> 0
; DrawTriangle(qsd(), 0, 0, screen\x / screen\y, (255 * a) / nb)
; Else
; DrawTriangle(qsd(), 0, 0, screen\x / screen\y)
; EndIf
;
; NextElement(qsd())
;
; DrawTriangle_qsd(0, 0, screen\x / screen\y)
; StopDrawing()
; EndIf
; FlipBuffers()
If WindowEvent() = #PB_Event_CloseWindow : End : EndIf
Next
timer = ElapsedMilliseconds() - timer
List = 2
StartDrawing(ScreenOutput())
DrawText(0, 0, "Nombre de Triangle = " + Str(ListSize(qsd())) + " Temps de calcul = " + Str(timer) + " ms")
StopDrawing()
; GrabSprite(0, 0, 0, screen\x, screen\y)
ElseIf modif = 1 And List = 2
ClearScreen(0)
ClearList(aze())
; mode = 0
timer = ElapsedMilliseconds()
niveau + 1
nb = ListSize(qsd()) - 1
For a = 0 To nb
SelectElement(qsd(), a)
AddElement(aze())
aze()\a\x = qsd()\b\x
aze()\a\y = qsd()\b\y
aze()\color_A = qsd()\color_B
aze()\b\x = qsd()\c\x
aze()\b\y = qsd()\c\y
aze()\color_B = qsd()\color_C
aze()\c\x = (qsd()\a\x + qsd()\b\x) / 2
aze()\c\y = (qsd()\a\y + qsd()\b\y) / 2
aze()\color_C = 255 * niveau / tot
c_x.d = aze()\c\x
c_y.d = aze()\c\y
AddElement(aze())
aze()\a\x = qsd()\a\x
aze()\a\y = qsd()\a\y
aze()\color_A = qsd()\color_A
aze()\b\x = qsd()\c\x
aze()\b\y = qsd()\c\y
aze()\color_B = qsd()\color_C
aze()\c\x = c_x + qsd()\c\x - qsd()\b\x
aze()\c\y = c_y + qsd()\c\y - qsd()\b\y
aze()\color_C = 255 * niveau / tot
; If StartDrawing(ScreenOutput())
; Box(0, screen\y - 10, (a + 1) * screen\x / (nb + 1), 10, RGB(255, 255, 255))
;
; PreviousElement(aze())
;
; If nb <> 0
; DrawTriangle(aze(), 0, 0, screen\x / screen\y, (255 * a) / nb)
; Else
; DrawTriangle(aze(), 0, 0, screen\x / screen\y)
; EndIf
;
; NextElement(aze())
;
; DrawTriangle_aze(0, 0, screen\x / screen\y)
; StopDrawing()
; EndIf
; FlipBuffers()
If WindowEvent() = #PB_Event_CloseWindow : End : EndIf
Next
timer = ElapsedMilliseconds() - timer
StartDrawing(ScreenOutput())
DrawText(0, 0, "Nombre de Triangle = " + Str(ListSize(aze())) + " Temps de calcul = " + Str(timer) + " ms")
StopDrawing()
List = 1
; GrabSprite(0, 0, 0, screen\x, screen\y)
EndIf
;}
;{ dessin
If modif = -1
ClearScreen(0)
If StartDrawing(ScreenOutput())
If List = 1
nb = ListSize(aze()) - 1
For a = 0 To nb
SelectElement(aze(), a)
StopDrawing()
FlipBuffers()
StartDrawing(ScreenOutput())
If nb <> 0
DrawTriangle(aze(), 0, 0, screen\x / screen\y, (255 * a) / nb)
Else
DrawTriangle(aze(), 0, 0, screen\x / screen\y)
EndIf
If WindowEvent() = #PB_Event_CloseWindow : End : EndIf
Next
Else
nb = ListSize(qsd()) - 1
For a = 0 To nb
SelectElement(qsd(), a)
StopDrawing()
FlipBuffers()
StartDrawing(ScreenOutput())
If nb <> 0
DrawTriangle(qsd(), 0, 0, screen\x / screen\y, (255 * a) / nb)
Else
DrawTriangle(qsd(), 0, 0, screen\x / screen\y)
EndIf
If WindowEvent() = #PB_Event_CloseWindow : End : EndIf
Next
EndIf
DrawText(0, 0, "Nombre de Triangle = " + Str(a) + " Temps de calcul = " + Str(timer) + " ms")
StopDrawing()
EndIf
; DisplaySprite(0, (mini - 1) * screen\x / mini, 0)
FlipBuffers()
milieu = milieumax
modif = 0
EndIf
;}
If modif = 1
; CreateImage(0, screen\x, screen\y)
; CopySpriteToImage(0, 0)
;
; ResizeImage(0, screen\x / mini, screen\y / mini)
;
; CreateSprite(0, screen\x / mini, screen\y / mini)
; If StartDrawing(SpriteOutput(0))
; DrawImage(ImageID(0), 0, 0)
; StopDrawing()
; EndIf
; DisplaySprite(0, (mini - 1) * screen\x / mini, 0)
FlipBuffers()
modif = 0
EndIf
Until event = #PB_Event_CloseWindow
End