1 /** 2 * Copyright: Mike Wey 2011 3 * License: zlib (See accompanying LICENSE file) 4 * Authors: Mike Wey 5 */ 6 7 module dmagick.ColorRGB; 8 9 import dmagick.Color; 10 11 import dmagick.c.magickType; 12 import dmagick.c.quantum; 13 14 /** 15 * An RGB(A) Color. 16 */ 17 class ColorRGB : Color 18 { 19 /** */ 20 this() 21 { 22 super(); 23 } 24 25 /** 26 * Create a Color from the specified Bytes. 27 */ 28 this(ubyte red, ubyte green, ubyte blue, ubyte opacity = 0) 29 { 30 super(ScaleCharToQuantum(red), 31 ScaleCharToQuantum(green), 32 ScaleCharToQuantum(blue), 33 ScaleCharToQuantum(opacity)); 34 } 35 36 /** 37 * Create a Color from the specified doubles. 38 * The values should be between 0.0 and 1.0. 39 */ 40 this(double red, double green, double blue, double opacity = 0) 41 { 42 super(scaleDoubleToQuantum(red), 43 scaleDoubleToQuantum(green), 44 scaleDoubleToQuantum(blue), 45 scaleDoubleToQuantum(opacity)); 46 } 47 48 /** 49 * Create a Color from a X11 color specification string 50 */ 51 this(string color) 52 { 53 super(color); 54 } 55 56 /** 57 * The value for red as a byte 58 */ 59 void redByte(ubyte red) 60 { 61 packet.red = ScaleCharToQuantum(red); 62 } 63 ///ditto 64 ubyte redByte() 65 { 66 return ScaleQuantumToChar(packet.red); 67 } 68 69 /** 70 * The value for green as a byte 71 */ 72 void greenByte(ubyte green) 73 { 74 packet.green = ScaleCharToQuantum(green); 75 } 76 ///ditto 77 ubyte greenByte() 78 { 79 return ScaleQuantumToChar(packet.green); 80 } 81 82 /** 83 * The value for blue as a byte 84 */ 85 void blueByte(ubyte blue) 86 { 87 packet.blue = ScaleCharToQuantum(blue); 88 } 89 ///ditto 90 ubyte blueByte() 91 { 92 return ScaleQuantumToChar(packet.blue); 93 } 94 95 /** 96 * The value for red as a double in the range [0.0 .. 1.0] 97 */ 98 void red(double red) 99 { 100 packet.red = scaleDoubleToQuantum(red); 101 } 102 ///ditto 103 double red() 104 { 105 return scaleQuantumToDouble(packet.red); 106 } 107 108 /** 109 * The value for green as a double in the range [0.0 .. 1.0] 110 */ 111 void green(double green) 112 { 113 packet.green = scaleDoubleToQuantum(green); 114 } 115 ///ditto 116 double green() 117 { 118 return scaleQuantumToDouble(packet.green); 119 } 120 121 /** 122 * The value for blue as a double in the range [0.0 .. 1.0] 123 */ 124 void blue(double blue) 125 { 126 packet.blue = scaleDoubleToQuantum(blue); 127 } 128 ///ditto 129 double blue() 130 { 131 return scaleQuantumToDouble(packet.blue); 132 } 133 }