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

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Lava effect
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.edu
  6. ;
  7. ; based on a idea by Sven Riedel <lynx@heim8.tu-clausthal.de>
  8. ; tweaked a bit by Sven Neumann <neumanns@uni-duesseldorf.de>
  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 (script-fu-lava image
  24.             drawable
  25.             seed
  26.             tile_size
  27.             mask_size
  28.             gradient
  29.             keep-selection
  30.             separate-layer
  31.             current-grad)
  32.   (let* (
  33.      (type (car (gimp-drawable-type-with-alpha drawable)))
  34.      (image-width (car (gimp-image-width image)))
  35.      (image-height (car (gimp-image-height image)))
  36.      (old-gradient (car (gimp-gradients-get-active)))
  37.      (old-bg (car (gimp-palette-get-background))))
  38.     
  39.     (gimp-image-undo-disable image)
  40.     (gimp-layer-add-alpha drawable)
  41.     
  42.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  43.     (begin
  44.       (gimp-selection-layer-alpha drawable)
  45.       (set! active-selection (car (gimp-selection-save image)))
  46.       (set! from-selection FALSE))
  47.     (begin
  48.       (set! from-selection TRUE)
  49.       (set! active-selection (car (gimp-selection-save image)))))
  50.     
  51.     (set! selection-bounds (gimp-selection-bounds image))
  52.     (set! select-offset-x (cadr selection-bounds))
  53.     (set! select-offset-y (caddr selection-bounds))
  54.     (set! select-width (- (cadr (cddr selection-bounds)) select-offset-x))
  55.     (set! select-height (- (caddr (cddr selection-bounds)) select-offset-y))
  56.     
  57.     (if (= separate-layer TRUE)
  58.     (begin
  59.       (set! lava-layer (car (gimp-layer-new image
  60.                         select-width
  61.                         select-height
  62.                         type
  63.                         "Lava Layer"
  64.                         100
  65.                         NORMAL)))
  66.       
  67.       (gimp-image-add-layer image lava-layer -1)
  68.       (gimp-layer-set-offsets lava-layer select-offset-x select-offset-y)
  69.       (gimp-selection-none image)
  70.       (gimp-edit-clear lava-layer)
  71.       
  72.       (gimp-selection-load active-selection)
  73.       (gimp-image-set-active-layer image lava-layer)))
  74.     
  75.     (set! active-layer (car (gimp-image-get-active-layer image)))
  76.     
  77.     (if (= current-grad FALSE)
  78.     (gimp-gradients-set-active gradient))
  79.     
  80.     (plug-in-solid-noise 1 image active-layer FALSE TRUE seed 2 2 2)
  81.     (plug-in-cubism 1 image active-layer tile_size 2.5 0)
  82.     (plug-in-oilify 1 image active-layer mask_size 0)
  83.     (plug-in-edge 1 image active-layer 2 0)
  84.     (plug-in-gauss-rle 1 image active-layer 2 TRUE TRUE)
  85.     (plug-in-gradmap 1 image active-layer)
  86.  
  87.     (gimp-gradients-set-active old-gradient)
  88.     (gimp-palette-set-background old-bg)
  89.  
  90.     (if (= keep-selection FALSE)
  91.     (gimp-selection-none image))
  92.    
  93.     (gimp-image-set-active-layer image drawable)
  94.     (gimp-image-remove-channel image active-selection)
  95.     (gimp-image-undo-enable image)
  96.     (gimp-displays-flush)))
  97.  
  98. (script-fu-register "script-fu-lava"
  99.             _"<Image>/Script-Fu/Render/Lava..."
  100.             "Fills the current selection with lava."
  101.             "Adrian Likins <adrian@gimp.org>"
  102.             "Adrian Likins"
  103.             "10/12/97"
  104.             "RGB* GRAY*"
  105.             SF-IMAGE "Image" 0
  106.             SF-DRAWABLE "Drawable" 0
  107.             SF-ADJUSTMENT _"Seed" '(10 1 30000 1 10 0 1)
  108.             SF-ADJUSTMENT _"Size" '(10 0 100 1 10 0 1)
  109.             SF-ADJUSTMENT _"Roughness" '(7 3 50 1 10 0 0)
  110.             SF-GRADIENT _"Gradient" "German_flag_smooth"
  111.             SF-TOGGLE   _"Keep Selection" TRUE
  112.             SF-TOGGLE   _"Separate Layer" TRUE
  113.             SF-TOGGLE   _"Use Current Gradient" FALSE)
  114.