diff options
| author | Mike Wey | 2011-08-28 23:14:09 +0200 |
|---|---|---|
| committer | Mike Wey | 2011-08-28 23:14:09 +0200 |
| commit | 9498f56bea3a87e35bd6a92b9fc29d8ed7ba98c0 (patch) | |
| tree | 57c776db686f37bd0b7f926454684e83eda7a21b | |
| parent | 6dce2778d911d8a08b492af1c5f43e707a1de790 (diff) | |
Add a line function to the DrawingContext, and a few bug fixes.
| -rw-r--r-- | dmagick/Color.d | 14 | ||||
| -rw-r--r-- | dmagick/DrawingContext.d | 23 | ||||
| -rw-r--r-- | dmagick/Options.d | 4 |
3 files changed, 32 insertions, 9 deletions
diff --git a/dmagick/Color.d b/dmagick/Color.d index ccb8b10..94b6906 100644 --- a/dmagick/Color.d +++ b/dmagick/Color.d @@ -29,13 +29,13 @@ class Color { packet = new PixelPacket; - packet.opacity = TransparentOpacity; + packet.opacity = OpaqueOpacity; } /** * Create a Color from the specified Quantums. */ - this(Quantum red, Quantum green, Quantum blue, Quantum opacity = 0) + this(Quantum red, Quantum green, Quantum blue, Quantum opacity = OpaqueOpacity) { this(); @@ -64,10 +64,10 @@ class Color { this(); - packet.red = packet.red; - packet.green = packet.green; - packet.blue = packet.blue; - packet.opacity = packet.opacity; + this.packet.red = packet.red; + this.packet.green = packet.green; + this.packet.blue = packet.blue; + this.packet.opacity = packet.opacity; } /** @@ -103,7 +103,7 @@ class Color else string frm = "%08X"; - if ( packet.opacity == 0 ) + if ( packet.opacity == OpaqueOpacity ) return format("#"~frm~frm~frm, packet.red, packet.green, packet.blue); else return format("#"~frm~frm~frm~frm, packet.red, packet.green, packet.blue, packet.opacity); diff --git a/dmagick/DrawingContext.d b/dmagick/DrawingContext.d index 51f24f3..f177a51 100644 --- a/dmagick/DrawingContext.d +++ b/dmagick/DrawingContext.d @@ -7,6 +7,7 @@ module dmagick.DrawingContext; import dmagick.Color; +import dmagick.Exception; import dmagick.Geometry; import dmagick.Image; import dmagick.Options; @@ -198,6 +199,28 @@ class DrawingContext } /** + * Draw a line from start to end. + */ + void line(size_t startX, size_t startY, size_t endX, size_t endY) + { + actions ~= (Image image) + { + PrimitiveInfo[] primitiveInfo = new PrimitiveInfo[3]; + + primitiveInfo[0].coordinates = 3; + primitiveInfo[0].primitive = PrimitiveType.LinePrimitive; + primitiveInfo[0].point = PointInfo(startX, startY); + primitiveInfo[1].primitive = PrimitiveType.LinePrimitive; + primitiveInfo[1].point = PointInfo(endX, endY); + primitiveInfo[2].primitive = PrimitiveType.UndefinedPrimitive; + + DrawPrimitive(image.imageRef, image.options.drawInfo, primitiveInfo.ptr); + + DMagickException.throwException(&(image.imageRef.exception)); + }; + } + + /** * Text rendering font point size */ void pointSize(double size) diff --git a/dmagick/Options.d b/dmagick/Options.d index d11366e..85e1c13 100644 --- a/dmagick/Options.d +++ b/dmagick/Options.d @@ -936,7 +936,7 @@ class Options ///ditto Color strokeColor() const { - return new Color(imageInfo.background_color); + return new Color(drawInfo.stroke); } /** @@ -990,7 +990,7 @@ class Options drawInfo.linecap = cap; } ///ditto - LineCap lineCap() const + LineCap strokeLineCap() const { return drawInfo.linecap; } |
