blob: 144b8288f3e2d029a9f9e9a0602c41c4d814e586 (
plain)
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
|
/**
* A container for the pixel values: red, green, blue and opacity.
*
* Copyright: Mike Wey 2011
* License: To be determined
* Authors: Mike Wey
*/
module dmagick.Color;
import std.string;
import dmagick.Exception;
import dmagick.Utils;
import dmagick.c.color;
import dmagick.c.exception;
import dmagick.c.pixel;
import dmagick.c.magickType;
class Color
{
PixelPacket* pixelPacket;
this()
{
pixelPacket = new PixelPacket;
pixelPacket.opacity = TransparentOpacity;
}
this(Quantum red, Quantum green, Quantum blue)
{
this(red, green, blue, 0);
}
this(Quantum red, Quantum green, Quantum blue, Quantum opacity)
{
this();
pixelPacket.red = red;
pixelPacket.green = green;
pixelPacket.blue = blue;
pixelPacket.opacity = opacity;
}
this(string color)
{
this();
ExceptionInfo* exception = AcquireExceptionInfo();
const(char)* name = toStringz(color);
QueryColorDatabase(name, pixelPacket, exception);
DMagickException.throwException(exception);
DestroyExceptionInfo(exception);
}
this(PixelPacket packet)
{
this();
pixelPacket.red = packet.red;
pixelPacket.green = packet.green;
pixelPacket.blue = packet.blue;
pixelPacket.opacity = packet.opacity;
}
this(PixelPacket* packet)
{
pixelPacket = packet;
}
bool opEquals(Color color)
{
return *pixelPacket == *(color.pixelPacket);
}
override string toString()
{
//TODO
return "none";
}
Color clone()
{
return new Color(*pixelPacket);
}
}
|