BlendLine-Func

BlitzPlus Forums/BlitzPlus Programming/BlendLine-Func

Oh, it depended on setting color with Color command.. and had OnBuffer instead of RGB parametre.. so now it works:

Function BlendLine(X1,Y1,X2,Y2,Color24)
 X# = X1
 Y# = Y1
  Angle# = ATan2#(Y2-Y1,X2-X1)
; DebugLog "Angle: " + Angle#
; DebugLog "Cos/Ang: " + Cos#(Angle#)
; DebugLog "Sin/Ang: " + Sin#(Angle#)
  LockBuffer()
 While Int(X#) <> X2 Or Int(Y#) <> Y2
  X# = X# + Cos#(Angle#)
  Y# = Y# + Sin#(Angle#)
   Pixel = ReadPixelFast(Int(X#),Int(Y#))
  NewR = (GetR(Pixel) + GetR(Color24)) Shr 1
  NewG = (GetG(Pixel) + GetG(Color24)) Shr 1
  NewB = (GetB(Pixel) + GetB(Color24)) Shr 1
   If NewR > 255 Then NewR = 255
   If NewG > 255 Then NewG = 255
   If NewB > 255 Then NewB = 255
  WritePixelFast Int(X#), Int(Y#), GetRGB(NewR,NewG,NewB)
;   DebugLog "X was " + Int(X#) + " , Y was " + Int(Y#)
 Wend
  UnlockBuffer()
End Function

Function GetRGB(R,G,B)
 Return $FF000000 Or R Shl 16 Or G Shl 8 Or B
End Function

Function GetR(RGB)
 Return RGB Shr 16 And %11111111
End Function

Function GetG(RGB)
 Return RGB Shr 8 And %11111111
End Function

Function GetB(RGB)
 Return RGB And %11111111
End Function