home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / Topware / gimp / gimp-setup-20001226.exe / Main / camo.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2000-12-27  |  3.7 KB  |  102 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-camo-pattern inSize inGrain inColor1 inColor2 inColor3 inSmooth inFlatten)
  21.  
  22.         (set! old-bg (car (gimp-palette-get-background)))
  23.         (set! theWidth inSize)
  24.     (set! theHeight inSize)
  25.         (set! theImage (car(gimp-image-new theWidth theHeight RGB)))
  26.  
  27.         (set! baseLayer (car (gimp-layer-new theImage theWidth theHeight RGBA_IMAGE "Background" 100 NORMAL)))
  28.         (gimp-image-add-layer theImage baseLayer 0)
  29.  
  30.         (set! thickLayer (car (gimp-layer-new theImage theWidth theHeight RGBA_IMAGE "Camo Thick Layer" 100 NORMAL)))
  31.         (gimp-image-add-layer theImage thickLayer 0)
  32.  
  33.         (set! thinLayer (car (gimp-layer-new theImage theWidth theHeight RGBA_IMAGE "Camo Thin Layer" 100 NORMAL)))
  34.         (gimp-image-add-layer theImage thinLayer 0)
  35.  
  36.         (gimp-selection-all theImage)
  37.         (gimp-palette-set-background inColor1)
  38.         (gimp-drawable-fill baseLayer BG-IMAGE-FILL)
  39.  
  40.         (plug-in-solid-noise TRUE theImage thickLayer 1 0 (rand 65536) 1 inGrain inGrain)
  41.         (plug-in-solid-noise TRUE theImage thinLayer 1 0 (rand 65536) 1 inGrain inGrain)
  42.         (gimp-threshold thickLayer 127 255)
  43.         (gimp-threshold thinLayer 145 255)
  44.  
  45.     (set! theBlur (- 16 inGrain))
  46.  
  47.         (gimp-palette-set-background inColor2)
  48.         (gimp-by-color-select thickLayer '(0 0 0) 127 REPLACE  TRUE FALSE 0 FALSE)
  49.         (gimp-edit-clear thickLayer)
  50.         (gimp-selection-invert theImage)
  51.         (gimp-edit-fill thickLayer BG-IMAGE-FILL)
  52.         (gimp-selection-none theImage)
  53.         (if (= inSmooth TRUE)
  54.         (script-fu-tile-blur theImage thickLayer theBlur TRUE TRUE FALSE)
  55.             ()
  56.         )
  57.  
  58.  
  59.         (gimp-palette-set-background inColor3)
  60.         (gimp-by-color-select thinLayer '(0 0 0) 127 REPLACE  TRUE FALSE 0 FALSE)
  61.         (gimp-edit-clear thinLayer)
  62.         (gimp-selection-invert theImage)
  63.         (gimp-edit-fill thinLayer BG-IMAGE-FILL)
  64.         (gimp-selection-none theImage)
  65.         (if (= inSmooth TRUE)
  66.         (script-fu-tile-blur theImage thinLayer (/ theBlur 2) TRUE TRUE FALSE)
  67.             ()
  68.         )
  69.  
  70.  
  71.         (if (= inFlatten TRUE)
  72.             (gimp-image-flatten theImage)
  73.             ()
  74.         )
  75.         (gimp-palette-set-background old-bg)
  76.         (gimp-display-new theImage)
  77. )
  78.  
  79.  
  80.  
  81. ; Register the function with the GIMP:
  82.  
  83. (script-fu-register
  84.  "script-fu-camo-pattern"
  85.  _"<Toolbox>/Xtns/Script-Fu/Patterns/Camouflage..."
  86.  "Camouflage pattern"
  87.  "Chris Gutteridge: cjg@ecs.soton.ac.uk"
  88.  "28th April 1998"
  89.  "Chris Gutteridge / ECS @ University of Southampton, England"
  90.  ""
  91.  SF-ADJUSTMENT _"Image Size"    '(256 10 1000 1 10 0 1)
  92.  SF-ADJUSTMENT _"Granularity"   '(7 0 15 1 1 0 0)
  93.  SF-COLOR      _"Color 1"       '(33 100 58)
  94.  SF-COLOR      _"Color 2"       '(170 170 60)
  95.  SF-COLOR      _"Color 3"       '(150 115 100)
  96.  SF-TOGGLE     _"Smooth"        FALSE
  97.  SF-TOGGLE     _"Flatten Image" TRUE
  98. )
  99.  
  100.