;; -*-scheme-*- ;; Chris Gutteridge (cjg@ecs.soton.ac.uk) ;; At ECS Dept, University of Southampton, England. ;; (Chris reused some code from his camouflage script) ;; 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-render-map image drawable seed randomise detail widen gradient use-current-gradient) ;; backup the palette colours and old gradient so they can be restored later (set! foreground-old (car (gimp-palette-get-foreground))) (set! background-old (car (gimp-palette-get-background))) (set! gradient-old (car (gimp-gradients-get-gradient))) ;; use current gradient or use gradient specified by this script (if (= use-current-gradient FALSE) (gimp-gradients-set-gradient gradient)) ;; abstracted these to make changes easier in future (set! x-scale detail) (set! y-scale detail) ;; randomise, ignore input seed. (if (= randomise TRUE) (set! seed (rand 65536)) ) ;; make the effect undoable (gimp-image-undo-group-start image) (if (= (car (gimp-selection-is-empty image)) TRUE) (gimp-selection-all image) ) ;; copy the original layer or selection (gimp-edit-copy drawable) ;; set this as layer one, even if it is not a proper layer yet (set! layer-1 (car (gimp-edit-paste drawable FALSE))) (gimp-floating-sel-to-layer layer-1) ;; but it is now ;; dont want a layer called "Pasted Layer", so change it (gimp-drawable-set-name layer-1 _"Rendered Map Layer") ; N.B. not 1.2 compatible ;; Changed unhelpful amusing but ridiculous layer name: "I've got more rubber ducks than you!" ; (set! layer-1 (car (gimp-layer-new image width height RGBA_IMAGE _"Rendered Map Layer" 100 NORMAL))) ; (gimp-image-add-layer image layer-1 0) (plug-in-solid-noise TRUE image layer-1 1 0 seed detail x-scale y-scale) (if (= widen 1) (begin (set! thinLayer (car (gimp-layer-copy layer-1 TRUE))) (gimp-drawable-set-name thinLayer _"Thin Layer") (gimp-image-add-layer image thinLayer 0) (let ((big-grain (min 15 (* 2 detail)))) (plug-in-solid-noise TRUE image thinLayer 1 0 seed big-grain big-grain big-grain) ) (gimp-palette-set-background '(255 255 255)) (gimp-palette-set-foreground '(0 0 0)) (let ((layer-mask (car (gimp-layer-create-mask thinLayer 0)))) (gimp-image-add-layer-mask image thinLayer layer-mask) (set! height (car (gimp-drawable-height layer-1))) (gimp-edit-blend layer-mask FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-TRIANGULAR FALSE FALSE 0 0 TRUE 0 0 0 (/ height 2)) ) ;; dont want the whole image flattened. keep things more flexible ;(set! layer-1 (car (gimp-image-flatten image))) (set! layer-1 (car (gimp-image-merge-down image thinLayer 0))) )) (gimp-selection-none image) (plug-in-gradmap TRUE image layer-1) ;; restore the old gradient and palette colours (gimp-gradients-set-gradient gradient-old) (gimp-palette-set-background background-old) (gimp-palette-set-foreground foreground-old) (gimp-image-undo-group-end image) (gimp-displays-flush) ) (script-fu-register "script-fu-pattern-render-map" ;; group by functionality (with patterns) not implementation (script-fu). _"/Filters/Render/Pattern/Render Map..." _"Another pattern which resembles a map. Uses the Solid Noise Plug-in: 'Filters, Render, Clouds, Solid Noise...'. Random Seed allows you to specify the seed value for the Solid Noise Plug-in. Randomise option ignores the Random Seed and chooses a different value. Works within Selection if there is one. " "Chris Gutteridge. Alan Horkan. " "Alan Horkan. Chris Gutteridge. ECS, University of Southampton, England. " "2004 04 02 UTC" ; was "28th April 1998" "RGB*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-ADJUSTMENT _"Random Seed" '(85 0 99999999 1 10 0 1) ;; max, any INT32 SF-TOGGLE _"Randomise" FALSE SF-ADJUSTMENT _"Detail" '(5 1 15 1 1 0 0) ; was labelled Granularity. ; changed min. from 0 to 1 to prevent errors in 1.2.x and because it looked lame ; changed max. from 15 but had to change it back, noise plugin is limited to 15 ; changed the default from 4 to 5 for no particular reason. looks busier! SF-OPTION _"Behaviour" '(_"Tile " _"Detail in Middle ") SF-GRADIENT _"Gradient" "Land and Sea" ;; was "Land_and_Sea" in v1.2 SF-TOGGLE _"Use Current Gradient" FALSE ) ;; ALAN: works on current image, and or current selection. Undoable. ;; DONE: added ability to specify the random seed. ;; enables users to consistantly recreate patterns they like ;; DONE added 'Randomise' an option to ignore specified and use random instead. ;; ie just like the old behaviour ;; DONE: added option use current gradient ;; DONE forward ported to GIMP 2.0 ;; doesn't work well if gradients are not preloaded, 'gimp --no-data' ;; (gimp 1.2 issue, gimp 2 seems to force the gradients to be loaded at the expense of startup speed) ;; TODO 'Gradient Reverse' option added in version 2.0 ;; would have copied it already, but it doesn't seem to actually do anything