(define tested-brush "Pepper")
(define tested-path (if (equal? (car (gimp-version)) "2.9.9")
                        (string-append "<path d='M 100 100"
                                   " h 1800 v 200 h -1800 v 200"
                                   " h 1800 v 200 h -1800 v 200"
                                   " h 1800 v 200 h -1800 v 200"
                                   " h 1800 v 200 h -1800 v 200"
                                   " h 1800 v 200 h -1800"
                                    "'/>")
                        (string-append "<path d='M 100 1900"
                                   " h 1800 v -200 h -1800 v -200"
                                   " h 1800 v -200 h -1800 v -200"
                                   " h 1800 v -200 h -1800 v -200"
                                   " h 1800 v -200 h -1800 v -200"
                                   " h 1800 v -200 h -1800"
                                    "'/>")))

(let* ((stderr (open-output-file "/dev/stderr"))
       (image (car (gimp-image-new 2000 2000 RGB)))
       (l (car (gimp-layer-new image 2000 2000 RGB-IMAGE "name" 100 NORMAL-MODE)))
       (vec (gimp-vectors-import-from-string image tested-path -1 0 1.0)))
  ;(display (car (gimp-vectors-export-to-string image (vector-ref (cadr vec) 0))) stderr)

  (gimp-image-insert-layer image l 0 0)

  (gimp-context-set-defaults)
  (gimp-context-set-brush tested-brush)

  (gimp-context-set-brush-size 200)
  (gimp-context-set-paint-method "gimp-paintbrush")
  (gimp-context-set-dynamics "Dynamics Off")

  (if (equal? (car (gimp-version)) "2.9.9")
      (begin
        (gimp-context-set-brush-default-hardness)
        (gimp-context-set-brush-spacing .01))
      (gimp-brushes-set-spacing 1))

  (define t0 (gettimeofday))
  (gimp-edit-stroke-vectors l (vector-ref (cadr vec) 0))
  (define t1 (gettimeofday))
  (define delta-t (- (+ (car t1) (/ (cadr t1) 1000000.0)) (+ (car t0) (/ (cadr t0) 1000000.0))))

  (display (car (gimp-version)) stderr) (newline stderr)
  (display (string-append "gimp-edit-stroke-vectors: ~ \033[32m" (number->string delta-t) "\033[0ms\n") stderr)

  (define file-name (string-append "tmp-" (car (gimp-version)) ".png"))

  (file-png-save 1 image l file-name file-name 0 0 0 0 0 0 0)
  (display (string-append "Exported " file-name "\n") stderr)

  (close-output-port stderr)
  (gimp-image-delete image)
  (gimp-quit TRUE))
