GIMP Script-fu

Artifact [029a5607f6]
Login

Artifact 029a5607f6e9acf0e5ce24edf8f222bbcdc2eb81:


; 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-layer-new-per-PC image drawable)
  (gimp-image-undo-group-start image)
  (let* ((drawable (car (gimp-image-get-active-layer image)))
         (mode (vector-ref #( "Normal" "Dissolve" "Behind" 
                              "Multiply" "Screen" "Overlay" 
                              "Difference" "Addition" "Subtract" 
                              "Darken only" "Lighten only" "Hue" 
                              "Saturation" "Color" "Value" 
                              "Divide" "Dodge" "Burn" 
                              "Hardlight" "Softlight" "Grain extract" 
                              "Grain merge" "Color erase" "Erase" 
                              "Replace" "Anti-erase" )
                           (car (gimp-layer-get-mode drawable)) ))
         (opacity (car (gimp-layer-get-opacity drawable)))
         (layer (car (gimp-layer-new-from-visible image 
                                                  image 
                                                  (string-append mode
                                                                 " "
                                                                 (number->string opacity) ))))
         )
    (gimp-image-add-layer image layer 0)
    (gimp-image-set-active-layer image drawable)
    )
  (gimp-image-undo-group-end image)
  (gimp-displays-flush)
  )

(script-fu-register "sg-layer-new-per-PC"
 "New from visible (Photocomics)"
 "Create new layer but retain active layer"
 "Saul Goode"
 "Saul Goode"
 "11/4/2009"
 "*"
 SF-IMAGE    "Image"    0
 SF-DRAWABLE "Drawable" 0
 )
(script-fu-menu-register "sg-layer-new-per-PC"
  "<Image>/Layer"
  )