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

  1. ;
  2. ; distress selection
  3. ;
  4. ;
  5. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  6. ; At ECS Dept, University of Southampton, England.
  7.  
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ; GNU General Public License for more details.
  16. ; You should have received a copy of the GNU General Public License
  17. ; along with this program; if not, write to the Free Software
  18. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. ; Define the function:
  21.  
  22. (define (script-fu-distress-selection    inImage
  23.                     inLayer
  24.                     inThreshold
  25.                     inSpread
  26.                     inGranu
  27.                     inSmooth
  28.                                         inSmoothH
  29.                                         inSmoothV
  30.     )
  31.  
  32.     (set! theImage inImage)
  33.         (set! theWidth (car (gimp-image-width inImage)))
  34.     (set! theHeight (car (gimp-image-height inImage)))
  35.  
  36.     (gimp-image-undo-disable theImage)
  37.  
  38.     (set! theLayer (car (gimp-layer-new     theImage
  39.                         theWidth
  40.                         theHeight
  41.                         RGBA_IMAGE
  42.                         "Distress Scratch Layer"
  43.                         100
  44.                         NORMAL
  45.     ) ) )
  46.  
  47.     (gimp-image-add-layer theImage theLayer 0)
  48.         (if (= TRUE (car (gimp-selection-is-empty theImage)))
  49.             ()
  50.         (gimp-edit-fill theLayer BG-IMAGE-FILL)
  51.         )
  52.     (gimp-selection-invert theImage)
  53.         (if (= TRUE (car (gimp-selection-is-empty theImage)))
  54.             ()
  55.             (gimp-edit-clear theLayer)
  56.         )
  57.     (gimp-selection-invert theImage)
  58.         (gimp-selection-none inImage)
  59.  
  60.     (gimp-layer-scale     theLayer
  61.                 (/ theWidth inGranu)
  62.                 (/ theHeight inGranu)
  63.                 TRUE
  64.     )
  65.  
  66.     (plug-in-spread     TRUE
  67.                 theImage
  68.                 theLayer
  69.                 inSpread
  70.                 inSpread
  71.     )
  72.     (plug-in-gauss-iir TRUE theImage theLayer inSmooth inSmoothH inSmoothV)
  73. ;    (plug-in-gauss-iir TRUE theImage theLayer 2 TRUE TRUE)
  74.     (gimp-layer-scale theLayer theWidth theHeight TRUE)
  75.     (plug-in-threshold-alpha TRUE theImage theLayer inThreshold)
  76.         (plug-in-gauss-iir TRUE theImage theLayer 1 TRUE TRUE)
  77.     (gimp-selection-layer-alpha theLayer)
  78.     (gimp-image-remove-layer theImage theLayer)
  79. ;    (gimp-layer-delete theLayer)
  80.     (gimp-image-undo-enable theImage)
  81.     (gimp-displays-flush)
  82. )
  83.  
  84.  
  85. ; Register the function with the GIMP:
  86.  
  87. (script-fu-register
  88.     "script-fu-distress-selection"
  89.     _"<Image>/Script-Fu/Selection/Distress Selection..."
  90.     "No description"
  91.     "Chris Gutteridge"
  92.     "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  93.     "23rd April 1998"
  94.     "RGB*"
  95.     SF-IMAGE "The Image" 0
  96.     SF-DRAWABLE "The Layer" 0
  97.     SF-ADJUSTMENT _"Threshold (Bigger 1<-->255 Smaller)" '(127 1 255 1 10 0 0)
  98.     SF-ADJUSTMENT _"Spread" '(8 0 1000 1 10 0 1)
  99.     SF-ADJUSTMENT _"Granularity (1 is Low)" '(4 1 25 1 10 0 1)
  100.     SF-ADJUSTMENT _"Smooth" '(2 0 150 1 10 0 1)
  101.     SF-TOGGLE _"Smooth Horizontally" TRUE
  102.     SF-TOGGLE _"Smooth Vertically" TRUE
  103. )
  104.