]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add ly:round-filled-polygon scheme function to create a filled rounded polygon
authorReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 21 Aug 2008 23:17:37 +0000 (01:17 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 23 Aug 2008 19:37:40 +0000 (21:37 +0200)
Simply call the C++ method Lookup::round_filled_polygon, so I simply add a
Scheme interface wrapper here.

Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
lily/stencil-scheme.cc

index 79e76e3dcc5def74ed2a649698f0041417437d91..ed362c06289858341edfe50a15d108c55565a5d5 100644 (file)
@@ -319,6 +319,28 @@ LY_DEFINE (ly_round_filled_box, "ly:round-filled-box",
                                   scm_to_double (blot)).smobbed_copy ();
 }
 
+LY_DEFINE (ly_round_filled_polygon, "ly:round-filled-polygon",
+           2, 0, 0,
+           (SCM points, SCM blot),
+           "Make a @code{Stencil} object that prints a black polygon with "
+           "corners at the points defined by @var{points} (list of coordinate "
+           "pairs) and roundness @var{blot}.")
+{
+  SCM_ASSERT_TYPE (scm_ilength (points) > 0, points, SCM_ARG1, __FUNCTION__, "list of coordinate pairs");
+  LY_ASSERT_TYPE (scm_is_number, blot, 2);
+  vector<Offset> pts;
+  for (SCM p = points; scm_is_pair (p); p = scm_cdr (p))
+    {
+      SCM scm_pt = scm_car (p);
+      if (scm_is_pair (scm_pt)) {
+        pts.push_back (ly_scm2offset (scm_pt));
+      } else {
+        // TODO: Print out warning
+      }
+    }
+  return Lookup::round_filled_polygon (pts, scm_to_double (blot)).smobbed_copy ();
+}
+
 LY_DEFINE (ly_register_stencil_expression, "ly:register-stencil-expression",
           1, 0, 0,
           (SCM symbol),