-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) | ||
) |