; The GIMP -- an image manipulation program ; Copyright (C) 1995 Spencer Kimball and Peter Mattis ; ; 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 2 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. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; This is a Script-Fu for The GIMP, for simplifying the process of rotoscoping lightsabre blades ; Copyright (C) Lee Mulvogue (lee@baudalign.com / www.baudalign.com) ; Send any bug reports, suggestions, fixes, etc., to ; lee@baudalign.com ; Revision History ; v1.3 Added Mid Blue preset corona colour ; v1.2 Added a few more preset corona colours ; v1.1 Fixed(?) some layer bugs, cleaned up some artifact stuff ; v1.0 (unreleased) worked, but had a few bugs ; v1.2 Fixed by Rod D of Gimpchat.com to run in Gimp-2.38 RC1 ; To Do ; Figure out why the background doesn't toggle correctly sometimes (define (script-fu-blade-roto image drawable grow-size size preset-color use-custom corona-color flare-fx lighten-corona flatten) (let* ( (type (car (gimp-drawable-type-with-alpha drawable))) (image-width (car (gimp-image-width image))) (image-height (car (gimp-image-height image))) (old-bg (car (gimp-palette-get-background))) (from-selection 0) (active-selection 0) (bg-layer (car (gimp-image-active-drawable image))) (glowbg-layer 0) (glow-layer 0) (blade-layer 0) (glow2-layer 0) (blade-and-corona 0) (feather3 (/ size 1)) (feather2 (/ size 2)) (feather1 (/ size 10)) ) (gimp-undo-push-group-start image) (if (= use-custom FALSE) (if (= preset-color 0) ;Red (set! corona-color '(255 0 0))) ) (if (= use-custom FALSE) (if (= preset-color 1) ;Ice Blue (set! corona-color '(0 174 239))) ) (if (= use-custom FALSE) (if (= preset-color 2) ;Mid Blue (set! corona-color '(0 125 255))) ) (if (= use-custom FALSE) (if (= preset-color 3) ;Blue (set! corona-color '(0 0 255))) ) (if (= use-custom FALSE) (if (= preset-color 4) ;Green (set! corona-color '(0 255 0))) ) (if (= use-custom FALSE) (if (= preset-color 5) ;Violet (set! corona-color '(255 0 255))) ) (if (= use-custom FALSE) (if (= preset-color 6) ;Rogue Blue (set! corona-color '(59 0 255))) ) (if (= use-custom FALSE) (if (= preset-color 7) ;Purple (set! corona-color '(143 0 255))) ) (if (= use-custom FALSE) (if (= preset-color 8) ;Yellow (set! corona-color '(255 255 0))) ) (if (= use-custom FALSE) (if (= preset-color 9) ;Orange (set! corona-color '(255 127 0))) ) (if (= use-custom FALSE) (if (= preset-color 10) ;Silver (set! corona-color '(212 212 212))) ) ; bg glow layer (set! glowbg-layer (car (gimp-layer-new image image-width image-height type "Glow" 50 0))) (gimp-image-add-layer image glowbg-layer -1) ; corona layer (set! glow-layer (car (gimp-layer-new image image-width image-height type "Corona" 100 0))) (gimp-image-add-layer image glow-layer -1) ; blade layer (set! blade-layer (car (gimp-layer-new image image-width image-height type "Blade" 100 0))) (gimp-image-add-layer image blade-layer -1) ; corona empasis layer (set! glow2-layer (car (gimp-layer-new image image-width image-height type "Corona emphasis" 80 13))) (gimp-image-add-layer image glow2-layer -1) (set! from-selection TRUE) (set! active-selection (car (gimp-selection-save image))) (gimp-selection-load active-selection) (gimp-selection-feather image feather1) (gimp-drawable-fill blade-layer 3) (gimp-palette-set-background '(255 255 255)) (gimp-edit-fill blade-layer 1) (gimp-edit-fill blade-layer 1) (gimp-selection-none image) ; Repeats fill to give whiter blade (gimp-selection-load active-selection) (gimp-selection-grow image grow-size) (gimp-selection-feather image feather2) (gimp-drawable-fill glow2-layer 3) (gimp-palette-set-background corona-color) (gimp-edit-fill glow2-layer 1) (gimp-selection-none image) ; Colour overlay to emphasise corona colour (gimp-selection-load active-selection) (gimp-selection-grow image grow-size) (gimp-selection-feather image feather2) (gimp-drawable-fill glow-layer 3) (gimp-palette-set-background corona-color) (gimp-edit-fill glow-layer 1) (gimp-selection-none image) ; Tight corona colouring (gimp-selection-load active-selection) (gimp-selection-grow image 4) (gimp-selection-feather image feather3) (gimp-drawable-fill glowbg-layer 3) (gimp-palette-set-background corona-color) (gimp-edit-fill glowbg-layer 1) (gimp-selection-none image) ; Loose corona glow colouring (if (= lighten-corona TRUE) (begin (gimp-hue-saturation glow-layer 0 0 100 0) (gimp-hue-saturation glowbg-layer 0 0 100 0))) ; lighten corona for more realistic fx (if (= flare-fx TRUE) (begin (gimp-layer-set-visible bg-layer FALSE) (gimp-layer-set-visible glowbg-layer FALSE) (gimp-layer-set-visible glow2-layer FALSE) (gimp-layer-set-visible blade-layer TRUE) (gimp-layer-set-visible glow-layer TRUE) (set! blade-and-corona (car (gimp-image-merge-visible-layers image 1))) (plug-in-flarefx 0 image blade-and-corona 128 128))) ; emitter flare on now merged blade and corona layers (gimp-layer-set-visible bg-layer TRUE) (gimp-layer-set-visible glowbg-layer TRUE) (gimp-layer-set-visible glow2-layer TRUE) (if (= flare-fx FALSE) (begin (gimp-layer-set-visible blade-layer TRUE) (gimp-layer-set-visible glow-layer TRUE))) ; make all layers visible (if (= flatten TRUE) (gimp-image-flatten image bg-layer)) ; flatten image (gimp-image-set-active-layer image drawable) (gimp-palette-set-background old-bg) (gimp-undo-push-group-end image) (gimp-displays-flush))) (script-fu-register "script-fu-blade-roto" _"/Script-Fu/Lightsabre/Blade-Rotoscope..." "Rotoscope lightsabre blades from selection. Before running, check the co-ords of your emitter if you want Emitter Flare (Gives a slightly flaring effect at the emmitter end). Grow size should only need to be adjusted for distant or close-up shots. FX Size of 50 is about right for blades about 5 pixels wide (150-250 pixels long). FX Size of 40-or-so is best for anything under that. Increase FX Size for close-up or high-res shots. Lighten Corona gives what seems to be the closest to the latest publicity shots, but some movie shots have darker (more colour-intense) coronas. You may also need to toggle the bg image's visibility afterwards - it seems to be a bit buggy." "Lee Mulvogue " "Lee Mulvogue" "2002" "RGB* GRAY*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-ADJUSTMENT _"Grow Size" '(5 0 250 1 10 0 1) SF-ADJUSTMENT _"FX Size (pixels * 10)" '(50 2 1000 1 10 0 1) SF-OPTION _"Preset Corona Colours" '(_"Red" _"Ice Blue" _"Mid Blue" _"Blue" _"Green" _"Violet" _"Rogue Blue" _"Purple" _"Yellow" _"Orange" _"Silver") SF-TOGGLE _"Use Custom Color" FALSE SF-COLOR _"Custom Color" '(0 174 239) SF-TOGGLE _"Emitter Flare" TRUE SF-TOGGLE _"Lighten Corona" TRUE SF-TOGGLE _"Flatten Image" FALSE )