home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / Topware / gimp / gimp-setup-20001226.exe / Main / coolmetal-logo.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2000-12-27  |  5.7 KB  |  150 lines

  1. ;  COOL-METAL
  2. ;  Create a text effect that looks like metal with a reflection of
  3. ;  the horizon, a reflection of the text in the mirrored ground, and
  4. ;  an interesting dropshadow
  5. ;  This script was inspired by Rob Malda's 'coolmetal.gif' graphic
  6.  
  7. (define (apply-cool-metal-logo-effect img
  8.                       logo-layer
  9.                       size
  10.                       bg-color
  11.                       gradient)
  12.   (let* ((feather (/ size 5))
  13.      (smear 7.5)
  14.      (period (/ size 3))
  15.      (amplitude (/ size 40))
  16.      (shrink (+ 1 (/ size 30)))
  17.      (depth (/ size 20))
  18.      (width (car (gimp-drawable-width logo-layer)))
  19.      (height (car (gimp-drawable-height logo-layer)))
  20.      (img-width (+ width (* 0.15 height) 10))
  21.      (img-height (+ (* 1.85 height) 10))
  22.      (bg-layer (car (gimp-layer-new img img-width img-height RGB_IMAGE "Background" 100 NORMAL)))
  23.      (shadow-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "Shadow" 100 NORMAL)))
  24.      (reflect-layer (car (gimp-layer-new img width height RGBA_IMAGE "Reflection" 100 NORMAL)))
  25.      (channel 0)
  26.      (fs 0)
  27.      (layer-mask 0)
  28.      (old-gradient (car (gimp-gradients-get-active)))
  29.      (old-fg (car (gimp-palette-get-foreground)))
  30.      (old-bg (car (gimp-palette-get-background))))
  31.     (gimp-image-resize img img-width img-height 0 0)
  32.     (gimp-image-add-layer img bg-layer 1)
  33.     (gimp-image-add-layer img reflect-layer 1)
  34.     (gimp-image-add-layer img shadow-layer 1)
  35.     (gimp-layer-set-preserve-trans logo-layer TRUE)
  36.  
  37.     (gimp-palette-set-background bg-color)
  38.     (gimp-edit-fill bg-layer BG-IMAGE-FILL)
  39.     (gimp-edit-clear reflect-layer)
  40.     (gimp-palette-set-background '(0 0 0))
  41.     (gimp-edit-fill shadow-layer BG-IMAGE-FILL)
  42.  
  43.     (gimp-gradients-set-active gradient)
  44.     (gimp-blend logo-layer CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE FALSE 0 0 0 0 0 (+ height 5))
  45.     (gimp-rect-select img 0 (- (/ height 2) feather) img-width (* 2 feather) REPLACE 0 0)
  46.     (plug-in-gauss-iir 1 img logo-layer smear TRUE TRUE)
  47.     (gimp-selection-none img)
  48.     (plug-in-ripple 1 img logo-layer period amplitude 1 0 1 TRUE FALSE)
  49.     (gimp-layer-translate logo-layer 5 5)
  50.     (gimp-layer-resize logo-layer img-width img-height 5 5)
  51.  
  52.     (gimp-selection-layer-alpha logo-layer)
  53.     (set! channel (car (gimp-selection-save img)))
  54.     (gimp-selection-shrink img shrink)
  55.     (gimp-selection-invert img)
  56.     (plug-in-gauss-rle 1 img channel feather TRUE TRUE)
  57.     (gimp-selection-layer-alpha logo-layer)
  58.     (gimp-selection-invert img)
  59.     (gimp-palette-set-background '(0 0 0))
  60.     (gimp-edit-fill channel BG-IMAGE-FILL)
  61.     (gimp-selection-none img)
  62.  
  63.     (plug-in-bump-map 1 img logo-layer channel 135 45 depth 0 0 0 0 FALSE FALSE 0)
  64.  
  65.     (gimp-selection-layer-alpha logo-layer)
  66.     (set! fs (car (gimp-selection-float shadow-layer 0 0)))
  67.     (gimp-edit-clear shadow-layer)
  68.     (gimp-perspective fs FALSE
  69.               (+ 5 (* 0.15 height)) (- height (* 0.15 height))
  70.               (+ 5 width (* 0.15 height)) (- height (* 0.15 height))
  71.               5 height
  72.               (+ 5 width) height)
  73.     (gimp-floating-sel-anchor fs)
  74.     (plug-in-gauss-rle 1 img shadow-layer smear TRUE TRUE)
  75.  
  76.     (gimp-rect-select img 5 5 width height REPLACE FALSE 0)
  77.     (gimp-edit-copy logo-layer)
  78.     (set! fs (car (gimp-edit-paste reflect-layer FALSE)))
  79.     (gimp-floating-sel-anchor fs)
  80.     (gimp-scale reflect-layer FALSE 0 0 width (* 0.85 height))
  81.     (gimp-flip reflect-layer 1)
  82.     (gimp-layer-set-offsets reflect-layer 5 (+ 3 height))
  83.  
  84.     (set! layer-mask (car (gimp-layer-create-mask reflect-layer WHITE-MASK)))
  85.     (gimp-image-add-layer-mask img reflect-layer layer-mask)
  86.     (gimp-palette-set-foreground '(255 255 255))
  87.     (gimp-palette-set-background '(0 0 0))
  88.     (gimp-blend layer-mask FG-BG-RGB NORMAL LINEAR 100 0 REPEAT-NONE
  89.         FALSE 0 0 0 (- (/ height 2)) 0 height)
  90.  
  91.     (gimp-image-remove-channel img channel)
  92.  
  93.     (gimp-gradients-set-active old-gradient)
  94.     (gimp-palette-set-background old-bg)
  95.     (gimp-palette-set-foreground old-fg)))
  96.  
  97.  
  98. (define (script-fu-cool-metal-logo-alpha img
  99.                      logo-layer
  100.                      size
  101.                      bg-color
  102.                      gradient)
  103.   (begin
  104.     (gimp-undo-push-group-start img)
  105.     (apply-cool-metal-logo-effect img logo-layer size bg-color gradient)
  106.     (gimp-undo-push-group-end img)
  107.     (gimp-displays-flush)))
  108.  
  109. (script-fu-register "script-fu-cool-metal-logo-alpha"
  110.             _"<Image>/Script-Fu/Alpha to Logo/Cool Metal..."
  111.             "Metallic logos with reflections and perspective shadows"
  112.             "Spencer Kimball & Rob Malda"
  113.             "Spencer Kimball & Rob Malda"
  114.             "1997"
  115.             "RGBA"
  116.                     SF-IMAGE      "Image" 0
  117.                     SF-DRAWABLE   "Drawable" 0
  118.             SF-ADJUSTMENT _"Effect Size (pixels)" '(100 2 1000 1 10 0 1)
  119.             SF-COLOR      _"Background Color" '(255 255 255)
  120.             SF-GRADIENT   _"Gradient" "Horizon_1"
  121.             )
  122.  
  123.  
  124. (define (script-fu-cool-metal-logo text
  125.                    size
  126.                    font
  127.                    bg-color
  128.                    gradient)
  129.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  130.      (text-layer (car (gimp-text-fontname img -1 0 0 text 0 TRUE size PIXELS font))))
  131.     (gimp-image-undo-disable img)
  132.     (gimp-layer-set-name text-layer text)
  133.     (apply-cool-metal-logo-effect img text-layer size bg-color gradient)
  134.     (gimp-image-undo-enable img)
  135.     (gimp-display-new img)))
  136.  
  137. (script-fu-register "script-fu-cool-metal-logo"
  138.             _"<Toolbox>/Xtns/Script-Fu/Logos/Cool Metal..."
  139.             "Metallic logos with reflections and perspective shadows"
  140.             "Spencer Kimball & Rob Malda"
  141.             "Spencer Kimball & Rob Malda"
  142.             "1997"
  143.             ""
  144.             SF-STRING     _"Text" "Cool Metal"
  145.             SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 1000 1 10 0 1)
  146.             SF-FONT       _"Font" "-*-Crillee-*-r-*-*-24-*-*-*-p-*-*-*"
  147.             SF-COLOR      _"Background Color" '(255 255 255)
  148.             SF-GRADIENT   _"Gradient" "Horizon_1"
  149.             )
  150.