-/*
- * Horizontal Slope:
- *
- * /| ^
- * / | |
- * / | | height
- * / | |
- * / | v
- * | /
- * | /
- * (0,0) x /slope=dy/dx
- * | /
- * |/
- *
- * <----->
- * width
- */
-Stencil
-Lookup::beam (Real slope, Real width, Real thick, Real blot)
-{
- Real height = slope * width;
- Real min_y = (0 <? height) - thick/2;
- Real max_y = (0 >? height) + thick/2;
-
- Box b (Interval (0, width),
- Interval (min_y, max_y));
-
- SCM at = scm_list_n (ly_symbol2scm ("beam"),
- scm_make_real (width),
- scm_make_real (slope),
- scm_make_real (thick),
- scm_make_real (blot),
- SCM_UNDEFINED);
- return Stencil (b, at);
+ p = Offset (0, thick / 2);
+ b.add_point (p);
+ p += Offset (1, -1) * (blot / 2);
+
+ SCM points = SCM_EOL;
+
+ points = scm_cons (scm_from_double (p[X_AXIS]),
+ scm_cons (scm_from_double (p[Y_AXIS]),
+ points));
+
+ p = Offset (0, -thick / 2);
+ b.add_point (p);
+ p += Offset (1, 1) * (blot / 2);
+
+ points = scm_cons (scm_from_double (p[X_AXIS]),
+ scm_cons (scm_from_double (p[Y_AXIS]),
+ points));
+
+ p = Offset (width, width * slope - thick / 2);
+ b.add_point (p);
+ p += Offset (-1, 1) * (blot / 2);
+
+ points = scm_cons (scm_from_double (p[X_AXIS]),
+ scm_cons (scm_from_double (p[Y_AXIS]),
+ points));
+
+ p = Offset (width, width * slope + thick / 2);
+ b.add_point (p);
+ p += Offset (-1, -1) * (blot / 2);
+
+ points = scm_cons (scm_from_double (p[X_AXIS]),
+ scm_cons (scm_from_double (p[Y_AXIS]),
+ points));
+
+ SCM expr = scm_list_n (ly_symbol2scm ("polygon"),
+ ly_quote_scm (points),
+ scm_from_double (blot),
+ SCM_BOOL_T,
+ SCM_UNDEFINED);
+
+ return Stencil (b, expr);