1 /* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, version 3 of the License ONLY.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 module iv
.gxx
.color
/*is aliced*/;
25 // ////////////////////////////////////////////////////////////////////////// //
26 // swaps 'R' and 'B' color components
27 public uint gxColor (in Color c
) pure nothrow @safe @nogc {
30 ((c
.asUint
&0xff)<<16)|
31 (c
.asUint
&0xff_00ff00)|
32 ((c
.asUint
>>16)&0xff);
36 public Color
gxToColor (uint clr
) pure nothrow @safe @nogc {
38 return Color((clr
>>16)&0xff, (clr
>>8)&0xff, clr
&0xff, (clr
>>24)&0xff);
42 // just swap 'R' and 'B' color components
43 public uint gxSwapRB (uint c
) pure nothrow @safe @nogc {
52 // ////////////////////////////////////////////////////////////////////////// //
53 public bool gxIsTransparent (uint clr
) pure nothrow @safe @nogc { pragma(inline
, true); return ((clr
&0xff000000) == 0xff000000); }
54 public bool gxIsSolid (uint clr
) pure nothrow @safe @nogc { pragma(inline
, true); return ((clr
&0xff000000) == 0x00_000000); }
56 public enum gxTransparent
= 0xff000000;
59 // ////////////////////////////////////////////////////////////////////////// //
60 private template isGoodRGBInt(T
) {
61 import std
.traits
: Unqual
;
65 is(TT
== short) ||
is(TT
== ushort) ||
66 is(TT
== int) ||
is(TT
== uint) ||
67 is(TT
== long) ||
is(TT
== ulong);
71 // ////////////////////////////////////////////////////////////////////////// //
72 public uint gxrgb(T0
, T1
, T2
) (T0 r
, T1 g
, T2 b
) pure nothrow @trusted @nogc if (isGoodRGBInt
!T0
&& isGoodRGBInt
!T1
&& isGoodRGBInt
!T2
) {
74 return (clampToByte(r
)<<16)|
(clampToByte(g
)<<8)|
clampToByte(b
);
78 public template gxRGB(int r
, int g
, int b
) {
79 enum gxRGB
= (clampToByte(r
)<<16)|
(clampToByte(g
)<<8)|
clampToByte(b
);
82 public template gxRGBA(int r
, int g
, int b
, int a
) {
83 enum gxRGBA
= (clampToByte(a
)<<24)|
(clampToByte(r
)<<16)|
(clampToByte(g
)<<8)|
clampToByte(b
);