- (string-append
- (ly:number->string x) " " (ly:number->string y) " { " s " } place-box\n"))
-
-(define (polygon points blotdiameter filled?)
- (string-append
- (ly:numbers->string points) " "
- (ly:number->string (/ (length points) 2)) " "
- (ly:number->string blotdiameter)
- (if filled? " true " " false ")
- " draw_polygon"))
-
-(define (repeat-slash wid slope thick)
- (string-append
- (ly:numbers->string (list wid slope thick))
- " draw_repeat_slash"))
+ (ly:format
+"~4f ~4f moveto
+~a\n" x y s))
+
+(define (polygon points blot-diameter filled?)
+ (ly:format "~a ~4l ~a ~4f draw_polygon"
+ (if filled? "true" "false")
+ points
+ (- (/ (length points) 2) 1)
+ blot-diameter))
+
+(define (repeat-slash width slope beam-thickness)
+ (define (euclidean-length x y)
+ (sqrt (+ (* x x) (* y y))))
+
+ (let ((x-width (euclidean-length beam-thickness (/ beam-thickness slope)))
+ (height (* width slope)))
+ (ly:format "~4l draw_repeat_slash"
+ (list x-width width height))))
+
+
+(define (round-filled-box left right bottom top blotdiam)
+ (let* ((halfblot (/ blotdiam 2))
+ (x (- halfblot left))
+ (width (- right (+ halfblot x)))
+ (y (- halfblot bottom))
+ (height (- top (+ halfblot y))))
+ (ly:format "~4l draw_round_box"
+ (list width height x y blotdiam))))
+
+;; save current color on stack and set new color
+(define (setcolor r g b)
+ (ly:format "gsave ~4l setrgbcolor\n"
+ (list r g b)))