arrows.ily 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #(define (number-or-boolean? arg)
  2. (or (number? arg)
  3. (boolean? arg)))
  4. #(define-markup-command (arrow layout props ang length filled)
  5. (number? number-or-boolean? boolean?)
  6. #:category graphic
  7. "Draw an arrow of length @var{length}.
  8. Use filled head if @var{filled} is true.
  9. Rotate by @var{ang} degrees; default points to the right.
  10. In order to draw an arrowhead only, use @code{##f} for @var{length}.
  11. @lilypond[verbatim,quote]
  12. \\markup {
  13. \\arrow #0 #3 ##f
  14. \\arrow #-60 #5 ##t
  15. \\arrow #90 ##f ##t
  16. }
  17. @end lilypond
  18. "
  19. (let* ((head (markup #:with-color black #:arrow-head X 1 filled))
  20. (adjust -.5)
  21. (arro (if length
  22. (markup
  23. #:combine
  24. head
  25. #:translate (cons adjust 0)
  26. #:override '(thickness . 1.5)
  27. #:draw-line (cons (- adjust length) 0))
  28. head)))
  29. (interpret-markup layout props
  30. (markup
  31. #:rotate ang
  32. arro))))
  33. arrowup = \markup {
  34. \arrow #-45 #1 ##t
  35. }
  36. arrowdown = \markup {
  37. \arrow #-45 #1 ##t
  38. }