; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
(define (sg-split-path-strokes image path)
(let* (
(name (car (gimp-vectors-get-name path)))
(subpaths nil)
(strokes (gimp-vectors-get-strokes path))
(num-strokes (car strokes))
(allbut num-strokes)
(stroke nil)
)
(gimp-image-undo-group-start image)
(while (> num-strokes 0)
(set! subpaths (cons (car (gimp-vectors-copy path)) subpaths))
(gimp-image-add-vectors image (car subpaths) -1)
(gimp-vectors-set-name (car subpaths)
(string-append name
"#"
(number->string (+ num-strokes 1))))
(set! num-strokes (- num-strokes 1))
)
(while (pair? subpaths)
(set! allbut (- allbut 1))
(set! num-strokes (car strokes))
(while (> num-strokes 0)
(set! num-strokes (- num-strokes 1))
(unless (= num-strokes allbut)
(gimp-vectors-remove-stroke (car subpaths) (aref (cadr strokes) num-strokes))
)
)
(set! subpaths (cdr subpaths))
)
(gimp-image-remove-vectors image path)
(gimp-image-undo-group-end image)
)
)
(script-fu-register "sg-split-path-strokes"
"Split Strokes"
"Separate strokes of the active path"
"Saul Goode"
"Saul Goode"
"10/3/2008"
""
SF-IMAGE "Image" 0
SF-VECTORS "Vectors" 0
)
(script-fu-menu-register "sg-split-path-strokes"
"<Vectors>")