```' ****** START INCLUDE Rgba Core:::RgbaBox(x1%, y1%, x2%, y2%, c&, a%b) ******
DIM r0%, g0%, b0%, a0%, r1%, g1%, b1%, a1%

SUB SetRgb0(x%,y%)
DIM c\$
c\$ = RIGHT\$("000000" + HEX\$(POINT(x%,y%)), 6)
r0% = VAL("0x" + LEFT\$(c\$,2))
g0% = VAL("0x" + MID\$(c\$,3,2))
b0% = VAL("0x" + RIGHT\$(c\$,2))
END SUB

SUB SetRgb1(c&,a%b)
DIM c\$
c\$ = RIGHT\$("000000" + HEX\$(c&), 6)
r1% = VAL("0x" + LEFT\$(c\$,2))
g1% = VAL("0x" + MID\$(c\$,3,2))
b1% = VAL("0x" + RIGHT\$(c\$,2))
a0% = 255 - a%b
a1% = a%b
END SUB

SUB RgbaCorePset(x%,y%)
PSET(x%,y%), _RGB( [{ (r0%*a0%)+(r1%*a1%) }/255], [{ (g0%*a0%)+(g1%*a1%) }/255], [{ (b0%*a0%)+(b1%*a1%) }/255] )
END SUB

Sub RgbaBox (x1%, y1%, x2%, y2%, c&, a%b)
xd% = ABS(x2% - x1%)
yd% = ABS(y2% - y1%)
SetRgb1(c&, a%b)
IF xd% = 0 THEN
FOR i = MIN(y1%,y2%) to MAX(y1%,y2%): SetRgb0(x1%,i) : RgbaCorePset(x1%,i) : NEXT i
ELSEIF yd% = 0 THEN
FOR i = MIN(y1%,y2%) to MAX(y1%,y2%): SetRgb0(x1%,i) : RgbaCorePset(x1%,i) : NEXT i
ELSE
FOR x% = MIN(x1%,x2%) to MAX(x1%,x2%)
FOR y%  = MIN(y1%,y2%) to MAX(y1%,y2%)
SetRgb0(x%,y%) : RgbaCorePset(x%,y%)
NEXT y%
NEXT x%
END IF
End Sub
'  ****** END INCLUDE Rgba Core:::RgbaBox(x1%, y1%, x2%, y2%, c&, a%b) ******

' BASIC Anywhere Machine program by Charlie Veniot to test RbgaBox library function in development version of BAM
' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.29.21.34]) on 2023.09.09 at 15:35 (Coordinated Universal Time)

SCREEN _NEWIMAGE(400,400, 27)

â–¶StartIteration:
x% = INT(RND*180) + 20
y% = INT(RND*180) + 20
FOR i = 0 to INT(RND*15) + 6
colour& = INT(RND * &hFFFFFF) + 1
alpha% = INT( RND * 100 )
RgbaBox(x% - i,y% - i,x% + i,y% + i, colour&, alpha%)
RgbaBox(400 - x% - i,y% - i,400 - x% + i,y% + i, colour&, alpha%)
RgbaBox(x% - i,400 - y% - i,x% + i,400 - y% + i, colour&, alpha%)
RgbaBox(400 - x% - i,400 - y% - i,400 - x% + i,400 - y% + i, colour&, alpha%)
_DELAY 0.1
NEXT i
GOTO â–¶StartIteration

```