home *** CD-ROM | disk | FTP | other *** search
GIMP Script-Fu Script | 2000-12-27 | 6.8 KB | 191 lines |
- ;
- ; burn-in-anim.scm V1.01 - script for the GIMP 1.1
- ;
- ; Copyright (C) 7/2000 Roland Berger (robe@align.de)
- ;
- ; Let text appear with a "burn-in" SFX and fade out.
- ; Source must be a (text) layer with alpha
- ;
- ; Homepage: http://fuchur.leute.server.de/burn_in/
- ; Copying: GNU Public License http://www.gnu.org
- ;
-
- (define (script-fu-burn-in-anim org-img org-layer glow-color bg-bl-color
- fadeout bl-width corona-width show-glow optimize speed)
-
- (let* (
- ;--- main variable: "bl-x" runs from 0 to layer-width
- (bl-x 0)
- (frame-nr 0)
- (old-fg (car (gimp-palette-get-foreground)))
- (old-bg (car (gimp-palette-get-background))) )
-
- (if (< speed 1)
- (set! speed (* -1 speed)) )
-
- ;--- work on a copy
- (set! img (car (gimp-channel-ops-duplicate org-img)))
- ; (gimp-image-disable-undo img)
- (gimp-image-undo-disable img)
- (if (> (car (gimp-drawable-type org-layer)) 1 )
- (gimp-convert-rgb img))
- (set! source-layer (aref (cadr (gimp-image-get-layers img)) 0 ))
- (set! source-layer-width (car (gimp-drawable-width source-layer)))
-
- ;--- hide any layer, cause we want to "merge visible layers" later
- (if (> (car (gimp-image-get-layers img)) 1)
- (gimp-message "Will only process top layer! Alpha mask required!"))
- (gimp-layer-set-visible source-layer FALSE)
-
- ;--- process layers with pixel-speed
- (while (< bl-x (+ source-layer-width bl-width))
- (set! bl-layer (car (gimp-layer-copy source-layer TRUE)))
- (set! bl-layer-name (string-append "fr-nr"
- (number->string frame-nr 10) ) )
-
- (gimp-image-add-layer img bl-layer -2)
- (gimp-layer-set-name bl-layer bl-layer-name)
- (gimp-layer-set-visible bl-layer TRUE)
- (gimp-layer-set-preserve-trans bl-layer TRUE)
- (gimp-layer-add-alpha bl-layer)
-
- ;--- add a blend mask
- ; (gimp-selection-layer-alpha img bl-layer)
- (gimp-selection-layer-alpha bl-layer)
- (set! bl-mask (car (gimp-layer-create-mask bl-layer BLACK-MASK)))
- (gimp-image-add-layer-mask img bl-layer bl-mask)
- (set! bl-layer-width source-layer-width)
- (set! bl-height (car (gimp-drawable-height bl-layer)))
-
- (set! bl-x-off (- bl-x bl-width))
- (set! bl-x-off (+ bl-x-off (car (gimp-drawable-offsets bl-layer))))
- (set! bl-y-off (cadr (gimp-drawable-offsets bl-layer)))
-
- ;--- add blend selection
- (gimp-rect-select img bl-x-off bl-y-off bl-width bl-height REPLACE 0 0)
- (if (= fadeout FALSE)
- (let* (
- (nofadeout-bl-x-off (car (gimp-drawable-offsets bl-layer)))
- (nofadeout-bl-width (+ nofadeout-bl-x-off bl-x)))
-
- (gimp-rect-select img nofadeout-bl-x-off bl-y-off
- nofadeout-bl-width bl-height REPLACE 0 0)))
-
- ;--- blend to trans
- (gimp-gradients-set-active "Default")
- (if (= fadeout TRUE)
- ; (gimp-blend img bl-mask CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE
- ; FALSE 0 0
- ; bl-x-off 0 (+ bl-x-off bl-width) 0) )
- (gimp-blend bl-mask CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE
- FALSE 0 0
- bl-x-off 0 (+ bl-x-off bl-width) 0) )
- (if (= fadeout FALSE)
- (begin
- (gimp-palette-set-foreground '(255 255 255))
- ; (gimp-bucket-fill img bl-mask FG-BUCKET-FILL NORMAL 100 255 0 0 0) ) )
- (gimp-bucket-fill bl-mask FG-BUCKET-FILL NORMAL 100 255 0 0 0) ) )
-
- (gimp-image-remove-layer-mask img bl-layer APPLY)
-
- ;--- add bright glow in front
- (if (= show-glow TRUE) (begin
- ;--- add some brightness to whole text
- (if (= fadeout TRUE)
- ; (gimp-brightness-contrast img bl-layer 100 0))
- (gimp-brightness-contrast bl-layer 100 0))
-
- ;--- blend glow color inside the letters
- (gimp-palette-set-foreground glow-color)
- ; (gimp-blend img bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
- ; FALSE 0 0
- ; (+ bl-x-off bl-width) 0
- ; (- (+ bl-x-off bl-width) (* corona-width 7)) 0)
- (gimp-blend bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
- FALSE 0 0
- (+ bl-x-off bl-width) 0
- (- (+ bl-x-off bl-width) (* corona-width 7)) 0)
-
- ;--- add a corona
- ; (gimp-selection-layer-alpha img bl-layer)
- (gimp-selection-layer-alpha bl-layer)
- (gimp-selection-sharpen img)
- (gimp-selection-grow img corona-width)
- (gimp-layer-set-preserve-trans bl-layer FALSE)
- (gimp-selection-feather img corona-width)
- (gimp-palette-set-foreground glow-color)
- ; (gimp-blend img bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
- ; FALSE 0 0
- ; (- (+ bl-x-off bl-width) corona-width) 0
- ; (- (+ bl-x-off bl-width) (* corona-width 5)) 0)
- ; ))
- (gimp-blend bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
- FALSE 0 0
- (- (+ bl-x-off bl-width) corona-width) 0
- (- (+ bl-x-off bl-width) (* corona-width 5)) 0)
- ))
-
- ;--- merge with background color
- (set! bg-layer (car (gimp-layer-copy source-layer FALSE)))
- (gimp-image-add-layer img bg-layer -1)
- (gimp-image-lower-layer img bg-layer)
- (set! bg-layer-name (string-append "bg-"
- (number->string frame-nr 10) ) )
- (gimp-layer-set-name bg-layer bg-layer-name)
- (gimp-layer-set-visible bg-layer TRUE)
- (gimp-palette-set-foreground bg-bl-color)
- (gimp-selection-all img)
- (gimp-layer-set-preserve-trans bg-layer FALSE)
- ; (gimp-bucket-fill img bg-layer FG-BUCKET-FILL NORMAL 100 255 0 0 0)
- (gimp-bucket-fill bg-layer FG-BUCKET-FILL NORMAL 100 255 0 0 0)
- (set! blended-layer (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))
- ;(set! blended-layer bl-layer)
- (gimp-layer-set-visible blended-layer FALSE)
-
- ;--- end of loop
- (set! frame-nr (+ frame-nr 1))
- (set! bl-x (+ bl-x speed))
- )
-
-
- (gimp-selection-none img)
- (gimp-image-remove-layer img source-layer)
- (gimp-image-set-filename img "burn-in")
-
- (if (= optimize TRUE) (begin
- ; (gimp-convert-indexed img TRUE 250)
- (gimp-convert-indexed img 1 0 253 0 1 "foo")
- (set! img-out (car (plug-in-animationoptimize 0 img bl-layer)))
- ))
-
- (gimp-layer-set-visible (aref (cadr (gimp-image-get-layers img)) 0 ) TRUE)
- ;(gimp-image-enable-undo img)
- (gimp-image-undo-enable img)
- (gimp-image-clean-all img)
- (set! img-display (car (gimp-display-new img)))
- (gimp-palette-set-foreground old-fg)
- (gimp-palette-set-background old-bg)
-
- (gimp-displays-flush)
-
- ))
-
- (script-fu-register "script-fu-burn-in-anim"
- "<Image>/Script-Fu/Animators/Burn-In"
- "Burn-in like SFX from a text layer with alpha"
- "Roland Berger robe@align.de"
- "Roland Berger"
- "July 2000"
- "RGBA GRAYA INDEXEDA"
- SF-IMAGE "The Image" 0
- SF-DRAWABLE "Layer to animate" 0
- SF-COLOR "Glow color" '(255 255 255)
- SF-COLOR "BG color" '(0 0 0)
- SF-TOGGLE "Fadeout?" TRUE
- SF-VALUE "Fadeout width" "300"
- SF-VALUE "Corona width" "15"
- SF-TOGGLE "Add glowing?" TRUE
- SF-TOGGLE "Prepare saving as GIF?" FALSE
- SF-VALUE "Pixel/frame" "200"
- )
-