Es geht auch ohne Floats:
Code: Alles auswählen
Define c1.l, c2.l, x.l, y.l, w.l, h.l
c1 = $123456
c2 = $789ABC
x = 0
y = 0
w = 254
h = 500
Define Img.l, max.l
Img = CreateImage(#PB_Any, w, h)
If Img
StartDrawing(ImageOutput(Img))
max = h - 1
For i = 0 To max
r = (Red(c1) * i / max) + Red(c2) * (max - i) / max
g = (Green(c1) * i / max) + Green(c2) * (max - i) / max
b = (Blue(c1) * i / max) + Blue(c2) * (max - i) / max
Line(0, i, w, 0, RGB(r, g, b))
Next
StopDrawing()
EndIf
SetClipboardImage(Img)
If OpenWindow(0, 0, 0, w, h, "Test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
If CreateGadgetList(WindowID(0))
ImageGadget(0, 0, 0, w, h, ImageID(Img))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndIf
Man muss nur daran denken, dass man zuerst Multipliziert und
anschließend Dividiert.