(08-22-2023, 06:16 PM)CharlieJV Wrote: Implementing _RGBA in BAM would be, I think, I real nightmare.
Instead, I'm thinking better to set an include library with this "RgbaPset" function. Question is: am I right in thinking this yields the same as what _RGBA would do color-wise ?
Code: (Select All)SUB RgbaPset(x,y,r,g,b,a)
c = POINT(x,y)
c$ = RIGHT$("000000" + HEX$(c), 6)
cr = VAL("0x" + LEFT$(c$,2)) * 256 ^ 2
cg = VAL("0x" + MID$(c$,3,2)) * 256 ^ 1
cb = VAL("0x" + RIGHT$(c$,2))
PSET(x,y), { [cr * (255-a)/255 + r * a / 255] _
+ [cg * (255-a)/255 + g * a / 255] _
+ [cb * (255-a)/255 + b * a / 255] }
END SUB
screen 27
line (0,0) - (400,400), &h0000ff ,BF
FOR this_x = 50 to 150
FOR this_y = 50 to 150
RgbaPset(this_x,this_y,0,0,0,100)
next this_y
next this_x
Yeah I think I translated your code to QB64 and compared your method, Charlie, with normal way of drawing an Alpha rectangle in QB64.
No blinking between 2 methods demos that it works. I tried a few colors too.
Code: (Select All)
Screen _NewImage(800, 600, 32)
Do
Cls
Line (0, 0)-(400, 400), &HFF0000FF, BF
For this_x = 50 To 150
For this_y = 50 To 150
RgbaPset this_x, this_y, 255, 255, 0, 100
Next this_y
Next this_x
_Delay 1
_Display
Cls
Line (0, 0)-(400, 400), &HFF0000FF, BF
Line (50, 50)-(150, 150), _RGB32(255, 255, 0, 100), BF
_Delay 1
_Display
Loop Until _KeyDown(27)
Sub RgbaPset (x, y, r, g, b, a)
Dim c As _Unsigned Long
c = Point(x, y)
cr = _Red32(c)
cg = _Green32(c)
cb = _Blue32(c)
PSet (x, y), _RGB32(cr * (255 - a) / 255 + r * a / 255, cg * (255 - a) / 255 + g * a / 255, cb * (255 - a) / 255 + b * a / 255)
End Sub
Nice one, assuming I did it correctly.
b = b + ...