;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
-;;;; Copyright (C) 2008--2012 Reinhold Kainhofer <reinhold@kainhofer.com>
+;;;; Copyright (C) 2008--2015 Reinhold Kainhofer <reinhold@kainhofer.com>
;;;;
;;;; LilyPond is free software: you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
;;;; This file implements different flag styles in Scheme / GUILE, most
-;;;; notably the old-straight-flag and the modern-straight-flag styles.
+;;;; notably the old-straight-flag, the modern-straight-flag and the flat-flag
+;;;; styles.
(define-public (no-flag grob)
offset length thickness stroke-thickness)
"Add the stroke for acciaccatura to the given flag stencil.
The stroke starts for up-flags at `upper-end-of-flag + (0,length/2)'
-and ends at `(0, vertical-center-of-flag-end) -
-(flag-x-width/2, flag-x-width + flag-thickness)'. Here `length' is the
+and ends at `(0, vertical-center-of-flag-end) - (flag-x-width/2,
+flag-x-width + flag-thickness)'. Here `length' is the
whole length, while `flag-x-width' is just the x-extent and thus depends on
the angle! Other combinations don't look as good.
(end (offset-add (cons 0 (cdr offset))
(cons (- (/ (car offset) 2)) (* (- (+ thickness (car offset))) dir))))
(stroke (make-line-stencil stroke-thickness (car start) (cdr start) (car end) (cdr end))))
- (ly:stencil-add stencil stroke)))
+ (ly:stencil-add stencil stroke)))
(define (buildflag flag-stencil remain curr-stencil spacing)
"Internal function to recursively create a stencil with @code{remain} flags
(thickness-offset (cons 0 (* -1 thickness dir)))
(spacing (* -1 flag-spacing factor dir ))
(start (cons (- half-stem-thickness) (* half-stem-thickness dir)))
- ;; The points of a round-filled-polygon need to be given in clockwise
- ;; order, otherwise the polygon will be enlarged by blot-size*2!
- (points (if stem-up (list start flag-end
- (offset-add flag-end thickness-offset)
- (offset-add start thickness-offset))
- (list start
- (offset-add start thickness-offset)
- (offset-add flag-end thickness-offset)
- flag-end)))
+ (raw-points
+ (list
+ '(0 . 0)
+ flag-end
+ (offset-add flag-end thickness-offset)
+ thickness-offset))
+ (points (map (lambda (coord) (offset-add coord start)) raw-points))
(stencil (ly:round-filled-polygon points half-stem-thickness))
;; Log for 1/8 is 3, so we need to subtract 3
(flag-stencil (buildflag stencil (- log 3) stencil spacing))
(stroke-style (ly:grob-property grob 'stroke-style)))
- (if (equal? stroke-style "grace")
- (add-stroke-straight flag-stencil grob
- dir log
- stroke-style
- flag-end flag-length
- thickness
- (* half-stem-thickness 2))
- flag-stencil))))
+ (cond ((eq? (ly:grob-property grob 'style) 'no-flag)
+ empty-stencil)
+ ((equal? stroke-style "grace")
+ (add-stroke-straight flag-stencil grob
+ dir log
+ stroke-style
+ flag-end flag-length
+ thickness
+ (* half-stem-thickness 2)))
+ (else flag-stencil)))))
(define-public (modern-straight-flag grob)
"Modern straight flag style (for composers like Stockhausen, Boulez, etc.).
flags are both 45 degrees."
((straight-flag 0.55 1 -45 1.2 45 1.4) grob))
+(define-public (flat-flag grob)
+ "Flat flag style. The angles of the flags are both 0 degrees"
+ ((straight-flag 0.55 1.0 0 1.0 0 1.0) grob))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Flags created from feta glyphs (normal and mensural flags)
(dir (if (eqv? (ly:grob-property stem-grob 'direction) UP) "u" "d"))
(flag (retrieve-glyph-flag flag-style dir dir-modifier grob))
(stroke-style (ly:grob-property grob 'stroke-style)))
- (if (null? stroke-style)
- flag
- (add-stroke-glyph flag grob dir stroke-style flag-style))))
-
+ (cond ((eq? (ly:grob-property grob 'style) 'no-flag)
+ empty-stencil)
+ ((null? stroke-style)
+ flag)
+ (else
+ (add-stroke-glyph flag grob dir stroke-style flag-style)))))
(define-public (mensural-flag grob)
(create-glyph-flag "mensural" modifier grob)))
-
-(define-public ((glyph-flag flag-style) grob)
+(define ((glyph-flag flag-style) grob)
"Simulatesthe default way of generating flags: Look up glyphs
@code{flags.style[ud][1234]} from the feta font and use it for the flag
stencil."
(create-glyph-flag flag-style "" grob))
-
+(export glyph-flag)
(define-public (normal-flag grob)
(create-glyph-flag "" "" grob))
-
(define-public (default-flag grob)
"Create a flag stencil for the stem. Its style will be derived from the
@code{'style} Flag property. By default, @code{lilypond} uses a
(cond
((equal? flag-style "") (normal-flag grob))
((equal? flag-style "mensural") (mensural-flag grob))
- ((equal? flag-style "no-flag") (no-flag grob))
+ ((equal? flag-style "no-flag") empty-stencil)
(else ((glyph-flag flag-style) grob)))))
+