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

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