home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / scripts / xach-effect.scm.z / xach-effect.scm
Encoding:
Text File  |  1999-07-21  |  4.3 KB  |  134 lines

  1.  
  2.  
  3. ; The GIMP -- an image manipulation program
  4. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  5. ; xach effect script
  6. ; Copyright (c) 1997 Adrian Likins
  7. ; aklikins@eos.ncsu.edu
  8. ;
  9. ; based on a idea by Xach Beane <xach@mint.net>
  10. ;
  11. ;
  12. ; This program is free software; you can redistribute it and/or modify
  13. ; it under the terms of the GNU General Public License as published by
  14. ; the Free Software Foundation; either version 2 of the License, or
  15. ; (at your option) any later version.
  16. ; This program is distributed in the hope that it will be useful,
  17. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ; GNU General Public License for more details.
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with this program; if not, write to the Free Software
  22. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24.  
  25. (define (script-fu-xach-effect image
  26.                    drawable
  27.                    hl-offset-x
  28.                    hl-offset-y
  29.                    hl-color
  30.                    hl-opacity
  31.                    ds-color
  32.                    ds-opacity
  33.                    ds-blur
  34.                    ds-offset-x
  35.                    ds-offset-y
  36.                    keep-selection)
  37.   (let* ((ds-blur (max ds-blur 0))
  38.      (ds-opacity (min ds-opacity 100))
  39.      (ds-opacity (max ds-opacity 0))
  40.      (type (car (gimp-drawable-type-with-alpha drawable)))
  41.      (image-width (car (gimp-image-width image)))
  42.      (image-height (car (gimp-image-height image)))
  43.      (old-bg (car (gimp-palette-get-background))))
  44.     
  45.     (gimp-image-disable-undo image)
  46.     (gimp-layer-add-alpha drawable)
  47.     
  48.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  49.     (begin
  50.       (gimp-selection-layer-alpha image drawable)
  51.       (set! active-selection (car (gimp-selection-save image)))
  52.       (set! from-selection FALSE))
  53.     (begin 
  54.       (set! from-selection TRUE)
  55.       (set! active-selection (car (gimp-selection-save image)))))
  56.     
  57.     (set! hl-layer (car (gimp-layer-new image image-width image-height type "Highlight" 100 NORMAL)))
  58.     (gimp-image-add-layer image hl-layer -1)
  59.     
  60.  
  61.     (gimp-selection-none image)
  62.     (gimp-edit-clear image hl-layer)
  63.     (gimp-selection-load image active-selection)
  64.     
  65.     (gimp-palette-set-background hl-color)
  66.     (gimp-edit-fill image hl-layer)
  67.     (gimp-selection-translate image hl-offset-x hl-offset-y)
  68.     (gimp-edit-fill image hl-layer)
  69.     (gimp-selection-none image)
  70.     (gimp-selection-load image active-selection)
  71.     
  72.     (set! mask (car (gimp-layer-create-mask hl-layer WHITE-MASK)))
  73.     (gimp-image-add-layer-mask image hl-layer mask)
  74.     
  75.     (gimp-palette-set-background hl-opacity)
  76.     (gimp-edit-fill image mask)
  77.  
  78.     (set! shadow-layer (car (gimp-layer-new image
  79.                         image-width
  80.                         image-height
  81.                         type
  82.                         "Shadow"
  83.                         ds-opacity
  84.                         NORMAL)))
  85.     (gimp-image-add-layer image shadow-layer -1)
  86.     (gimp-selection-none image)
  87.     (gimp-edit-clear image shadow-layer)
  88.     (gimp-selection-load image active-selection)
  89.     (gimp-selection-translate image ds-offset-x ds-offset-y)
  90.     (gimp-palette-set-background ds-color)
  91.     (gimp-edit-fill image shadow-layer)
  92.     (gimp-selection-none image)
  93.     (plug-in-gauss-rle 1 image shadow-layer ds-blur TRUE TRUE)
  94.     (gimp-selection-load image active-selection)
  95.     (gimp-edit-clear image shadow-layer)
  96.     (gimp-image-lower-layer image shadow-layer)
  97.  
  98.  
  99.     (gimp-palette-set-background old-bg)
  100.  
  101.     (if (= keep-selection FALSE)
  102.     (gimp-selection-none image))
  103.  
  104.     (gimp-image-set-active-layer image drawable)
  105.     (gimp-image-remove-channel image active-selection)
  106.     (gimp-image-enable-undo image)
  107.     (gimp-displays-flush)))
  108.  
  109. (script-fu-register "script-fu-xach-effect"
  110.             "<Image>/Script-Fu/Decor/Xach-Effect"
  111.             "Add a subtle translucent 3-d effect to the current selection or alpha channel"
  112.             "Adrian Likins <adrian@gimp.org>"
  113.             "Adrian Likins"
  114.             "9/28/97"
  115.             "RGB RGBA GRAY GRAYA"
  116.             SF-IMAGE "Image" 0
  117.             SF-DRAWABLE "Drawable" 0
  118.             SF-VALUE "highlight X offset" "-1"
  119.             SF-VALUE "highlight Y offset" "-1"
  120.             SF-COLOR "Highlight Color" '(255 255 255)
  121.             SF-COLOR "Opacity" '(66 66 66)
  122.             SF-COLOR "Drop Shadow Color" '(0 0 0)
  123.             SF-VALUE "Drop shadow Opacity" "100"
  124.             SF-VALUE "Drop shadow Blur Radius" "12"
  125.             SF-VALUE "Drop shadow X offset" "5"
  126.                     SF-VALUE "Drop shadow Y offset" "5"
  127.             SF-TOGGLE "Keep Selection?" TRUE)
  128.  
  129.  
  130.  
  131.