]> git.donarmstrong.com Git - lilypond.git/blob - scm/output-socket.scm
e992e7c74b095605c4729338a10bdc3bb59f42cb
[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 (display (ly:all-stencil-expressions))
15 (for-each
16  (lambda (x) 
17    (module-define! (current-module)
18                    x
19                    dummy))
20  
21  (ly:all-stencil-expressions))
22
23
24 (define-public (draw-line thick x1 y1 x2 y2)
25   (format "drawline ~a ~a ~a ~a ~a"
26           thick x1 y2 x2 y2))
27
28 (define-public (polygon xy-coords blot do-fill)
29   (format "polygon ~a ~a ~a"
30           blot
31           (if do-fill "True" "False")
32           (string-join
33            (map number->string xy-coords))
34   ))
35
36 (define-public (named-glyph font glyph)
37   (format "glyphshow ~a \"~a\" ~a \"~a\""
38           (ly:font-glyph-name-to-charcode font glyph)
39           (ly:font-name font)
40           (modified-font-metric-font-scaling font)
41           glyph
42           ))
43
44 (define-public (placebox x y s) 
45   (format "at ~a ~a ~a\n" x y s))
46
47 (define-public (round-filled-box  breapth width depth height blot-diameter)
48   (format "draw_round_box ~a ~a ~a ~a ~a"
49           breapth width depth height blot-diameter
50           ))
51
52 (define (event-cause grob)
53   (let*
54       ((cause (ly:grob-property  grob 'cause)))
55
56     (cond
57      ((ly:stream-event? cause) cause)
58 ;     ((ly:grob? cause) (music-cause cause))
59      (else
60       #f))))
61
62 (define (grob-bbox grob offset)
63   (let*
64       ((x-ext (ly:grob-extent grob grob X))
65        (y-ext (ly:grob-extent grob grob Y))
66        (x (car offset))
67        (y (cdr offset)))
68
69     (if (interval-empty? x-ext)
70         (set! x-ext '(0 . 0)))
71
72     (if (interval-empty? y-ext)
73         (set! y-ext '(0 . 0)))
74     
75     (list (+ x (car x-ext))
76           (+ y (car y-ext))
77           (+ x (cdr x-ext))
78           (+ y (cdr y-ext))
79           )))
80
81 (define-public (no-origin)
82   "nocause\n")
83
84 (define-public (grob-cause offset grob)
85   (let*
86       ((cause (event-cause grob))
87        (tag (if (and cause (integer? (ly:event-property cause 'input-tag)))
88                 (ly:event-property cause 'input-tag)
89                 -1))
90        (name (cdr (assoc 'name (ly:grob-property grob 'meta))))
91        )
92     
93     (apply format
94            (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n"
95                          tag name)
96            
97                    (grob-bbox grob offset))
98           )))
99
100
101 (define (escape-string str)
102   (string-regexp-substitute
103    " " "\\040" 
104    (string-regexp-substitute "\"" "\\\"" str)))
105   
106 (define-public (utf-8-string
107                 descr
108                 string)
109   
110   (format "utf-8 \"~a\" \"~a\""
111           (escape-string descr)
112
113           ;; don't want unescaped spaces.
114           (escape-string string)
115           ))
116
117
118 (define (bezier-sandwich lst thick)
119   (format
120    #f
121    "bezier_sandwich ~a [~a]"
122    thick
123    (string-append 
124     (string-join (map (lambda (x) (format "(~a,~a)" (car x) (cdr x)))
125                       lst) ","))))