From 9498f56bea3a87e35bd6a92b9fc29d8ed7ba98c0 Mon Sep 17 00:00:00 2001 From: Mike Wey Date: Sun, 28 Aug 2011 23:14:09 +0200 Subject: Add a line function to the DrawingContext, and a few bug fixes. --- dmagick/DrawingContext.d | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'dmagick/DrawingContext.d') 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; @@ -197,6 +198,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 */ -- cgit v1.2.3