You can even make it work transparently with
rgba, too:
Code: Select all
union colortype
bgra as uinteger<32>
type
b as ubyte
g as ubyte
r as ubyte
a as ubyte
end type
declare constructor(byval bgra as uinteger<32>=rgba(255,255,255,255))
declare constructor( as ubyte, as ubyte, as ubyte, as ubyte )
declare operator let( as uinteger <32> )
declare operator cast() as uinteger <32>
end union
constructor colortype(byval bgra as uinteger<32>)
this.bgra=bgra
end constructor
constructor colortype( r as ubyte, g as ubyte, b as ubyte, a as ubyte )
bgra = rgba( r, g, b, a )
end constructor
operator colortype.let( value as uinteger <32> )
bgra = value
end operator
operator colortype.cast() as uinteger <32>
return( bgra )
end operator
type mytype
clr as colortype=rgba(1,2,3,4)
end type
var myColor = colortype( 255, 128, 64, 255 )
screenRes( 800, 600, 32 )
line( 100, 100 ) - ( 500, 500 ), myColor, bf
? myColor.r, myColor.g, myColor.b, myColor.a
sleep()