diff options
Diffstat (limited to 'dmagick/ColorGray.d')
| -rw-r--r-- | dmagick/ColorGray.d | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dmagick/ColorGray.d b/dmagick/ColorGray.d new file mode 100644 index 0000000..3d78bda --- /dev/null +++ b/dmagick/ColorGray.d @@ -0,0 +1,60 @@ +/** + * Copyright: Mike Wey 2011 + * License: zlib (See accompanying LICENSE file) + * Authors: Mike Wey + */ + +module dmagick.ColorGray; + +import dmagick.Color; + +import dmagick.c.magickType; +import dmagick.c.quantum; + +/** + * A Gray scale color. + */ +class ColorGray : Color +{ + /// + this() + { + super(); + } + + /** + * Create a Color from the specified Bytes. + */ + this(ubyte shade, ubyte opacity = 0) + { + Quantum gray = ScaleCharToQuantum(shade); + + super(gray, gray, gray, ScaleCharToQuantum(opacity)); + } + + /** + * Create a Color from the specified doubles. + * The values should be between 0.0 and 1.0. + */ + this(double shade, double opacity = 0) + { + Quantum gray = scaleDoubleToQuantum(shade); + + super(gray, gray, gray, scaleDoubleToQuantum(opacity)); + } + + /** + * The value for the shade as a double in the range [0.0 .. 1.0] + */ + void shade(double shade) + { + pixelPacket.red = ScaleCharToQuantum(shade); + pixelPacket.green = ScaleCharToQuantum(shade); + pixelPacket.blue = ScaleCharToQuantum(shade); + } + ///ditto + double shade() + { + return scaleQuantumToDouble(pixelPacket.red); + } +} |
