1 /**
2  * Copyright: Mike Wey 2011
3  * License:   zlib (See accompanying LICENSE file)
4  * Authors:   Mike Wey
5  */
6 
7 module dmagick.ColorGray;
8 
9 import dmagick.Color;
10 
11 import dmagick.c.magickType;
12 import dmagick.c.quantum;
13 
14 /**
15  * A Gray scale color.
16  */
17 class ColorGray : Color
18 {
19 	/** */
20 	this()
21 	{
22 		super();
23 	}
24 
25 	/**
26 	 * Create a Color from the specified Bytes.
27 	 */
28 	this(ubyte shade, ubyte opacity = 0)
29 	{
30 		Quantum gray = ScaleCharToQuantum(shade);
31 
32 		super(gray, gray, gray, ScaleCharToQuantum(opacity));
33 	}
34 
35 	/**
36 	 * Create a Color from the specified doubles.
37 	 * The values should be between 0.0 and 1.0.
38 	 */
39 	this(double shade, double opacity = 0)
40 	{
41 		Quantum gray = scaleDoubleToQuantum(shade);
42 
43 		super(gray, gray, gray, scaleDoubleToQuantum(opacity));
44 	}
45 
46 	/**
47 	 * The value for the shade as a double in the range [0.0 .. 1.0]
48 	 */
49 	void shade(double shade)
50 	{
51 		packet.red   = scaleDoubleToQuantum(shade);
52 		packet.green = scaleDoubleToQuantum(shade);
53 		packet.blue  = scaleDoubleToQuantum(shade);
54 	}
55 	///ditto
56 	double shade()
57 	{
58 		return scaleQuantumToDouble(packet.red);
59 	}
60 }