; Highlight rel 0.04 ; Created by Graechan using techniques from Esper ; Comments directed to http://gimpchat.com or http://gimpscripts.com ; ; License: GPLv3 ; 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 3 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. ; ; To view a copy of the GNU General Public License ; visit: http://www.gnu.org/licenses/gpl.html ; ; ; ------------ ;| Change Log | ; ------------ ; Rel 0.01 - Initial Release ; Rel 0.02 - (Updated By GnuTux) ; Highlight Color Option ; Highlight Opacity Option ; Merge Option ; Add Bump Map Parameters For More Granular Control Over Highlights ; Rel 0.03 - Highlight Layer Blur Option ; Rel 0.04 - Modified to run on 2.6,2.8 and 2.10 ; ; ;Helper function to check the gimp version (define (gimp-version-meets? check) (let ((c (map string->number (strbreakup check "."))) (v (map string->number (strbreakup (car (gimp-version)) ".")))) (if (> (car v) (car c)) #t (if (< (car c) (car v)) #f (if (> (cadr v) (cadr c)) #t (if (< (cadr v) (cadr c)) #f (if (>= (caddr v) (caddr c)) #t #f))))))) ; ; ; Include layer Procedure (define (include-layer image newlayer oldlayer stack) ;stack 0=above 1=below (cond ((defined? 'gimp-image-get-item-position) ;test for 2.8 compatability (gimp-image-insert-layer image newlayer (car (gimp-item-get-parent oldlayer)) (+ (car (gimp-image-get-layer-position image oldlayer)) stack)) ;For GIMP 2.8 ) (else (gimp-image-add-layer image newlayer (+ (car (gimp-image-get-layer-position image oldlayer)) stack)) ;For GIMP 2.6 ) ) ;end cond ) ;end add layer procedure ; ; (define (script-fu-highlight image layer hl-color hl-dist hl-opacity hl-blur bump-azimuth bump-elevation bump-depth bump-type bump-invert hl-merge) (gimp-image-undo-group-start image) (let* ( (width (car (gimp-image-width image))) (height (car (gimp-image-height image))) (ambient 255) (highlight (car (gimp-layer-new image width height RGBA-IMAGE "Highlight Layer" 100 0))) (alpha (car (gimp-drawable-has-alpha layer))) (sel (car (gimp-selection-is-empty image))) (layer-name (cond ((defined? 'gimp-image-get-item-position) (car (gimp-item-get-name layer))) (else (car (gimp-drawable-get-name layer))))) (highlight-channel 0) (ver 2.8) ) (if (gimp-version-meets? "2.10.0") (begin ;then (set! ambient .255))) (cond ((not (defined? 'gimp-image-get-item-position)) (set! ver 2.6))) ;define the gimp version (gimp-context-push) (gimp-context-set-paint-method "gimp-paintbrush") (cond ((defined? 'gimp-context-set-dynamics) (gimp-context-set-dynamics "Dynamics Off"))) (gimp-context-set-foreground '(0 0 0)) (gimp-context-set-background '(255 255 255)) (if (= alpha FALSE) (gimp-layer-add-alpha layer)) ;;;;check that a selection was made if not make one (if (= sel TRUE) (begin (cond ((= ver 2.8) (gimp-image-select-item image 2 layer)) (else (gimp-selection-layer-alpha layer)) ) ;endcond ) ) ; ;;;;begin the script ; (include-layer image highlight layer 0) ;stack 0=above 1=below (gimp-selection-shrink image hl-dist) (gimp-context-set-foreground '(128 128 128)) (gimp-edit-fill highlight (cond ((gimp-version-meets? "2.10.0") FILL-FOREGROUND ) (else FOREGROUND-FILL))) ;;;;create highlight-channel (gimp-selection-load highlight-channel) (set! highlight-channel (car (gimp-selection-save image))) (cond ((= ver 2.8) (gimp-item-set-name highlight-channel "highlight-channel")) (else (gimp-drawable-set-name highlight-channel "highlight-channel")) ) ;endcond (gimp-selection-none image) (plug-in-gauss-rle2 RUN-NONINTERACTIVE image highlight-channel 5 5) (gimp-image-set-active-layer image highlight) ; ; Bump the highlight layer ; (plug-in-bump-map 1 ; Interactive (0), non-interactive (1) image ; Input image highlight ; Input drawable (incoming layer) highlight-channel ; Bumpmap drawable (incoming layer) bump-azimuth ; Azimuth (float) bump-elevation ; Elevation (float) bump-depth ; Depth 0 ; X offset 0 ; Y offset 0 ; Level that full transparency should represent ambient ; Ambient lighting factor TRUE ; Compensate for darkening bump-invert ; Invert bumpmap toggle bump-type) ; Type of map (0=linear, 1=spherical, 2=sinusoidal) (plug-in-colortoalpha RUN-NONINTERACTIVE image highlight '(128 128 128)) ;;;;finish the script ; ; Set Highlight Color & Opacity ; (plug-in-colorify RUN-NONINTERACTIVE image highlight hl-color) ; Set Highlight Color (gimp-layer-set-opacity highlight hl-opacity) ; Set Highlight Opacity ; ; Blur Highlight Layer ; (if (> hl-blur 0) (begin (plug-in-gauss 1 image highlight hl-blur hl-blur 1) ) ) ; ; Merge Highlight Layer ; (if (= hl-merge TRUE) (begin (set! layer (car (gimp-image-merge-down image highlight EXPAND-AS-NECESSARY))) ) ) (cond ((= ver 2.8) (gimp-item-set-name layer layer-name)) (else (gimp-drawable-set-name layer layer-name)) ) ;endcond (gimp-image-remove-channel image highlight-channel) (gimp-displays-flush) (gimp-image-undo-group-end image) (gimp-context-pop) ) ) (script-fu-register "script-fu-highlight" "Highlight" "Instructions" "Graechan" "Graechan - http://gimpchat.com" "2012" "RGB*" SF-IMAGE "image" 0 SF-DRAWABLE "drawable" 0 SF-COLOR "Highlight Color" '(255 255 255) SF-ADJUSTMENT "Highlight Offset" '(0 0 20 1 2 0 0) SF-ADJUSTMENT "Highlight Opacity" '(100 1 100 1 10 0 0) SF-ADJUSTMENT "Highlight Blur" '(0 0 30 1 2 0 0) SF-ADJUSTMENT "Bump Azimuth" '(135 0 360 1 45 2 0) SF-ADJUSTMENT "Bump Elevation" '(30 .5 90 .1 1 2 0) SF-ADJUSTMENT "Bump Depth" '(35 1 65 1 5 0 0) SF-OPTION "Bump Curve" '("Linear" "Spherical" "Sinusoidal") SF-TOGGLE "Invert Bump" FALSE SF-TOGGLE "Merge Highlight Layer" FALSE ) (script-fu-menu-register "script-fu-highlight" "/Filters/Light and Shadow")