Here is the border colour automated for a black background.
I have a function for any colour background, but it is sometimes one byte off either the red,green,blue or alpha.
So I am still working on that.
NOTE the 32 bit and 64 bit are different and are separated by the criterion size of integer.( I keep forgetting #if 32 bits or #if 64 bits macros, and they are hard to find and remember)
Press space to refresh, esc to end.
Code: Select all
Screen 19,32,,64
Function BorderColour(c As Ulong) As Ulong
Dim As Ubyte alf=Cast(Ubyte Ptr,@c)[3]
Dim As Long rd=((Cast(Ubyte Ptr,@c)[2])*alf)
Dim As Long gr=((Cast(Ubyte Ptr,@c)[1])*alf)
Dim As Long bl=((Cast(Ubyte Ptr,@c)[0])*alf)
If Sizeof(Integer)=4 Then '32 bits
Dim As Uinteger b
Screencontrol 13,,b
Dim As Ubyte newalf=(((Cast(Ubyte Ptr,@c)[3])*alf)+(Cast(Ubyte Ptr,@b)[3]*(255-alf))) Shr 8 +1
Return Rgba((rd Shr 8 ),(gr Shr 8 ),(bl Shr 8 ),newalf)
Else '64 bits
Return Rgba((rd Shr 8 ),(gr Shr 8 ),(bl Shr 8 ),alf)
End If
End Function
#define range(f,l) Int(Rnd*(((l)+1)-(f))+(f))
Dim As Long x1,y1,x2,y2
Dim As Ubyte rd,gr,bl,alf
Do
x1=range(20,300)
y1=range(30,200)
x2=range(500,799)
y2=range(400,599)
rd=Rnd*255
gr=Rnd*255
bl=Rnd*255
alf=50+Rnd*200
Dim As Ulong box=Rgba(rd,gr,bl,alf)
Cls
Line(x1,y1)-(x2,y2),box,b
Dim As Ulong p=(Point(x1+2,y1)) 'for comparison
Dim As Ulong b= BorderColour(box)
Draw String(360,300),"HELLO"
Paint(x1+5,y1+5),box,b 'just inside the box
Print "rgba(";rd;",";gr;",";bl;",";alf;")","box colour"
Print "rgba("; Cast(Ubyte Ptr,@p)[2];",";Cast(Ubyte Ptr,@p)[1];",";Cast(Ubyte Ptr,@p)[0];",";Cast(Ubyte Ptr,@p)[3];")","from point"
Print "rgba("; Cast(Ubyte Ptr,@b)[2];",";Cast(Ubyte Ptr,@b)[1];",";Cast(Ubyte Ptr,@b)[0];",";Cast(Ubyte Ptr,@b)[3];")","from function"
Sleep
Loop Until Multikey(1)
Sleep