;; camouflage.scm -*-scheme-*- ;; Changes (gimp2 changes, use current image, don't Flatten!) and fixes by Alan Horkan. ;; Alan Horkan claims no copyright on his improvements to this script ;; TODO if there is a selection work within it. ;; Chris Gutteridge (cjg@ecs.soton.ac.uk) ;; At ECS Dept, University of Southampton, England. ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (define (script-fu-pattern-camouflage image drawable detail colour1 colour2 colour3 inSmooth) (gimp-image-undo-group-start image) ; enable undo (set! width (car (gimp-drawable-width drawable))) (set! height (car (gimp-drawable-height drawable))) ;; Save the current background colour so it can be restored when finished (set! old-bg (car (gimp-palette-get-background))) (gimp-layer-add-alpha drawable) (set! baseLayer (car (gimp-layer-new image width height RGBA-IMAGE _"Camouflage Base" 100 NORMAL))) (gimp-image-add-layer image baseLayer 0) (set! thickLayer (car (gimp-layer-new image width height RGBA-IMAGE _"Camouflage Thick" 100 NORMAL))) (gimp-image-add-layer image thickLayer 0) (set! thinLayer (car (gimp-layer-new image width height RGBA-IMAGE _"Camouflage Thin" 100 NORMAL))) (gimp-image-add-layer image thinLayer 0) (gimp-selection-all image) (gimp-palette-set-background colour1) (gimp-drawable-fill baseLayer BG-IMAGE-FILL) ;; ALAN: bugfix gimp1.2.x solid-noise plugin crashed if detail=0 ; (if (< detail 1) (set! detail 1)) (plug-in-solid-noise TRUE image thickLayer 1 0 (rand 65536) 1 detail detail) (plug-in-solid-noise TRUE image thinLayer 1 0 (rand 65536) 1 detail detail) (gimp-threshold thickLayer 127 255) (gimp-threshold thinLayer 145 255) (set! theBlur (- 16 detail)) (gimp-palette-set-background colour2) (gimp-by-color-select thickLayer '(0 0 0) 127 REPLACE TRUE FALSE 0 FALSE) (gimp-edit-clear thickLayer) (gimp-selection-invert image) (gimp-edit-fill thickLayer BG-IMAGE-FILL) (gimp-selection-none image) (if (= inSmooth TRUE) (script-fu-tile-blur image thickLayer theBlur TRUE TRUE FALSE) () ) (gimp-palette-set-background colour3) (gimp-by-color-select thinLayer '(0 0 0) 127 REPLACE TRUE FALSE 0 FALSE) (gimp-edit-clear thinLayer) (gimp-selection-invert image) (gimp-edit-fill thinLayer BG-IMAGE-FILL) (gimp-selection-none image) (if (= inSmooth TRUE) (script-fu-tile-blur image thinLayer (/ theBlur 2) TRUE TRUE FALSE) () ) (gimp-palette-set-background old-bg) ; restore the old background colour (gimp-image-undo-group-end image) ; enable undo (gimp-displays-flush) ) (script-fu-register "script-fu-pattern-camouflage" _"/Filters/Render/Pattern/Camouflage..." _"Camouflage pattern in three colours. Creates three new layers which form a Camouflage like design. " "Chris Gutteridge. Alan Horkan. " ; Authors "Chris Gutteridge, ECS @ University of Southampton, England" ; Copyright "April 2004" ; Date, was "28th April 1998" "RGB*" ; TODO Support for more image types? (ie, convert them to RGB and run) SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 ;; ALAN: bugfix set min=1, solid-noise plugin crashed if detail=0 ;; NOTE: increased max detail to 100, best used only on much larger images SF-ADJUSTMENT _"Detail" '(10 0 100 1 1 0 0) SF-COLOR _"Colour 1" '(33 100 58) SF-COLOR _"Colour 2" '(170 170 60) SF-COLOR _"Colour 3" '(150 115 100) SF-TOGGLE _"Smooth" FALSE )