fluffybunny wrote:
Hi Esper,
I beg to differ.
In the script you will notice that the call to the plug in 'color to alpha' is preceeded by a ';'. This means that everything after the ';' on that line is treated as a comment and not processed.
Coders often do this while testing debugging so they can easilly toggle blocks of statements on or off.
fluffybunny
i stand corrected, thanks for clearing that up
yesterday i tried to learn a bit about script language via the console, but i find it pretty difficult, so good to have you here to translate stuff for me
at this point im not even 100% sure the satin technique i presented in the tutorial is correct, but the effect looks right, so ill leave it as it is right now
do you think you could have another go at the Jonathan Stipe version of the satin effect ?
because the result looks different, in comparison to the FX-Foundry that you already translated
here is the code:
(define (script-fu-layerfx-satin img
drawable
color
opacity
mode
offsetangle
offsetdist
size
contour
invert
merge)
(gimp-image-undo-group-start img)
(let* ((origfgcolor (car (gimp-palette-get-foreground)))
(origselection (car (gimp-selection-save img)))
(layername (car (gimp-drawable-get-name drawable)))
(growamt (math-ceil (/ size 2)))
(lyrgrowamt (math-round (* growamt 1.2)))
(satinlayer (car (gimp-layer-new img (+ (car (gimp-drawable-width drawable)) (* lyrgrowamt 2)) (+ (car (gimp-drawable-height drawable)) (* lyrgrowamt 2)) (cond ((= (car (gimp-image-base-type img)) 0) 1) ((= (car (gimp-image-base-type img)) 1) 3)) (string-append layername "-satin") 100 0)))
(satinmask 0)
(blacklayer 0)
(drwoffsets (gimp-drawable-offsets drawable))
(ang (* (* (+ offsetangle 180) -1) (/ (* 4 (atan 1.0)) 180)))
(offsetX (math-round (* offsetdist (cos ang))))
(offsetY (math-round (* offsetdist (sin ang))))
(alphaSel 0)
(layeraoffsets 0)
(layerboffsets 0)
(dx 0)
(dy 0)
(origmask 0)
(alphamask 0)
)
(add-over-layer img satinlayer drawable)
(gimp-layer-set-offsets satinlayer (- (car drwoffsets) lyrgrowamt) (- (cadr drwoffsets) lyrgrowamt))
(gimp-selection-all img)
(gimp-palette-set-foreground '(0 0 0))
(gimp-edit-fill satinlayer 0)
(gimp-selection-none img)
(gimp-selection-layer-alpha drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-selection-combine (car (gimp-layer-get-mask drawable)) 3)
)
(set! alphaSel (car (gimp-selection-save img)))
(draw-blurshape img satinlayer size growamt alphaSel 0)
(plug-in-autocrop-layer 1 img satinlayer)
(set! satinmask (car (gimp-layer-copy satinlayer 0)))
(add-over-layer img satinmask satinlayer)
(gimp-layer-translate satinlayer offsetX offsetY)
(gimp-layer-translate satinmask (* offsetX -1) (* offsetY -1))
(set! layeraoffsets (gimp-drawable-offsets satinlayer))
(set! layerboffsets (gimp-drawable-offsets satinmask))
(set! dx (- (max (car layeraoffsets) (car layerboffsets)) (min (car layeraoffsets) (car layerboffsets))))
(set! dy (- (max (cadr layeraoffsets) (cadr layerboffsets)) (min (cadr layeraoffsets) (cadr layerboffsets))))
(set! blacklayer (car (gimp-layer-new img (+ (car (gimp-drawable-width satinlayer)) dx) (+ (car (gimp-drawable-height satinlayer)) dy) (cond ((= (car (gimp-image-base-type img)) 0) 1) ((= (car (gimp-image-base-type img)) 1) 3)) (string-append layername "-satinblank") 100 0)))
(add-under-layer img blacklayer satinlayer)
(gimp-layer-set-offsets blacklayer (min (car layeraoffsets) (car layerboffsets)) (min (cadr layeraoffsets) (cadr layerboffsets)))
(gimp-selection-all img)
(gimp-palette-set-foreground '(0 0 0))
(gimp-edit-fill blacklayer 0)
(gimp-selection-none img)
(gimp-layer-set-mode satinmask 6)
(set! satinlayer (car (gimp-image-merge-down img satinlayer 0)))
(set! satinlayer (car (gimp-image-merge-down img satinmask 0)))
(gimp-drawable-set-name satinlayer (string-append layername "-satin"))
(if (> contour 0)
(begin
(apply-contour satinlayer 0 contour)
(gimp-selection-load alphaSel)
(gimp-selection-grow img size)
(gimp-selection-invert img)
(gimp-palette-set-foreground '(0 0 0))
(gimp-edit-fill satinlayer 0)
(gimp-selection-none img)
)
)
(if (= invert 1)
(gimp-invert satinlayer)
)
(set! satinmask (car (gimp-layer-create-mask satinlayer 5)))
(gimp-layer-add-mask satinlayer satinmask)
(gimp-selection-all img)
(gimp-palette-set-foreground color)
(gimp-edit-fill satinlayer 0)
(gimp-selection-none img)
(gimp-layer-set-opacity satinlayer opacity)
(gimp-layer-set-mode satinlayer (get-blending-mode mode))
(gimp-layer-resize satinlayer (car (gimp-drawable-width drawable)) (car (gimp-drawable-height drawable)) (- (car (gimp-drawable-offsets satinlayer)) (car drwoffsets)) (- (cadr (gimp-drawable-offsets satinlayer)) (cadr drwoffsets)))
(if (= merge 1)
(begin
(set! origmask (car (gimp-layer-get-mask drawable)))
(if (> origmask -1)
(begin
(set! origmask (car (gimp-channel-copy origmask)))
(gimp-layer-remove-mask drawable 1)
)
)
(set! alphamask (car (gimp-layer-create-mask drawable 3)))
(set! satinlayer (car (gimp-image-merge-down img satinlayer 0)))
(gimp-drawable-set-name satinlayer layername)
(gimp-layer-add-mask satinlayer alphamask)
(gimp-layer-remove-mask satinlayer 0)
(if (> origmask -1)
(gimp-layer-add-mask satinlayer origmask)
)
)
(begin
(gimp-selection-load alphaSel)
(gimp-selection-invert img)
(gimp-palette-set-foreground '(0 0 0))
(gimp-edit-fill satinmask 0)
)
)
(gimp-palette-set-foreground origfgcolor)
(gimp-selection-load origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)