home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 February / PCWorld_2001-02_cd.bin / Software / Topware / gimp / gimp-setup-20001226.exe / Main / predator.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2000-12-27  |  3.8 KB  |  112 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Predator effect
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.ed
  6. ;
  7. ;  The idea here is too make the image/selection look sort of like 
  8. ;  the view the predator had in the movies. ie, kind of a thermogram
  9. ;  type of thing. Works best on colorful rgb images.
  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 2 of the License, or
  14. ; (at your option) any later version.
  15. ; This program is distributed in the hope that it will be useful,
  16. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ; GNU General Public License for more details.
  19. ; You should have received a copy of the GNU General Public License
  20. ; along with this program; if not, write to the Free Software
  21. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23.  
  24. (define (script-fu-predator image
  25.                 drawable
  26.                 edge-amount
  27.                 pixelize
  28.                 pixel-size
  29.                 keep-selection
  30.                 separate-layer)
  31.   (let* (
  32.      (type (car (gimp-drawable-type-with-alpha drawable)))
  33.      (image-width (car (gimp-image-width image)))
  34.      (image-height (car (gimp-image-height image))))
  35.     
  36.     (gimp-undo-push-group-start image)
  37.     (gimp-layer-add-alpha drawable)
  38.     
  39.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  40.     (begin
  41.       (gimp-selection-layer-alpha drawable)
  42.       (set! active-selection (car (gimp-selection-save image)))
  43.       (set! from-selection FALSE))
  44.     (begin
  45.       
  46.       (set! from-selection TRUE)
  47.       (set! active-selection (car (gimp-selection-save image)))))
  48.     
  49.     (set! selection-bounds (gimp-selection-bounds image))
  50.     (set! select-offset-x (cadr selection-bounds))
  51.     (set! select-offset-y (caddr selection-bounds))
  52.     (set! select-width (- (cadr (cddr selection-bounds)) select-offset-x))
  53.     (set! select-height (- (caddr (cddr selection-bounds)) select-offset-y))
  54.     
  55.     (if (= separate-layer TRUE)
  56.     (begin
  57.       (set! effect-layer (car (gimp-layer-new image
  58.                         select-width
  59.                         select-height
  60.                         type
  61.                         "glow layer"
  62.                         100
  63.                         NORMAL)))
  64.     
  65.       (gimp-layer-set-offsets effect-layer select-offset-x select-offset-y)
  66.       (gimp-image-add-layer image effect-layer -1)
  67.       (gimp-selection-none image)
  68.       (gimp-edit-clear effect-layer)
  69.     
  70.       (gimp-selection-load active-selection)
  71.       (gimp-edit-copy drawable)
  72.       (let ((floating-sel (car (gimp-edit-paste effect-layer FALSE))))
  73.         (gimp-floating-sel-anchor floating-sel)
  74.         )
  75.       (gimp-image-set-active-layer image effect-layer )))
  76.     (set! active-layer (car (gimp-image-get-active-layer image)))
  77.  
  78.     ; all the fun stuff goes here
  79.     (if (= pixelize TRUE)
  80.     (plug-in-pixelize 1 image active-layer pixel-size))
  81.     (plug-in-max-rgb 1 image active-layer 0)
  82.     (plug-in-edge 1 image active-layer edge-amount 1)
  83.     
  84.     ; clean up the selection copy
  85.     (gimp-selection-load active-selection)
  86.     
  87.     (if (= keep-selection FALSE)
  88.     (gimp-selection-none image))
  89.     
  90.     (gimp-undo-push-group-end image)
  91.     (gimp-image-set-active-layer image drawable)
  92.     (gimp-image-remove-channel image active-selection)
  93.     (gimp-displays-flush)))
  94.  
  95. (script-fu-register "script-fu-predator"
  96.             _"<Image>/Script-Fu/Alchemy/Predator..."
  97.             "Looks like images from the movie Predator"
  98.             "Adrian Likins <adrian@gimp.org>"
  99.             "Adrian Likins"
  100.             "10/12/97"
  101.             "RGB*"
  102.             SF-IMAGE "Image" 0
  103.             SF-DRAWABLE "Drawable" 0
  104.             SF-ADJUSTMENT _"Edge Amount" '(2 0 24 1 1 0 0)
  105.             SF-TOGGLE     _"Pixelize" TRUE
  106.             SF-ADJUSTMENT _"Pixel Amount" '(3 1 16 1 1 0 0)
  107.             SF-TOGGLE     _"Keep Selection" TRUE
  108.             SF-TOGGLE     _"Separate Layer" TRUE)
  109.