(in-package :clim-postscript)

(defmethod climi::medium-draw-design* 
    ((medium postscript-medium) (design climi::bezier-area))
  (let ((stream (postscript-medium-file-stream medium))
        (*transformation* (sheet-native-transformation (medium-sheet medium))))
    (postscript-actualize-graphics-state stream medium)
    (format stream "newpath~%")
    (let ((p0 (slot-value (car (climi::segments design)) 'climi::p0)))
      (write-coordinates stream (point-x p0) (point-y p0))
      (format stream "moveto~%"))
    (loop for segment in (climi::segments design)
          do (with-slots (climi::p1 climi::p2 climi::p3) segment
               (write-coordinates stream (point-x climi::p1) (point-y climi::p1))
               (write-coordinates stream (point-x climi::p2) (point-y climi::p2))
               (write-coordinates stream (point-x climi::p3) (point-y climi::p3))
               (format stream "curveto~%")))
    (format stream "fill~%")))

(defvar *design*
  (climi::make-bezier-area* '(100 100 150 120 170 120 190 90
                              160 80 140 80 100 100)))

;;; need to run gsharp before this will work
(defvar *g*
  (sdl::compute-design (aref score-pane::*fonts* 6) :g-clef))

#|
(with-open-file (ps "/tmp/treble.ps" :direction :output :if-exists :supersede)
  (clim:with-output-to-postscript-stream (s ps)
    (clim:draw-design s (clim:transform-region (clim:make-transformation 1 0 0 -1 200 200) *g*))))
|#
