home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 July / CHIP-1999-07.iso / software / gimp / GIMP-SET.EXE / file0465_3cb45c_3cbb62.bin < prev    next >
Encoding:
Text File  |  1999-02-28  |  5.2 KB  |  174 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Alien Glow themed button
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.edu
  6. ;
  7. ; based on code from Frederico Mena Quintero (Quartic)
  8. ; federico@nuclecu.unam.mx
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ; This program is distributed in the hope that it will be useful,
  15. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ; GNU General Public License for more details.
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. (define (text-width extents)
  24.   (car extents))
  25.  
  26. (define (text-height extents)
  27.   (cadr extents))
  28.  
  29. (define (text-ascent extents)
  30.   (caddr extents))
  31.  
  32. (define (text-descent extents)
  33.   (cadr (cddr extents)))
  34.  
  35. (define (blend-bumpmap img drawable x1 y1 x2 y2)
  36.   (gimp-blend drawable
  37.           FG-BG-RGB
  38.           DARKEN-ONLY
  39.           LINEAR
  40.           100
  41.           0
  42.           REPEAT-NONE
  43.           FALSE
  44.           0
  45.           0
  46.           x1
  47.           y1
  48.           x2
  49.           y2))
  50.  
  51. (define (script-fu-alien-glow-button text
  52.                 size
  53.                 foundry
  54.                 family
  55.                 weight
  56.                 slant
  57.                 set-width
  58.                 spacing
  59.                 text-color
  60.                 glow-color
  61.                 bg-color
  62.                 padding
  63.                 glow-radius
  64.                 flatten)
  65.   (let* ((old-fg-color (car (gimp-palette-get-foreground)))
  66.      (old-bg-color (car (gimp-palette-get-background)))
  67.      (text-extents (gimp-text-get-extents text
  68.                           size
  69.                           PIXELS
  70.                           foundry
  71.                           family
  72.                           weight
  73.                           slant
  74.                           set-width
  75.                           spacing))
  76.      (ascent (text-ascent text-extents))
  77.      (descent (text-descent text-extents))
  78.      
  79.      (img-width (+ (* 2  padding)
  80.                (- (text-width text-extents)
  81.               (text-width (gimp-text-get-extents " "
  82.                                  size
  83.                                  PIXELS
  84.                                  foundry
  85.                                  family
  86.                                  weight
  87.                                  slant
  88.                                  set-width
  89.                                  spacing)))))
  90.      (img-height (+ (* 2 padding)
  91.             (+ ascent descent)))
  92.      (layer-height img-height)
  93.      (layer-width img-width)
  94.      (img-width (+ img-width glow-radius))
  95.      (img-height (+ img-height glow-radius))
  96.      (img (car (gimp-image-new  img-width   img-height  RGB)))
  97.      (bg-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "Background" 100 NORMAL)))
  98.      (glow-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "Glow" 100 NORMAL)))
  99.      (button-layer (car (gimp-layer-new img layer-width layer-height RGBA_IMAGE "Button" 100 NORMAL))))
  100.  
  101.     (gimp-image-disable-undo img)
  102.  
  103.     ; Create bumpmap layer
  104.     
  105.     (gimp-image-add-layer img bg-layer -1)
  106.     (gimp-palette-set-foreground '(0 0 0))
  107.     (gimp-palette-set-background bg-color)
  108.     (gimp-edit-fill bg-layer)
  109.     (gimp-image-add-layer img glow-layer -1)
  110.  
  111.     ; Create text layer
  112.  
  113.     (gimp-image-add-layer img button-layer -1)
  114.     (gimp-layer-set-offsets button-layer (/ glow-radius 2) (/ glow-radius 2))
  115.     (gimp-selection-none img)
  116.     (gimp-rect-select img 0 0 img-width img-height REPLACE FALSE 0)
  117.     (gimp-palette-set-foreground '(100 100 100))
  118.     (gimp-palette-set-background '(0 0 0))
  119.     (gimp-blend button-layer FG-BG-RGB NORMAL SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE 0 0 0 0 img-height img-width)
  120.     (gimp-edit-clear glow-layer)
  121.     (gimp-rect-select img (/ glow-radius 4) (/ glow-radius 4) (- img-width (/ glow-radius 2)) (- img-height (/ glow-radius 2)) REPLACE FALSE 0 )
  122.     (gimp-palette-set-background glow-color)
  123.     (gimp-edit-fill glow-layer)
  124.     (gimp-selection-none img)
  125.     (plug-in-gauss-rle 1 img glow-layer glow-radius TRUE TRUE)
  126.     (gimp-palette-set-foreground text-color)
  127.     (let ((textl (car (gimp-text
  128.                img -1 0 0 text 0 TRUE size PIXELS foundry family weight slant set-width spacing))))
  129.       (gimp-layer-set-offsets textl
  130.                   (+  padding (/ glow-radius 2))
  131.                   (+ (+ padding descent) (/ glow-radius 2))))
  132.     ; Done
  133.     (gimp-selection-none img)
  134.     (gimp-palette-set-foreground old-fg-color)
  135.     (gimp-palette-set-background old-bg-color)
  136.     (gimp-image-enable-undo img)
  137.     (if (= flatten TRUE)
  138.     (gimp-image-flatten img))
  139.     (gimp-display-new img)))
  140.  
  141. ; Register!
  142.  
  143. (script-fu-register "script-fu-alien-glow-button"
  144.             "<Toolbox>/Xtns/Script-Fu/Web page themes/Alien Glow/Button"
  145.             "Button with an eerie glow"
  146.             "Adrian Likins"
  147.             "Adrian Likins"
  148.             "July 1997"
  149.             ""
  150.             SF-STRING "Text" "Hello world!"
  151.             SF-VALUE "Size" "22"
  152.             SF-STRING "Foundry" "*"
  153.             SF-STRING "Family" "futura_poster"
  154.             SF-STRING "Weight" "*"
  155.             SF-STRING "Slant" "*"
  156.             SF-STRING "Set width" "*"
  157.             SF-STRING "Spacing" "*"
  158.             SF-COLOR "Text color" '(0 0 0)
  159.             SF-COLOR "Glow Color" '(63 252 0)
  160.             SF-COLOR "Background Color" '(0 0 0)
  161.             SF-VALUE "Padding" "6"
  162.             SF-VALUE "Glow Radius" "10"
  163.             SF-TOGGLE "Flatten Image?" TRUE)
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.