Skip to content

Commit

Permalink
Add the script file
Browse files Browse the repository at this point in the history
  • Loading branch information
tailoric committed Sep 7, 2019
1 parent 8bf6cbc commit 8c927a8
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions script-fu-outline.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
(script-fu-register
"script-fu-outline" ; func name
"Outline Current Layer..." ; menu label
"Creates a simple outline for the current layer"
"Eric Schneider" ; copyright notice
"2019 Eric Schneider"
"September 07, 2019 " ; date created
"RGBA" ; image type that the script works on
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT "Border Size" '(2 1 1000 1 5 0 1) ; a spin button
SF-COLOR "Color" '(0 0 0) ; color variable
SF-TOGGLE "Merge with Layer?" FALSE ; toggle if the layer should get merged with the outline
)
(script-fu-menu-register "script-fu-outline" "<Image>/Edit")
(define (script-fu-outline inImage inLayer inBorderSize inBorderColor doMergeWitLayer)
(let* (
(inLayerName (car (gimp-item-get-name inLayer)))
(currentForegroundColor (car (gimp-context-get-foreground))) ;get the current foreground color to reset later
(borderLayerHeight (+ (car (gimp-drawable-height inLayer)) inBorderSize))
(borderLayerWidth (+ (car (gimp-drawable-width inLayer)) inBorderSize))
(borderLayerPosition (+ (car (gimp-image-get-item-position inImage inLayer) ) 1))
(borderLayerOffsets (gimp-drawable-offsets inLayer))
(theBorderLayer (car
(gimp-layer-new
inImage
borderLayerWidth
borderLayerHeight
RGB-IMAGE
(string-append "Border Layer of '" inLayerName "'")
100
LAYER-MODE-NORMAL-LEGACY
)
)
)
)
(gimp-image-undo-group-start inImage)
(gimp-selection-clear inImage);remove current selection if there
;initialize the border layer
(gimp-image-add-layer inImage theBorderLayer borderLayerPosition)
(gimp-layer-set-offsets theBorderLayer (car borderLayerOffsets) (cadr borderLayerOffsets))
(gimp-layer-add-alpha theBorderLayer)
(gimp-layer-resize theBorderLayer (+ borderLayerWidth inBorderSize) (+ borderLayerHeight inBorderSize) inBorderSize inBorderSize)
(plug-in-colortoalpha RUN-NONINTERACTIVE inImage theBorderLayer '(0 0 0))
;select the outline of the current layer
(gimp-image-select-item inImage CHANNEL-OP-ADD inLayer)
(gimp-selection-grow inImage inBorderSize)
(gimp-context-set-foreground inBorderColor)
(gimp-edit-bucket-fill
theBorderLayer
BUCKET-FILL-FG
LAYER-MODE-NORMAL-LEGACY
100
0
TRUE
0
0
)
(gimp-context-set-foreground currentForegroundColor)
(gimp-selection-clear inImage)
(when (equal? doMergeWitLayer TRUE) (gimp-image-merge-down
inImage
inLayer
CLIP-TO-BOTTOM-LAYER
)
)
(gimp-image-undo-group-end inImage)
)
)

0 comments on commit 8c927a8

Please sign in to comment.