1998-05-12 22:21:08 +00:00
|
|
|
;
|
|
|
|
; distress selection
|
|
|
|
;
|
|
|
|
;
|
|
|
|
; Chris Gutteridge (cjg@ecs.soton.ac.uk)
|
|
|
|
; At ECS Dept, University of Southampton, England.
|
|
|
|
|
2009-01-17 22:28:01 +00:00
|
|
|
; This program is free software: you can redistribute it and/or modify
|
1998-05-12 22:21:08 +00:00
|
|
|
; it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
; the Free Software Foundation; either version 3 of the License, or
|
1998-05-12 22:21:08 +00:00
|
|
|
; (at your option) any later version.
|
2006-10-16 01:08:54 +00:00
|
|
|
;
|
1998-05-12 22:21:08 +00:00
|
|
|
; 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.
|
2006-10-16 01:08:54 +00:00
|
|
|
;
|
1998-05-12 22:21:08 +00:00
|
|
|
; You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1998-05-12 22:21:08 +00:00
|
|
|
|
|
|
|
; Define the function:
|
|
|
|
|
2003-06-10 12:57:27 +00:00
|
|
|
(define (script-fu-distress-selection inImage
|
2007-06-04 16:18:32 +00:00
|
|
|
inDrawable
|
2006-10-16 01:08:54 +00:00
|
|
|
inThreshold
|
|
|
|
inSpread
|
|
|
|
inGranu
|
|
|
|
inSmooth
|
|
|
|
inSmoothH
|
|
|
|
inSmoothV)
|
|
|
|
|
|
|
|
(let (
|
|
|
|
(theImage inImage)
|
|
|
|
(theWidth (car (gimp-image-width inImage)))
|
|
|
|
(theHeight (car (gimp-image-height inImage)))
|
2008-01-15 05:15:08 +00:00
|
|
|
(theLayer 0)
|
2007-06-04 16:18:32 +00:00
|
|
|
(theMode (car (gimp-image-base-type inImage)))
|
2014-11-23 20:52:15 +01:00
|
|
|
(prevLayer (car (gimp-image-get-active-layer inImage)))
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
2003-06-10 12:57:27 +00:00
|
|
|
|
2011-11-09 02:42:34 -05:00
|
|
|
(gimp-context-push)
|
|
|
|
(gimp-context-set-defaults)
|
|
|
|
(gimp-image-undo-group-start theImage)
|
2003-06-10 12:57:27 +00:00
|
|
|
|
2011-11-09 02:42:34 -05:00
|
|
|
(if (= theMode GRAY)
|
|
|
|
(set! theMode GRAYA-IMAGE)
|
|
|
|
(set! theMode RGBA-IMAGE)
|
|
|
|
)
|
|
|
|
(set! theLayer (car (gimp-layer-new theImage
|
|
|
|
theWidth
|
|
|
|
theHeight
|
|
|
|
theMode
|
|
|
|
"Distress Scratch Layer"
|
|
|
|
100
|
2017-01-09 20:37:30 +01:00
|
|
|
LAYER-MODE-NORMAL)))
|
2011-11-09 02:42:34 -05:00
|
|
|
|
|
|
|
(gimp-image-insert-layer theImage theLayer 0 0)
|
|
|
|
|
|
|
|
(if (= FALSE (car (gimp-selection-is-empty theImage)))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill theLayer FILL-BACKGROUND)
|
2011-11-09 02:42:34 -05:00
|
|
|
)
|
2003-06-10 12:57:27 +00:00
|
|
|
|
2011-11-09 02:42:34 -05:00
|
|
|
(gimp-selection-invert theImage)
|
2003-06-10 12:57:27 +00:00
|
|
|
|
2011-11-09 02:42:34 -05:00
|
|
|
(if (= FALSE (car (gimp-selection-is-empty theImage)))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-clear theLayer)
|
2007-06-04 16:18:32 +00:00
|
|
|
)
|
2003-06-10 12:57:27 +00:00
|
|
|
|
2011-11-09 02:42:34 -05:00
|
|
|
(gimp-selection-invert theImage)
|
|
|
|
(gimp-selection-none inImage)
|
|
|
|
|
|
|
|
(gimp-layer-scale theLayer
|
|
|
|
(/ theWidth inGranu)
|
|
|
|
(/ theHeight inGranu)
|
|
|
|
TRUE)
|
|
|
|
|
|
|
|
(plug-in-spread RUN-NONINTERACTIVE
|
|
|
|
theImage
|
|
|
|
theLayer
|
|
|
|
inSpread
|
|
|
|
inSpread)
|
|
|
|
|
|
|
|
(plug-in-gauss-iir RUN-NONINTERACTIVE
|
|
|
|
theImage theLayer inSmooth inSmoothH inSmoothV)
|
|
|
|
(gimp-layer-scale theLayer theWidth theHeight TRUE)
|
|
|
|
(plug-in-threshold-alpha RUN-NONINTERACTIVE theImage theLayer inThreshold)
|
|
|
|
(plug-in-gauss-iir RUN-NONINTERACTIVE theImage theLayer 1 TRUE TRUE)
|
|
|
|
(gimp-image-select-item inImage CHANNEL-OP-REPLACE theLayer)
|
|
|
|
(gimp-image-remove-layer theImage theLayer)
|
|
|
|
(if (and (= (car (gimp-item-is-channel inDrawable)) TRUE)
|
|
|
|
(= (car (gimp-item-is-layer-mask inDrawable)) FALSE))
|
|
|
|
(gimp-image-set-active-channel theImage inDrawable)
|
|
|
|
)
|
|
|
|
(gimp-image-undo-group-end theImage)
|
|
|
|
|
2014-11-23 20:52:15 +01:00
|
|
|
(gimp-image-set-active-layer theImage prevLayer)
|
|
|
|
|
2011-11-09 02:42:34 -05:00
|
|
|
(gimp-displays-flush)
|
|
|
|
(gimp-context-pop)
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
1998-05-12 22:21:08 +00:00
|
|
|
|
2003-06-10 12:57:27 +00:00
|
|
|
(script-fu-register "script-fu-distress-selection"
|
2006-10-19 12:09:52 +00:00
|
|
|
_"_Distort..."
|
2006-10-16 01:08:54 +00:00
|
|
|
_"Distress the selection"
|
|
|
|
"Chris Gutteridge"
|
|
|
|
"1998, Chris Gutteridge / ECS dept, University of Southampton, England."
|
|
|
|
"23rd April 1998"
|
2007-06-04 16:18:32 +00:00
|
|
|
"RGB*,GRAY*"
|
2006-10-16 01:08:54 +00:00
|
|
|
SF-IMAGE "The image" 0
|
|
|
|
SF-DRAWABLE "The layer" 0
|
Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer
metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 12:44:17 +00:00
|
|
|
SF-ADJUSTMENT _"_Threshold (bigger 1<-->254 smaller)" '(127 1 254 1 10 0 0)
|
|
|
|
SF-ADJUSTMENT _"_Spread" '(8 0 1000 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"_Granularity (1 is low)" '(4 1 25 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"S_mooth" '(2 1 150 1 10 0 1)
|
|
|
|
SF-TOGGLE _"Smooth hor_izontally" TRUE
|
|
|
|
SF-TOGGLE _"Smooth _vertically" TRUE
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
2004-11-18 22:44:28 +00:00
|
|
|
|
|
|
|
(script-fu-menu-register "script-fu-distress-selection"
|
2006-10-16 01:08:54 +00:00
|
|
|
"<Image>/Select/Modify")
|