; ; $Id: dlblend.scm,v 1.2 1998/01/04 10:23:49 dl Exp $ ; ; (C) 1998 - Laurent Demailly - L@Demailly.com ; ; What this script does : ; ----------------------- ; Makes a copy of your image and creates an animation of the active layer ; + The image is assumed to have only 1 layer (with transparency) ; + A custom gradient must be selected using the gradient editor ; it is assumed to be suitable for bi-linear application ; (like Flare_Radial_102) ; + The desired background color must be set (to get proper ; anti aliasing) ; ; 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. ; (define (script-fu-dlblendanim img drawable num-frames gradient span rel-y1 rel-y2 anti-aliasing bg-remove threshold ) (let* ((num-frames (max 1 num-frames)) (remaining-frames (+ num-frames (* 2 span))) (image (car (gimp-channel-ops-duplicate img))) (height (car (gimp-image-height image))) (width (car (gimp-image-width image))) (y1 (* height rel-y1)) (y2 (* height rel-y2)) (offset (/ width num-frames)) (x (- (* offset span))) (bg-layer FALSE) (color (car (gimp-palette-get-background))) ) (gimp-image-disable-undo image) (set! source-layer (car (gimp-image-get-active-layer image))) (gimp-layer-set-visible source-layer 0) (while (> remaining-frames 0) (set! anim-layer (car (gimp-layer-copy source-layer TRUE))) (gimp-layer-set-preserve-trans anim-layer TRUE) (set! bg-layer (car (gimp-layer-new image width height RGB_IMAGE "bg" 100 NORMAL))) (gimp-drawable-fill bg-layer BG-IMAGE-FILL) (gimp-image-add-layer image bg-layer -1) (gimp-image-add-layer image anim-layer -1) (gimp-layer-set-visible bg-layer 1) (gimp-layer-set-visible anim-layer 1) (set! layer-name (string-append "Frame " (number->string (- (+ num-frames span 1) remaining-frames) 10))) (gimp-layer-set-name anim-layer layer-name) (gimp-layer-set-name bg-layer layer-name) (gimp-blend image anim-layer CUSTOM NORMAL gradient 100 ; opacity 0. ; offset ? REPEAT-NONE anti-aliasing ; anti aliasing 3 0.2 x y1 (+ x (* span offset)) y2 ) (gimp-image-merge-visible-layers image 0) (set! anim-layer (aref (cadr (gimp-image-get-layers image)) 0)) (if (= bg-remove TRUE) (begin (gimp-by-color-select image anim-layer color threshold REPLACE FALSE ; anti aliasing FALSE ; feather 0 ; feather radius FALSE ; composite/merged ) (gimp-edit-clear image anim-layer) (gimp-selection-none image) ) ) (gimp-layer-set-visible anim-layer 0) (set! remaining-frames (- remaining-frames 1)) (set! x (+ x offset)) ) (gimp-image-remove-layer image source-layer) (gimp-layer-set-visible anim-layer 1) (gimp-image-enable-undo image) (gimp-display-new image))) (script-fu-register "script-fu-dlblendanim" "/Script-Fu/Animators/DlBlend" "Animates an image by moving gradient over it" "Laurent Demailly (L@demailly.com)" "Laurent Demailly" "1/3/98" "RGBA" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-VALUE "Number of Frames" "12" SF-VALUE "Gradient type" "BILINEAR" SF-VALUE "Span" "3" SF-VALUE "Relative Y1" ".4" SF-VALUE "Relative Y2" ".6" SF-TOGGLE "AntiAliasing" 0 SF-TOGGLE "Remove Background" 1 SF-VALUE "Threshold" "10" )