]> git.donarmstrong.com Git - lilypond.git/blob - scm/output-socket.scm
* scm/output-svg.scm (utf-8-string): rename from utf8-string.
[lilypond.git] / scm / output-socket.scm
1
2 (define-module (scm output-socket)
3   #:re-export (quote)
4   )
5
6 (use-modules (guile)
7              (srfi srfi-1)
8              (srfi srfi-13)
9              (lily))
10
11 (define (dummy . rest)
12   "")
13
14 (for-each
15  (lambda (x) 
16    (module-define! (current-module)
17                    x
18                    dummy))
19  
20  (ly:all-stencil-expressions))
21
22
23 (define-public (draw-line thick x1 y1 x2 y2)
24   (format "drawline ~a ~a ~a ~a ~a"
25           thick x1 y2 x2 y2))
26
27 (define-public (polygon xy-coords blot do-fill)
28   (format "polygon ~a ~a ~a"
29           blot
30           (if do-fill "True" "False")
31           (string-join
32            (map number->string xy-coords))
33   ))
34
35 (define-public (named-glyph font glyph)
36   (format "glyphshow ~a \"~a\" ~a \"~a\""
37           (ly:font-glyph-name-to-charcode font glyph)
38           (ly:font-name font)
39           (modified-font-metric-font-scaling font)
40           glyph
41           ))
42
43 (define-public (placebox x y s) 
44   (format "at ~a ~a ~a\n" x y s))
45
46 (define-public (round-filled-box  breapth width depth height blot-diameter)
47   (format "draw_round_box ~a ~a ~a ~a ~a"
48           breapth width depth height blot-diameter
49           ))
50
51 (define (music-cause grob)
52   (let*
53       ((cause (ly:grob-property  grob 'cause)))
54
55     (cond
56      ((ly:music? cause) cause)
57      ((ly:grob? cause) (music-cause cause))
58      (else
59       #f))))
60
61 (define (grob-bbox grob offset)
62   (let*
63       ((x-ext (ly:grob-extent grob grob X))
64        (y-ext (ly:grob-extent grob grob Y))
65        (x (car offset))
66        (y (cdr offset))
67        )
68
69     (map (lambda (x)
70            (if (inf? x) 0.0 x))
71          
72          (list (+ x (car x-ext))
73                (+ y (car y-ext))
74                (+ x (cdr x-ext))
75                (+ y (cdr y-ext)))
76     )))
77
78 (define-public (no-origin)
79   "nocause\n")
80
81 (define-public (grob-cause offset grob)
82   (let*
83       ((cause (music-cause grob))
84        (tag (if (and cause (integer? (ly:music-property cause 'input-tag)))
85                 (ly:music-property cause 'input-tag)
86                 -1))
87        (name (cdr (assoc 'name (ly:grob-property grob 'meta))))
88        )
89     
90     (apply format
91            (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n"
92                          tag name)
93            
94                    (grob-bbox grob offset))
95           )))
96
97
98 (define-public (utf-8-string
99                 descr
100                 string)
101   
102   (format "utf-8 \"~a\" \"~a\"" descr
103
104           ;; don't want unescaped spaces.
105           (string-regexp-substitute " " "\\040" string)))
106