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

  1. ;  Nova Starscape
  2. ;  Create a text effect that simulates an eerie alien glow around text
  3.  
  4. (define (find-blend-coords w h)
  5.   (let* ((denom (+ (/ w h) (/ h w)))
  6.      (bx    (/ (* -2 h) denom))
  7.      (by    (/ (* -2 w) denom)))
  8.     (cons bx by)))
  9.  
  10. (define (find-nova-x-coord drawable x1 x2 y)
  11.   (let* ((x 0)
  12.      (alpha 3)
  13.      (range (- x2 x1))
  14.      (min-clearance 5)
  15.      (val '())
  16.      (val-left '())
  17.      (val-right '())
  18.      (val-top '())
  19.      (val-bottom '())
  20.      (limit 100)
  21.      (clearance 0))
  22.     (while (and (= clearance 0) (> limit 0))
  23.        (set! x (+ (rand range) x1))
  24.        (set! val (cadr (gimp-drawable-get-pixel drawable x y)))
  25.        (set! val-left (cadr (gimp-drawable-get-pixel drawable (- x min-clearance) y)))
  26.        (set! val-right (cadr (gimp-drawable-get-pixel drawable (+ x min-clearance) y)))
  27.        (set! val-top (cadr (gimp-drawable-get-pixel drawable x (- y min-clearance))))
  28.        (set! val-bottom (cadr (gimp-drawable-get-pixel drawable x (+ y min-clearance))))
  29.        (if (and (= (aref val alpha) 0) (= (aref val-left alpha) 0) (= (aref val-right alpha) 0)
  30.             (= (aref val-top alpha) 0) (= (aref val-bottom alpha) 0))
  31.            (set! clearance 1) (set! limit (- limit 1))))
  32.     x))
  33.  
  34. (define (apply-starscape-logo-effect img
  35.                      logo-layer
  36.                      size
  37.                      glow-color)
  38.   (let* ((border (/ size 4))
  39.      (grow (/ size 30))
  40.      (offx (* size 0.03))
  41.      (offy (* size 0.02))
  42.      (feather (/ size 4))
  43.      (shadow-feather (/ size 25))
  44.      (width (car (gimp-drawable-width logo-layer)))
  45.      (height (car (gimp-drawable-height logo-layer)))
  46.      (w (* (/ (- width (* border 2)) 2.0) 0.75))
  47.      (h (* (/ (- height (* border 2)) 2.0) 0.75))
  48.      (novay (* height 0.3))
  49.      (novax (find-nova-x-coord logo-layer (* width 0.2) (* width 0.8) novay))
  50.      (novaradius (/ (min height width) 7.0))
  51.      (cx (/ width 2.0))
  52.      (cy (/ height 2.0))
  53.      (bx (+ cx (car (find-blend-coords w h))))
  54.      (by (+ cy (cdr (find-blend-coords w h))))
  55.      (bg-layer (car (gimp-layer-new img width height RGB_IMAGE "Background" 100 NORMAL)))
  56.      (glow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Glow" 100 NORMAL)))
  57.      (shadow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Drop Shadow" 100 NORMAL)))
  58.      (bump-channel (car (gimp-channel-new img width height "Bump Map" 50 '(0 0 0))))
  59.      (old-pattern (car (gimp-patterns-get-pattern)))
  60.      (old-fg (car (gimp-palette-get-foreground)))
  61.      (old-bg (car (gimp-palette-get-background))))
  62.     (gimp-image-resize img width height 0 0)
  63.     (gimp-image-add-layer img bg-layer 1)
  64.     (gimp-image-add-layer img glow-layer 1)
  65.     (gimp-image-add-layer img shadow-layer 1)
  66.     (gimp-layer-set-preserve-trans logo-layer TRUE)
  67.  
  68.     (gimp-palette-set-background '(0 0 0))
  69.     (gimp-edit-fill bg-layer BG-IMAGE-FILL)
  70.     (gimp-edit-clear shadow-layer)
  71.     (gimp-edit-clear glow-layer)
  72.  
  73.     (gimp-selection-layer-alpha logo-layer)
  74.     (gimp-selection-grow img grow)
  75.     (gimp-selection-feather img feather)
  76.     (gimp-palette-set-background glow-color)
  77.     (gimp-selection-feather img feather)
  78.     (gimp-edit-fill glow-layer BG-IMAGE-FILL)
  79.  
  80.     (gimp-selection-layer-alpha logo-layer)
  81.     (gimp-selection-feather img shadow-feather)
  82.     (gimp-palette-set-background '(0 0 0))
  83.     (gimp-selection-translate img offx offy)
  84.     (gimp-edit-fill shadow-layer BG-IMAGE-FILL)
  85.  
  86.     (gimp-selection-none img)
  87.     (gimp-palette-set-background '(31 31 31))
  88.     (gimp-palette-set-foreground '(255 255 255))
  89.     (gimp-blend logo-layer FG-BG-RGB NORMAL BILINEAR 100 0 REPEAT-NONE FALSE 0 0 cx cy bx by)
  90.  
  91.     (plug-in-nova 1 img glow-layer novax novay glow-color novaradius 100 0)
  92.  
  93.     (gimp-selection-all img)
  94.     (gimp-patterns-set-pattern "Stone")
  95.     (gimp-bucket-fill bump-channel PATTERN-BUCKET-FILL NORMAL 100 0 FALSE 0 0)
  96.     (plug-in-bump-map 1 img logo-layer bump-channel 135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
  97.     (gimp-image-remove-channel img bump-channel)
  98.     (gimp-selection-none img)
  99.  
  100.     (gimp-patterns-set-pattern old-pattern)
  101.     (gimp-palette-set-background old-bg)
  102.     (gimp-palette-set-foreground old-fg)))
  103.  
  104.  
  105. (define (script-fu-starscape-logo-alpha img
  106.                     logo-layer
  107.                     size
  108.                     glow-color)
  109.   (begin
  110.     (gimp-undo-push-group-start img)
  111.     (apply-starscape-logo-effect img logo-layer size glow-color)
  112.     (gimp-undo-push-group-end img)
  113.     (gimp-displays-flush)))
  114.  
  115. (script-fu-register "script-fu-starscape-logo-alpha"
  116.             _"<Image>/Script-Fu/Alpha to Logo/Starscape..."
  117.             "Starscape using the Nova plug-in"
  118.             "Spencer Kimball"
  119.             "Spencer Kimball"
  120.             "1997"
  121.             "RGBA"
  122.                     SF-IMAGE      "Image" 0
  123.                     SF-DRAWABLE   "Drawable" 0
  124.             SF-ADJUSTMENT _"Effect Size (pixels * 4)" '(150 1 1000 1 10 0 1)
  125.             SF-COLOR      _"Glow Color" '(28 65 188)
  126.             )
  127.  
  128.  
  129. (define (script-fu-starscape-logo text
  130.                   size
  131.                   fontname
  132.                   glow-color)
  133.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  134.      (border (/ size 4))
  135.      (text-layer (car (gimp-text-fontname img -1 0 0 text border TRUE size PIXELS fontname))))
  136.     (gimp-image-undo-disable img)
  137.     (gimp-layer-set-name text-layer text)
  138.     (apply-starscape-logo-effect img text-layer size glow-color)
  139.     (gimp-image-undo-enable img)
  140.     (gimp-display-new img)))
  141.  
  142. (script-fu-register "script-fu-starscape-logo"
  143.             _"<Toolbox>/Xtns/Script-Fu/Logos/Starscape..."
  144.             "Starscape using the Nova plug-in"
  145.             "Spencer Kimball"
  146.             "Spencer Kimball"
  147.             "1997"
  148.             ""
  149.             SF-STRING     _"Text" "Nova"
  150.             SF-ADJUSTMENT _"Font Size (pixels)" '(150 1 1000 1 10 0 1)
  151.                     SF-FONT       _"Font" "-*-engraver-*-r-*-*-24-*-*-*-p-*-*-*"
  152.             SF-COLOR      _"Glow Color" '(28 65 188)
  153.             )
  154.