Stencil
Lookup::bezier_sandwich (Bezier top_curve, Bezier bottom_curve, Real thickness)
{
- /*
- Need the weird order b.o. the way PS want its arguments
- */
- SCM list = SCM_EOL;
- list = scm_cons (ly_offset2scm (bottom_curve.control_[3]), list);
- list = scm_cons (ly_offset2scm (bottom_curve.control_[0]), list);
- list = scm_cons (ly_offset2scm (bottom_curve.control_[1]), list);
- list = scm_cons (ly_offset2scm (bottom_curve.control_[2]), list);
- list = scm_cons (ly_offset2scm (top_curve.control_[0]), list);
- list = scm_cons (ly_offset2scm (top_curve.control_[3]), list);
- list = scm_cons (ly_offset2scm (top_curve.control_[2]), list);
- list = scm_cons (ly_offset2scm (top_curve.control_[1]), list);
-
- SCM horizontal_bend = scm_list_n (ly_symbol2scm ("bezier-sandwich"),
- ly_quote_scm (list),
+ SCM commands = scm_list_n (ly_symbol2scm ("moveto"),
+ scm_from_double (top_curve.control_[0][X_AXIS]),
+ scm_from_double (top_curve.control_[0][Y_AXIS]),
+ ly_symbol2scm ("curveto"),
+ scm_from_double (top_curve.control_[1][X_AXIS]),
+ scm_from_double (top_curve.control_[1][Y_AXIS]),
+ scm_from_double (top_curve.control_[2][X_AXIS]),
+ scm_from_double (top_curve.control_[2][Y_AXIS]),
+ scm_from_double (top_curve.control_[3][X_AXIS]),
+ scm_from_double (top_curve.control_[3][Y_AXIS]),
+ ly_symbol2scm ("curveto"),
+ scm_from_double (bottom_curve.control_[2][X_AXIS]),
+ scm_from_double (bottom_curve.control_[2][Y_AXIS]),
+ scm_from_double (bottom_curve.control_[1][X_AXIS]),
+ scm_from_double (bottom_curve.control_[1][Y_AXIS]),
+ scm_from_double (bottom_curve.control_[0][X_AXIS]),
+ scm_from_double (bottom_curve.control_[0][Y_AXIS]),
+ ly_symbol2scm ("closepath"),
+ SCM_UNDEFINED);
+
+ SCM horizontal_bend = scm_list_n (ly_symbol2scm ("path"),
scm_from_double (thickness),
+ ly_quote_scm (commands),
+ ly_quote_scm (ly_symbol2scm ("round")),
+ ly_quote_scm (ly_symbol2scm ("round")),
+ SCM_BOOL_T,
SCM_UNDEFINED);
Interval x_extent = top_curve.extent (X_AXIS);
closepath fill
} bind def
-% this is for drawing slurs and barre-indicators.
-/draw_bezier_sandwich % x5 y5 x6 y6 x7 y7
- % x4 y4
- % x1 y1 x2 y2 x3 y3
- % x0 y0
- % linewidth draw_bezier_sandwich
-{
- gsave
- currentpoint translate
- % round ending and round beginning
- 1 setlinejoin 1 setlinecap
- setlinewidth
- moveto
- curveto
- lineto
- curveto
- closepath
- stroke_and_fill
- grestore
-} bind def
-
/draw_circle % filled? radius thickness draw_circle
{
setlinewidth % f? r
(define-public (ly:all-stencil-commands)
"Return the list of stencil commands that can be
defined in the output modules (@file{output-*.scm})."
- '(bezier-sandwich
- blank
+ '(blank
char
circle
dashed-line
(+ (* size end-string-coordinate) half-thickness)))
(x-extent (cons (car box-lower-left) (car box-upper-right)))
(y-extent (cons (cdr box-lower-left) (cdr box-upper-right))))
- (ly:make-stencil
- (list 'bezier-sandwich
- `(quote ,bezier-list)
- (* size bezier-thick))
+ (make-bezier-sandwich-stencil
+ bezier-list
+ (* size bezier-thick)
x-extent
y-extent)))
;;; Lily output interface, PostScript implementation --- cleanup and docme
;;;
-;; two beziers
-(define (bezier-sandwich lst thick)
- (ly:format "~l ~4f draw_bezier_sandwich"
- (map number-pair->string4 lst)
- thick))
-
(define (char font i)
(ly:format "~a (\\~a) show"
(ps-font-command font)
;;; stencil commands
;;;
-(define (bezier-sandwich lst thick)
- (format #f "bezier_sandwich ~a [~a]"
- thick
- (string-append
- (string-join (map
- (lambda (x)
- (format #f "(~a,~a)" (car x) (cdr x)))
- lst)
- ","))))
-
(define (draw-line thick x1 y1 x2 y2)
(format #f "drawline ~a ~a ~a ~a ~a"
thick x1 y2 x2 y2))
;;; stencil outputters
;;;
-(define (bezier-sandwich lst thick)
- (let* ((first (list-tail lst 4))
- (second (list-head lst 4)))
- (entity 'path ""
- '(stroke-linejoin . "round")
- '(stroke-linecap . "round")
- '(stroke . "currentColor")
- '(fill . "currentColor")
- `(stroke-width . ,thick)
- `(d . ,(string-append (svg-bezier first #f)
- (svg-bezier second #t))))))
-
(define (char font i)
(dispatch
`(fontify ,font ,(entity 'tspan (char->entity (integer->char i))))))
;;;; You should have received a copy of the GNU General Public License
;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
+(define (make-bezier-sandwich-stencil coords thick xext yext)
+ (let* ((command-list `(moveto
+ ,(car (list-ref coords 3))
+ ,(cdr (list-ref coords 3))
+ curveto
+ ,(car (list-ref coords 0))
+ ,(cdr (list-ref coords 0))
+ ,(car (list-ref coords 1))
+ ,(cdr (list-ref coords 1))
+ ,(car (list-ref coords 2))
+ ,(cdr (list-ref coords 2))
+ curveto
+ ,(car (list-ref coords 4))
+ ,(cdr (list-ref coords 4))
+ ,(car (list-ref coords 5))
+ ,(cdr (list-ref coords 5))
+ ,(car (list-ref coords 6))
+ ,(cdr (list-ref coords 6))
+ closepath)))
+ (ly:make-stencil
+ `(path ,thick `(,@' ,command-list) 'round 'round #t)
+ xext
+ yext)))
+
(define-public (stack-stencils axis dir padding stils)
"Stack stencils @var{stils} in direction @var{axis}, @var{dir}, using
@var{padding}."
(lower-inner-control-point
(cons inner-control-x lower-control-y)))
- (ly:make-stencil
- (list 'bezier-sandwich
- `(quote ,(list
- ;; Step 4: curve through inner control points
- ;; to lower end point.
- upper-inner-control-point
- lower-inner-control-point
- lower-end-point
- ;; Step 3: move to upper end point.
- upper-end-point
- ;; Step 2: curve through outer control points
- ;; to upper end point.
- lower-outer-control-point
- upper-outer-control-point
- upper-end-point
- ;; Step 1: move to lower end point.
- lower-end-point))
- line-width)
- (interval-widen x-extent (/ line-width 2))
- (interval-widen y-extent (/ line-width 2)))))
+ (make-bezier-sandwich-stencil
+ (list
+ ;; Step 4: curve through inner control points
+ ;; to lower end point.
+ upper-inner-control-point
+ lower-inner-control-point
+ lower-end-point
+ ;; Step 3: move to upper end point.
+ upper-end-point
+ ;; Step 2: curve through outer control points
+ ;; to upper end point.
+ lower-outer-control-point
+ upper-outer-control-point
+ upper-end-point
+ ;; Step 1: move to lower end point.
+ lower-end-point)
+ line-width
+ (interval-widen x-extent (/ line-width 2))
+ (interval-widen y-extent (/ line-width 2)))))
(define-public (parenthesize-stencil
stencil half-thickness width angularity padding)