le tracage marche bien, mais je n'arrive pas à faire un "dégradé" de couleur... pourtant cela n'a pas l'air compliqué

je part de la couleur A pour aller jusqu'a la couleur B
en tenant compte de la distance entre les 2 points...
j'ai besoin d'un regard neuf :p
merki
Code : Tout sélectionner
Global SCREEN_W=640
Global SCREEN_H=480
Procedure.l Signe(a.l)
If a>0
ProcedureReturn 1
ElseIf a=0
ProcedureReturn 0
Else
ProcedureReturn -1
EndIf
EndProcedure
Procedure.l Max(a.l, b.l)
If a>b
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
Procedure Distance(x1,y1,z1,x2,y2,z2)
Protected Result.f
Result = Sqr( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2) )
ProcedureReturn Result
EndProcedure
Procedure DrawLinePtr3D(x1.l, y1.l, z1.l, x2.l, y2.l, z2.l,CouleurStart.l,CouleurEnd.l,Dist=15)
Protected xd.l, yd.l, zd.l
Protected x.l, y.l, z.l
Protected ax.l, ay.l, az.l
Protected sx.l, sy.l, sz.l
Protected dx.l, dy.l, dz.l
Protected Couleur.l,Pas.l,Distance.l
Couleur = CouleurStart
Distance = Distance(x1,y1,z1,x2,y2,z2)
Pas = (CouleurEnd-CouleurStart)/Distance
If x1<>0 And y1<>0 And x2<>0 And y2<>0
dx = x2 - x1
dy = y2 - y1
dz = z2 - z1
ax = Abs(dx) *2
ay = Abs(dy) *2
az = Abs(dz) *2 ;ou az = Abs(dz) : az = az << 1
sx = Signe(dx)
sy = Signe(dy)
sz = Signe(dz)
x = x1
y = y1
z = z1
If (ax >= Max(ay, az)) ; x dominant
yd = ay - (ax >> 1)
zd = az - (ax >> 1)
Repeat
Couleur+Pas
If x>0 And x<SCREEN_W-1 And y>0 And y<SCREEN_H-1 And z>Dist
;PokeL(*DrawingBuffer + (x*PixFrt) + SCREEN_W * (y*PixFrt),Couleur)
Plot(x,y,Couleur)
EndIf
If (x = x2)
ProcedureReturn;
EndIf
If (yd >= 0)
y + sy ; y +1 Or 0 Or -1
yd - ax;
EndIf
If (zd >= 0)
z + sz; ; z +1 or 0 or -1
zd - ax;
EndIf
x + sx ; x +1 Or 0 Or -1
yd + ay;
zd + az;
Until 0
ElseIf (ay >= Max(ax, az)) ; y dominant */
xd = ax - (ay >> 1)
zd = az - (ay >> 1)
Repeat
Couleur+Pas
If x>0 And x<SCREEN_W-1 And y>0 And y<SCREEN_H-1 And z>Dist
;PokeL(*DrawingBuffer + (x*PixFrt) + SCREEN_W * (y*PixFrt),Couleur)
Plot(x,y,Couleur)
EndIf
If (y = y2)
ProcedureReturn;
EndIf
If (xd >= 0)
x + sx ;x +1 Or 0 Or -1
xd - ay
EndIf
If (zd >= 0)
z + sz ;z +1 Or 0 Or -1
zd - ay
EndIf
y + sy ;y +1 Or 0 Or -1
xd + ax
zd + az
Until 0
ElseIf (az >= Max(ax, ay)) ; z dominant */
xd = ax - (az >> 1)
yd = ay - (az >> 1)
Repeat
Couleur+Pas
If x>0 And x<SCREEN_W-1 And y>0 And y<SCREEN_H-1 And z>Dist
; PokeL(*DrawingBuffer + (x*PixFrt) + SCREEN_W * (y*PixFrt),Couleur)
Plot(x,y,Couleur)
EndIf
If (z = z2)
ProcedureReturn;
EndIf
If (xd >= 0)
x + sx ;/x +1 or 0 or -1
xd - az
EndIf
If (yd >= 0)
y + sy ;y +1 Or 0 Or -1
yd - az
EndIf
z + sz ;z +1 Or 0 Or -1
xd + ax
yd + ay
Until 0
EndIf
EndIf
EndProcedure
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 Or InitSound() = 0
End
EndIf
OpenScreen(640,480,32,"")
Repeat
ExamineKeyboard() : ExamineMouse()
ClearScreen(0)
StartDrawing(ScreenOutput())
DrawLinePtr3D(100,100,100,250,100,100,RGB(255,255,255),RGB(255,0,0))
StopDrawing()
FlipBuffers(2)
Until KeyboardPushed(#PB_Key_Escape)