
Code : Tout sélectionner
Declare DoLine(XStart,YStart,xend,YEnd,CoulR,CoulG,CoulB)
InitSprite()
InitKeyboard()
OpenScreen(640, 480, 32, "DoLine")
;- Boucle
rayon=200
Repeat
ClearScreen(0, 0, 0)
For i.w = 0 To 359
DoLine(320,240, 320 + rayon * Cos(i * 0.0174533), 240 + rayon * Sin(i* 0.0174533),Random(255),Random(255),Random(255))
Next i
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
Procedure DoLine(xi,yi,xf,yf,CoulR,CoulG,CoulB)
StartDrawing(ScreenOutput())
FrontColor(CoulR,CoulG,CoulB)
x = xi
y = yi
dx = xf - xi
dy = yf - yi
If dx > 0
xinc = 1
Else
xinc = -1
EndIf
If dy > 0
yinc = 1
Else
yinc = -1
EndIf
dx = Abs(dx)
dy = Abs(dy)
Plot(x,y)
If dx > dy
cumul = dx / 2
For i = 1 To dx
x + xinc
cumul + dy
If (cumul >= dx)
cumul - dx
y + yinc
EndIf
Plot(x,y)
Next
Else
cumul = dy / 2
For i = 1 To dy
y + yinc
cumul + dx
If cumul >= dy
cumul - dy
x + xinc
EndIf
Plot(x,y)
Next
EndIf
StopDrawing()
EndProcedure