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