libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd/cvd draw.h


From: Damian Eads
Subject: [libcvd-members] libcvd/cvd draw.h
Date: Mon, 04 Oct 2010 18:00:29 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Damian Eads <eads>      10/10/04 18:00:29

Modified files:
        cvd            : draw.h 

Log message:
        Added a more generic version of drawShape.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/draw.h?cvsroot=libcvd&r1=1.12&r2=1.13

Patches:
Index: draw.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/draw.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- draw.h      20 Mar 2010 20:28:21 -0000      1.12
+++ draw.h      4 Oct 2010 18:00:12 -0000       1.13
@@ -182,6 +182,30 @@
     drawLine(im, points.back()+offset, points.front()+offset, c);
 }
 
+/// draws a polyline defined by a set of points into an image. A given offset 
is added
+/// to all points.
+/// @param im image to draw in
+/// @param offset added to all points
+/// @param begin an iterator pointing to the first point in the shape.
+/// @param end   an iterator pointing to one past the last point in the shape.
+/// @param c color of the line
+/// @ingroup gGraphics
+template <class T, class PointIterator>
+void drawShape(Image<T>& im, const ImageRef& offset,
+               PointIterator begin, PointIterator end, const T& c) {
+    if (begin == end) {
+        return;
+    }
+    PointIterator last(begin);
+    PointIterator it(begin);
+    ++it;
+    for (; it != end; it++) {
+        drawLine(im, *last+offset, *(it)+offset, c);
+        last = it;
+    }
+    drawLine(im, (*last)+offset, (*begin)+offset, c);
+}
+
 /// draws a box defined by the upper left and the lower right corners into an 
image
 /// @param im image to draw in
 /// @param upperleft ImageRef of upper left corner



reply via email to

[Prev in Thread] Current Thread [Next in Thread]