]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/markup-line-styles.ly
Imported Upstream version 2.19.45
[lilypond.git] / input / regression / markup-line-styles.ly
1 \version "2.19.22"
2
3 \header {
4   texidoc = "The markup-commands @code{\\draw-dashed-line},
5   @code{\\draw-dotted-line} and @code{\\draw-squiggle-line} should print the
6   same visual length as @code{\\draw-line}.
7   Also testing possible overrides for @code{\\draw-squiggle-line}"
8 }
9
10 %% draw-dotted-line and draw-dashed-line
11 test =
12 #(define-scheme-function (x-nmbr y-nmbr)(number? number?)
13  (let* ((lst (map
14                (lambda (x)
15                  (let* ((x-lngth (if (positive? x-nmbr)
16                                      (* x 0.75)
17                                      (* x -0.75)))
18                         (dest (cons x-lngth y-nmbr))
19                         (x-strg (number->string x-lngth))
20                         (y-strg (number->string y-nmbr))
21                         (txt-1 (markup
22                                #:concat (
23                                    " \\draw-dotted-line #'("
24                                    x-strg
25                                    " . "
26                                    y-strg
27                                    ")")))
28                         (txt-2 (markup
29                                #:concat (
30                                    " \\draw-dashed-line #'("
31                                    x-strg
32                                    " . "
33                                    y-strg
34                                    ")")))
35                         (txt-3 (markup
36                                #:concat (
37                                    " \\draw-line #'("
38                                    x-strg
39                                    " . "
40                                    y-strg
41                                    ")"))))
42                     (markup
43                        #:override '(baseline-skip . 0)
44                        #:left-column
45                          (
46                          ;; dotted-line
47                          #:line
48                            ((#:draw-dotted-line dest)
49                              #:vcenter (#:fontsize -4 txt-1))
50                          ;; dashed-line
51                          #:line
52                            ((#:draw-dashed-line dest)
53                              #:vcenter (#:fontsize -4 txt-2))
54                          ;; default solid-line:
55                          #:line
56                            ((#:draw-line dest)
57                              #:vcenter (#:fontsize -4 txt-3))
58                          #:vspace 0.5))))
59                   (iota (abs x-nmbr)))))
60         lst))
61
62 %% draw-squiggle-line
63 mrkp =
64 \markup
65   \override #'(word-space . 2)
66   \column {
67     \line { \draw-squiggle-line #0.5 #'(6 . 0) ##t \tiny \vcenter "default" }
68     \line {
69       \override #'(orientation . -1) \draw-squiggle-line #0.5 #'(6 . 0) ##t
70       \tiny \vcenter "different orientation"
71     }
72     \line {
73       \draw-squiggle-line #0.5 #'(6 . 0) ##f
74       \tiny \vcenter "\"eq-end?\" set #f"
75     }
76     \line {
77       \override #'(height . 1) \draw-squiggle-line #0.5 #'(6 . 0) ##t
78       \tiny \vcenter "different height"
79     }
80     \line {
81       \override #'(thickness . 5) \draw-squiggle-line #0.5 #'(6 . 0) ##t
82       \tiny \vcenter "different thickness"
83     }
84     \line {
85       \override #'(angularity . 2) \draw-squiggle-line #0.5 #'(6 . 0) ##t
86       \tiny \vcenter "different angularity"
87     }
88   }
89
90 test-draw-squiggle-line =
91 #(define-scheme-function (steps) (integer?)
92 ;; Puts out a markup combining draw-line-markup and draw-squiggle-line-markup
93 ;; in a  helix-like mannor
94   (define (val-pts-list steps)
95     ;; Puts out a list, with each element being a pair of a numerical value
96     ;; and a number-pair
97     ;; The numerical value is used for first-bow-length and its height
98     ;; The number-pair is the destination-point of the line.
99     ;; Those points are on a simple helix around '(0 . 0)
100     (map
101       (lambda (n r)
102         (let* ((y (* (sin n) r))
103                (x (* (cos n) r)))
104           (if (< (abs x) 0.00001)
105               (set! x 0))
106           (if (< (abs y) 0.00001)
107               (set! y 0))
108           (cons (max 0.1 (- 0.5 (/ 1 r))) (cons x y ))))
109       (iota steps 0 (/ TWO-PI steps))
110       (iota steps 3 0.5)))
111
112   (let ((args
113           (map
114             (lambda (arg)
115               #{
116                 \markup
117                   \combine
118                     \draw-line $(cdr arg)
119                     \override #`(height . , (car arg))
120                     \draw-squiggle-line
121                       #(car arg)
122                       $(cdr arg) ##f
123               #})
124             (val-pts-list steps))))
125     #{ \markup { \hspace #10 \overlay $args \hspace #5 \vcenter \mrkp } #}))
126
127 \test #15 #0
128
129 \test-draw-squiggle-line #12 #10