- (string-append
- (ly:number->string x) " " (ly:number->string y) " { " s " } place-box\n"))
-
-(define (polygon points blotdiameter)
- (string-append
- (ly:numbers->string points) " "
- (ly:number->string (/ (length points) 2)) " "
- (ly:number->string blotdiameter)
- " draw_polygon"))
-
-(define (repeat-slash wid slope thick)
- (string-append
- (ly:numbers->string (list wid slope thick))
- " draw_repeat_slash"))
-
-(define (round-filled-box x y width height blotdiam)
- (string-append
- (ly:numbers->string
- (list x y width height blotdiam)) " draw_round_box"))
+ (format #f
+"~a ~a moveto
+~a\n"
+ (str4 x)
+ (str4 y)
+ s))
+
+(define (polygon points blot-diameter filled?)
+ (format #f "~a ~a ~a ~a draw_polygon"
+ (if filled? "true" "false")
+ (numbers->string4 points)
+ (number->string (- (/ (length points) 2) 1))
+ (str4 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)))
+ (format #f "~a draw_repeat_slash"
+ (numbers->string4 (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))))
+ (format #f "~a draw_round_box"
+ (numbers->string4
+ (list width height x y blotdiam)))))
+
+;; save current color on stack and set new color
+(define (setcolor r g b)
+ (format #f "gsave ~a setrgbcolor\n"
+ (numbers->string4 (list r g b))))
+
+;; restore color from stack
+(define (resetcolor) "grestore \n")
+
+;; rotation around given point
+(define (setrotation ang x y)
+ (format "gsave ~a translate ~a rotate ~a translate\n"
+ (numbers->string4 (list x y))
+ (number->string ang)
+ (numbers->string4 (list (* -1 x) (* -1 y)))))
+
+(define (resetrotation ang x y)
+ "grestore ")
+