home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 August / ENTER.ISO / files / gimp-2.0.5-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / coffee.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2004-09-26  |  2.8 KB  |  85 lines

  1. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  2. ; At ECS Dept, University of Southampton, England.
  3.  
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8. ; This program is distributed in the hope that it will be useful,
  9. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. ; GNU General Public License for more details.
  12. ; You should have received a copy of the GNU General Public License
  13. ; along with this program; if not, write to the Free Software
  14. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15.  
  16.  
  17. (define (script-fu-coffee-stain inImage
  18.                 inLayer
  19.                 inNumber
  20.                 inDark)
  21.  
  22.    (set! old-gradient (car (gimp-gradients-get-gradient)))
  23.    (set! theImage inImage)
  24.    (set! theHeight (car (gimp-image-height theImage)))
  25.    (set! theWidth (car (gimp-image-width theImage)))
  26.    (set! theNumber inNumber)
  27.    (set! theSize (min theWidth theHeight))
  28.  
  29.    (gimp-image-undo-group-start theImage)
  30.  
  31.    (while (> theNumber 0)
  32.       (set! theNumber (- theNumber 1))
  33.       (set! theStain (car (gimp-layer-new theImage theSize theSize
  34.                           RGBA-IMAGE "Stain" 100
  35.                           (if (= inDark TRUE)
  36.                           DARKEN-ONLY-MODE NORMAL-MODE))))
  37.  
  38.       (gimp-image-add-layer theImage theStain 0)
  39.       (gimp-selection-all theImage)
  40.       (gimp-edit-clear theStain)
  41.  
  42.       (let ((blobSize (/ (rand (- theSize 40)) (+ (rand 3) 1))))
  43.             (gimp-ellipse-select theImage
  44.                  (/ (- theSize blobSize) 2)
  45.                  (/ (- theSize blobSize) 2)
  46.                  blobSize blobSize CHANNEL-OP-REPLACE TRUE 0 FALSE))
  47.  
  48.       (script-fu-distress-selection theImage theStain
  49.                     (* (+ (rand 15) 1) (+ (rand 15) 1))
  50.                     (/ theSize 25) 4 2 TRUE TRUE)
  51.  
  52.       (gimp-gradients-set-gradient "Coffee")
  53.  
  54.       (gimp-edit-blend theStain CUSTOM-MODE NORMAL-MODE
  55.                GRADIENT-SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE
  56.                FALSE 0 0 TRUE
  57.                0 0 0 0)
  58.  
  59.       (gimp-layer-set-offsets theStain
  60.                   (- (rand theWidth) (/ theSize 2))
  61.                   (- (rand theHeight) (/ theSize 2)) theSize))
  62.  
  63.    (gimp-selection-none theImage)
  64.  
  65.    (gimp-image-undo-group-end theImage)
  66.  
  67.    (gimp-gradients-set-gradient old-gradient)
  68.    (gimp-displays-flush))
  69.  
  70. ; Register the function with the GIMP:
  71.  
  72. (script-fu-register "script-fu-coffee-stain"
  73.             _"<Image>/Script-Fu/Decor/_Coffee Stain..."
  74.             "Draws realistic looking coffee stains"
  75.             "Chris Gutteridge"
  76.             "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  77.             "25th April 1998"
  78.             "RGB*"
  79.             SF-IMAGE       "The Image" 0
  80.             SF-DRAWABLE    "The Layer" 0
  81.             SF-ADJUSTMENT _"Stains"    '(3 1 10 1 1 0 0)
  82.             SF-TOGGLE     _"Darken Only\n(Better, but only for Images with alot of White)" TRUE)
  83.