home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / xach-effect.scm < prev   
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  5.2 KB  |  142 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; xach effect script
  5. ; Copyright (c) 1997 Adrian Likins
  6. ; aklikins@eos.ncsu.edu
  7. ;
  8. ; based on a idea by Xach Beane <xach@mint.net>
  9. ;
  10. ;
  11. ; This program is free software: you can redistribute it and/or modify
  12. ; it under the terms of the GNU General Public License as published by
  13. ; the Free Software Foundation; either version 3 of the License, or
  14. ; (at your option) any later version.
  15. ;
  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. ;
  21. ; You should have received a copy of the GNU General Public License
  22. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  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-comp
  31.                                ds-color
  32.                                ds-opacity
  33.                                ds-blur
  34.                                ds-offset-x
  35.                                ds-offset-y
  36.                                keep-selection)
  37.   (let* (
  38.         (ds-blur (max ds-blur 0))
  39.         (ds-opacity (min ds-opacity 100))
  40.         (ds-opacity (max ds-opacity 0))
  41.         (type (car (gimp-drawable-type-with-alpha drawable)))
  42.         (image-width (car (gimp-image-width image)))
  43.         (hl-opacity (list hl-opacity-comp hl-opacity-comp hl-opacity-comp))
  44.         (image-height (car (gimp-image-height image)))
  45.         (active-selection 0)
  46.         (from-selection 0)
  47.         (theLayer 0)
  48.         (hl-layer 0)
  49.         (shadow-layer 0)
  50.         (mask 0)
  51.         )
  52.  
  53.     (gimp-context-push)
  54.  
  55.     (gimp-image-undo-group-start image)
  56.     (gimp-layer-add-alpha drawable)
  57.  
  58.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  59.         (begin
  60.           (gimp-selection-layer-alpha drawable)
  61.           (set! active-selection (car (gimp-selection-save image)))
  62.           (set! from-selection FALSE))
  63.         (begin
  64.           (set! from-selection TRUE)
  65.           (set! active-selection (car (gimp-selection-save image)))))
  66.  
  67.     (set! hl-layer (car (gimp-layer-new image image-width image-height type "Highlight" 100 NORMAL-MODE)))
  68.     (gimp-image-add-layer image hl-layer -1)
  69.  
  70.     (gimp-selection-none image)
  71.     (gimp-edit-clear hl-layer)
  72.     (gimp-selection-load active-selection)
  73.  
  74.     (gimp-context-set-background hl-color)
  75.     (gimp-edit-fill hl-layer BACKGROUND-FILL)
  76.     (gimp-selection-translate image hl-offset-x hl-offset-y)
  77.     (gimp-edit-fill hl-layer BACKGROUND-FILL)
  78.     (gimp-selection-none image)
  79.     (gimp-selection-load active-selection)
  80.  
  81.     (set! mask (car (gimp-layer-create-mask hl-layer ADD-WHITE-MASK)))
  82.     (gimp-layer-add-mask hl-layer mask)
  83.  
  84.     (gimp-context-set-background hl-opacity)
  85.     (gimp-edit-fill mask BACKGROUND-FILL)
  86.  
  87.     (set! shadow-layer (car (gimp-layer-new image
  88.                                             image-width
  89.                                             image-height
  90.                                             type
  91.                                             "Shadow"
  92.                                             ds-opacity
  93.                                             NORMAL-MODE)))
  94.     (gimp-image-add-layer image shadow-layer -1)
  95.     (gimp-selection-none image)
  96.     (gimp-edit-clear shadow-layer)
  97.     (gimp-selection-load active-selection)
  98.     (gimp-selection-translate image ds-offset-x ds-offset-y)
  99.     (gimp-context-set-background ds-color)
  100.     (gimp-edit-fill shadow-layer BACKGROUND-FILL)
  101.     (gimp-selection-none image)
  102.     (plug-in-gauss-rle RUN-NONINTERACTIVE image shadow-layer ds-blur TRUE TRUE)
  103.     (gimp-selection-load active-selection)
  104.     (gimp-edit-clear shadow-layer)
  105.     (gimp-image-lower-layer image shadow-layer)
  106.  
  107.     (if (= keep-selection FALSE)
  108.         (gimp-selection-none image))
  109.  
  110.     (gimp-image-set-active-layer image drawable)
  111.     (gimp-image-remove-channel image active-selection)
  112.     (gimp-image-undo-group-end image)
  113.     (gimp-displays-flush)
  114.  
  115.     (gimp-context-pop)
  116.   )
  117. )
  118.  
  119. (script-fu-register "script-fu-xach-effect"
  120.   _"_Xach-Effect..."
  121.   _"Add a subtle translucent 3D effect to the selected region (or alpha)"
  122.   "Adrian Likins <adrian@gimp.org>"
  123.   "Adrian Likins"
  124.   "9/28/97"
  125.   "RGB* GRAY*"
  126.   SF-IMAGE       "Image"                   0
  127.   SF-DRAWABLE    "Drawable"                0
  128.   SF-ADJUSTMENT _"Highlight X offset"      '(-1 -100 100 1 10 0 1)
  129.   SF-ADJUSTMENT _"Highlight Y offset"      '(-1 -100 100 1 10 0 1)
  130.   SF-COLOR      _"Highlight color"         "white"
  131.   SF-ADJUSTMENT _"Highlight opacity"       '(66 0 255 1 10 0 0)
  132.   SF-COLOR      _"Drop shadow color"       "black"
  133.   SF-ADJUSTMENT _"Drop shadow opacity"     '(100 0 100 1 10 0 0)
  134.   SF-ADJUSTMENT _"Drop shadow blur radius" '(12 0 255 1 10 0 1)
  135.   SF-ADJUSTMENT _"Drop shadow X offset"    '(5 0 255 1 10 0 1)
  136.   SF-ADJUSTMENT _"Drop shadow Y offset"    '(5 0 255 1 10 0 1)
  137.   SF-TOGGLE     _"Keep selection"          TRUE
  138. )
  139.  
  140. (script-fu-menu-register "script-fu-xach-effect"
  141.                          "<Image>/Filters/Light and Shadow/Shadow")
  142.