1 /** Colors. 2 * 3 * See_Also: https://github.com/TurkeyMan/color 4 */ 5 module nxt.color; 6 7 @safe pure nothrow @nogc: 8 9 /** RGB 24-bit color, where each color component has 8-bit precision. 10 * 11 * See_Also: Implements the $(LINK2 https://en.wikipedia.org/wiki/RGB_color_space, RGB) _color type. 12 */ 13 struct ColorRGB8 14 { 15 this(ubyte redC, ubyte greenC, ubyte blueC) 16 { 17 this.redC = redC; 18 this.greenC = greenC; 19 this.blueC = blueC; 20 } 21 22 ubyte redC; ///< Red component. 23 ubyte greenC; ///< Green component. 24 ubyte blueC; ///< Blue component. 25 26 static immutable black = typeof(this)(0x00, 0x00, 0x00); ///< Black. 27 static immutable white = typeof(this)(0xff, 0xff, 0xff); ///< White. 28 static immutable red = typeof(this)(0xff, 0x00, 0x00); ///< Red. 29 static immutable green = typeof(this)(0x00, 0xff, 0x00); ///< Green. 30 static immutable blue = typeof(this)(0x00, 0x00, 0xff); ///< Blue. 31 static immutable cyan = typeof(this)(0x00, 0xff, 0xff); ///< Cyan. 32 static immutable magenta = typeof(this)(0xff, 0x00, 0xff); ///< Magenta. 33 static immutable yellow = typeof(this)(0xff, 0xff, 0x00); ///< Yellow. 34 } 35 36 /** Default color format. 37 */ 38 alias Color = ColorRGB8; 39 40 /** BGR 24-bit color, where each color component has 8-bit precision. 41 */ 42 struct ColorBGR8 43 { 44 this(ubyte redC, ubyte greenC, ubyte blueC) 45 { 46 this.redC = redC; 47 this.greenC = greenC; 48 this.blueC = blueC; 49 } 50 51 ubyte blueC; ///< Blue component. 52 ubyte greenC; ///< Green component. 53 ubyte redC; ///< Red component. 54 }