home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 February / PCWorld_2001-02_cd.bin / Software / Topware / gimp / gimp-setup-20001226.exe / Main / burn-in-anim-11a.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2000-12-27  |  6.8 KB  |  191 lines

  1. ;
  2. ;  burn-in-anim.scm  V1.01  -  script for the GIMP 1.1
  3. ;
  4. ;  Copyright (C) 7/2000 Roland Berger (robe@align.de)
  5. ;  Let text appear with a "burn-in" SFX and fade out.
  6. ;  Source must be a (text) layer with alpha
  7. ;
  8. ;  Homepage: http://fuchur.leute.server.de/burn_in/
  9. ;  Copying: GNU Public License http://www.gnu.org
  10. ;
  11.  
  12. (define (script-fu-burn-in-anim org-img org-layer glow-color bg-bl-color
  13.     fadeout bl-width corona-width show-glow optimize speed)
  14.  
  15. (let* (
  16.     ;--- main variable: "bl-x" runs from 0 to layer-width
  17.     (bl-x 0)
  18.     (frame-nr 0)
  19.     (old-fg (car (gimp-palette-get-foreground)))
  20.     (old-bg (car (gimp-palette-get-background))) )
  21.  
  22.     (if (< speed 1)
  23.     (set! speed (* -1 speed)) )
  24.  
  25. ;--- work on a copy
  26.     (set! img (car (gimp-channel-ops-duplicate org-img)))
  27. ;    (gimp-image-disable-undo img) 
  28.     (gimp-image-undo-disable img) 
  29.     (if (> (car (gimp-drawable-type org-layer)) 1 )
  30.         (gimp-convert-rgb img))
  31.     (set! source-layer (aref (cadr (gimp-image-get-layers img)) 0 ))
  32.     (set! source-layer-width (car (gimp-drawable-width  source-layer)))
  33.  
  34. ;--- hide any layer, cause we want to "merge visible layers" later
  35.     (if (> (car (gimp-image-get-layers img)) 1)
  36.     (gimp-message "Will only process top layer! Alpha mask required!"))
  37.     (gimp-layer-set-visible source-layer FALSE)
  38.  
  39. ;--- process layers with pixel-speed
  40. (while (< bl-x (+ source-layer-width bl-width))
  41.     (set! bl-layer (car (gimp-layer-copy source-layer TRUE)))
  42.     (set! bl-layer-name (string-append "fr-nr"
  43.     (number->string frame-nr 10) ) )
  44.  
  45.     (gimp-image-add-layer img bl-layer -2)
  46.     (gimp-layer-set-name bl-layer bl-layer-name)
  47.     (gimp-layer-set-visible bl-layer TRUE)
  48.     (gimp-layer-set-preserve-trans bl-layer TRUE)
  49.     (gimp-layer-add-alpha bl-layer)
  50.  
  51. ;--- add a blend mask
  52. ;    (gimp-selection-layer-alpha img bl-layer)
  53.     (gimp-selection-layer-alpha bl-layer)
  54.     (set! bl-mask (car (gimp-layer-create-mask bl-layer BLACK-MASK)))
  55.     (gimp-image-add-layer-mask img bl-layer bl-mask)
  56.     (set! bl-layer-width source-layer-width)
  57.     (set! bl-height      (car (gimp-drawable-height bl-layer)))
  58.  
  59.     (set! bl-x-off (- bl-x     bl-width))
  60.     (set! bl-x-off (+ bl-x-off (car  (gimp-drawable-offsets bl-layer))))
  61.     (set! bl-y-off             (cadr (gimp-drawable-offsets bl-layer)))
  62.  
  63. ;--- add blend selection
  64.     (gimp-rect-select img bl-x-off bl-y-off bl-width bl-height REPLACE 0 0)
  65.     (if (= fadeout FALSE)
  66.     (let* (
  67.         (nofadeout-bl-x-off (car (gimp-drawable-offsets bl-layer)))
  68.         (nofadeout-bl-width (+ nofadeout-bl-x-off bl-x)))
  69.         
  70.         (gimp-rect-select img nofadeout-bl-x-off bl-y-off
  71.         nofadeout-bl-width bl-height REPLACE 0 0)))
  72.  
  73. ;--- blend to trans
  74.     (gimp-gradients-set-active "Default")
  75.     (if (= fadeout TRUE)
  76. ;        (gimp-blend img bl-mask CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE
  77. ;            FALSE 0 0
  78. ;        bl-x-off 0 (+ bl-x-off bl-width) 0) )
  79.         (gimp-blend bl-mask CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE
  80.             FALSE 0 0
  81.         bl-x-off 0 (+ bl-x-off bl-width) 0) )
  82.     (if (= fadeout FALSE)
  83.     (begin
  84.     (gimp-palette-set-foreground '(255 255 255))
  85. ;    (gimp-bucket-fill img bl-mask FG-BUCKET-FILL NORMAL 100 255 0 0 0) ) )
  86.     (gimp-bucket-fill bl-mask FG-BUCKET-FILL NORMAL 100 255 0 0 0) ) )
  87.  
  88.     (gimp-image-remove-layer-mask img bl-layer APPLY)
  89.  
  90. ;--- add bright glow in front
  91. (if (= show-glow TRUE) (begin
  92.     ;--- add some brightness to whole text
  93.     (if (= fadeout TRUE)
  94. ;    (gimp-brightness-contrast img bl-layer 100 0))
  95.     (gimp-brightness-contrast bl-layer 100 0))
  96.  
  97.     ;--- blend glow color inside the letters
  98.     (gimp-palette-set-foreground glow-color)
  99. ;    (gimp-blend img bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
  100. ;            FALSE 0 0
  101. ;           (+ bl-x-off bl-width)                      0
  102. ;        (- (+ bl-x-off bl-width) (* corona-width 7)) 0)
  103.     (gimp-blend bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
  104.             FALSE 0 0
  105.            (+ bl-x-off bl-width)                      0
  106.         (- (+ bl-x-off bl-width) (* corona-width 7)) 0)
  107.  
  108.     ;--- add a corona
  109. ;    (gimp-selection-layer-alpha img bl-layer)
  110.     (gimp-selection-layer-alpha bl-layer)
  111.     (gimp-selection-sharpen img)
  112.     (gimp-selection-grow img corona-width)
  113.     (gimp-layer-set-preserve-trans bl-layer FALSE)
  114.     (gimp-selection-feather img corona-width)
  115.     (gimp-palette-set-foreground glow-color)
  116. ;    (gimp-blend img bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
  117. ;            FALSE 0 0
  118. ;        (- (+ bl-x-off bl-width) corona-width) 0
  119. ;        (- (+ bl-x-off bl-width) (* corona-width 5)) 0)
  120. ;    ))
  121.     (gimp-blend bl-layer FG-TRANS NORMAL LINEAR 100 0 REPEAT-NONE
  122.             FALSE 0 0
  123.         (- (+ bl-x-off bl-width) corona-width) 0
  124.         (- (+ bl-x-off bl-width) (* corona-width 5)) 0)
  125.     ))
  126.  
  127. ;--- merge with background color
  128.     (set! bg-layer (car (gimp-layer-copy source-layer FALSE)))
  129.     (gimp-image-add-layer img bg-layer -1)
  130.     (gimp-image-lower-layer img bg-layer)
  131.     (set! bg-layer-name (string-append "bg-"
  132.     (number->string frame-nr 10) ) )
  133.     (gimp-layer-set-name bg-layer bg-layer-name)
  134.     (gimp-layer-set-visible bg-layer TRUE)
  135.     (gimp-palette-set-foreground bg-bl-color)
  136.     (gimp-selection-all img)
  137.     (gimp-layer-set-preserve-trans bg-layer FALSE)
  138. ;    (gimp-bucket-fill img bg-layer FG-BUCKET-FILL NORMAL 100 255 0 0 0)
  139.     (gimp-bucket-fill bg-layer FG-BUCKET-FILL NORMAL 100 255 0 0 0)
  140.     (set! blended-layer (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))
  141.     ;(set! blended-layer bl-layer)
  142.     (gimp-layer-set-visible blended-layer FALSE)
  143.  
  144. ;--- end of loop
  145.     (set! frame-nr (+ frame-nr 1))
  146.     (set! bl-x     (+ bl-x speed))
  147. )
  148.  
  149.  
  150. (gimp-selection-none img)
  151. (gimp-image-remove-layer img source-layer)
  152. (gimp-image-set-filename img "burn-in")
  153.  
  154. (if (= optimize TRUE) (begin
  155. ;    (gimp-convert-indexed img TRUE 250)
  156.     (gimp-convert-indexed img 1 0 253 0 1 "foo")
  157.     (set! img-out (car (plug-in-animationoptimize 0 img bl-layer)))
  158.     ))
  159.  
  160. (gimp-layer-set-visible (aref (cadr (gimp-image-get-layers img)) 0 ) TRUE)
  161. ;(gimp-image-enable-undo img)
  162. (gimp-image-undo-enable img)
  163. (gimp-image-clean-all img)
  164. (set! img-display (car (gimp-display-new img)))
  165. (gimp-palette-set-foreground old-fg)
  166. (gimp-palette-set-background old-bg)
  167.  
  168. (gimp-displays-flush)
  169.  
  170. ))
  171.  
  172. (script-fu-register "script-fu-burn-in-anim"
  173.             "<Image>/Script-Fu/Animators/Burn-In"
  174.             "Burn-in like SFX from a text layer with alpha"
  175.             "Roland Berger robe@align.de"
  176.             "Roland Berger"
  177.             "July 2000"
  178.             "RGBA GRAYA INDEXEDA"
  179.             SF-IMAGE "The Image" 0
  180.             SF-DRAWABLE "Layer to animate" 0
  181.             SF-COLOR "Glow color" '(255 255 255)
  182.             SF-COLOR "BG color" '(0 0 0)
  183.             SF-TOGGLE "Fadeout?" TRUE
  184.             SF-VALUE "Fadeout width" "300"
  185.             SF-VALUE "Corona width" "15"
  186.             SF-TOGGLE "Add glowing?" TRUE
  187.             SF-TOGGLE "Prepare saving as GIF?" FALSE
  188.             SF-VALUE "Pixel/frame" "200"
  189. )
  190.