GIMP Script-fu

Artifact [e86d7b88e8]
Login

Artifact [e86d7b88e8]

Artifact e86d7b88e81995f9908f10bd339343ad9fd70b8d:


; 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-select-within-layer image drawable)
  (let* ((layer (car (gimp-image-get-active-layer image))))
    (gimp-image-undo-group-start image)
    (if (= (car (gimp-selection-bounds image)) FALSE)
      (gimp-selection-all image) )
    (gimp-rect-select image
                      (car (gimp-drawable-offsets layer))
                      (cadr (gimp-drawable-offsets layer))
                      (car (gimp-drawable-width layer))
                      (car (gimp-drawable-height layer))
                      CHANNEL-OP-INTERSECT 0 0 )
    (gimp-image-undo-group-end image) )
  (gimp-displays-flush)
  )

(script-fu-register "sg-select-within-layer"
  "_Within Layer"
  _"Intersect selection with the boundaries of the active layer"
  "Saul Goode"
  "Saul Goode"
  "11/16/2006"
  "*"
  SF-IMAGE    "Image"    0
  SF-DRAWABLE "Drawable" 0
  )
(script-fu-menu-register "sg-select-within-layer"
  "<Image>/Select"
  )