summaryrefslogtreecommitdiff
path: root/dmagick/Color.d
diff options
context:
space:
mode:
authorMike Wey2011-02-07 23:47:33 +0100
committerMike Wey2011-02-07 23:47:33 +0100
commitb5fc681a9af594c3d872199393ae065d37e4faf7 (patch)
tree194b25590c573396f82f48d8b8bae452979abc11 /dmagick/Color.d
parentd33595cdf0da82c14e7d12dd74a8cedbd9900cee (diff)
Add a Color class
Diffstat (limited to 'dmagick/Color.d')
-rw-r--r--dmagick/Color.d79
1 files changed, 79 insertions, 0 deletions
diff --git a/dmagick/Color.d b/dmagick/Color.d
new file mode 100644
index 0000000..f428f95
--- /dev/null
+++ b/dmagick/Color.d
@@ -0,0 +1,79 @@
+/**
+ * The image
+ *
+ * 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.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)
+ {
+ pixelPacket = packet;
+ }
+
+ bool opEquals(Color color)
+ {
+ return pixelPacket == color.pixelPacket;
+ }
+
+ override string toString()
+ {
+ //TODO
+
+ return "none";
+ }
+
+ Color clone()
+ {
+ return new Color(pixelPacket);
+ }
+}