;; -*-scheme-*- ;; Land --- create a pattern that resembles a Topographic map ;; Copyright (C) 1997 Adrian Karstan Likins. ;; Thanks to Frederico Mena Quintero (Quartic) for helping me debug this. ;; ;; 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-land image drawable seed randomise detail land-height sea-depth x-scale y-scale gradient use-current-gradient) ;; make the effect undoable (gimp-image-undo-group-start image) ;; save current gradient (set! gradient-saved (car (gimp-gradients-get-gradient))) ;; use the gradient specified by this script? (if (= use-current-gradient FALSE) (gimp-gradients-set-gradient gradient)) ;; randomise, ignore input seed. use randomely generated seed instead (if (= randomise TRUE) (set! seed (rand 65536)) ) ;; copy the original layer or selection to a new layer (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 _"Noise Layer") ; not v1.2 compatible (set! turbulent TRUE) (set! tileable TRUE) (plug-in-solid-noise 1 image layer-1 turbulent tileable seed detail x-scale y-scale) (plug-in-c-astretch 1 image layer-1) ;; copy layer-1 to create layer-2 (set! layer-2 (car (gimp-layer-copy layer-1 TRUE))) (gimp-image-add-layer image layer-2 -1) (gimp-drawable-set-name layer-2 _"Land Layer") ; not v1.2 compatible ; this is not actually necessary, layer-2 was the last used and still active (gimp-image-set-active-layer image layer-2) ; map (overdraw using) the coloured gradient (plug-in-gradmap 1 image layer-2) (gimp-by-color-select layer-1 '(190 190 190) 55 REPLACE FALSE FALSE 0 FALSE) (plug-in-bump-map 1 image layer-2 layer-1 135.0 35 land-height 0 0 0 0 TRUE FALSE 0) ;(plug-in-c-astretch 1 image layer-2) (gimp-selection-invert image) (plug-in-bump-map 1 image layer-2 layer-1 135.0 35 sea-depth 0 0 0 0 TRUE FALSE 0) ;(plug-in-c-astretch 1 image layer-2) ;; merge/remove? I prefer merge when using a mostly transparent gradient ;; results are more interesting and consistant with the old version of the script ;(gimp-image-remove-layer image layer-1) ; remove it ;(gimp-image-merge-down image layer-2 0) ; merge it ;; (un)comment the next line if you do (not) want to keep a selection of the "land" (gimp-selection-none image) ;; restore gradient (gimp-gradients-set-gradient gradient-saved) (gimp-image-undo-group-end image) (gimp-displays-flush) ) (script-fu-register "script-fu-pattern-land" _"/Filters/Render/Pattern/Land..." ; put in menus with other patterns "Create a Topographic map pattern. Recommended gradients: 'Land' gradient produces a landscape that looks like Earth. 'Brushed_aluminum' gradient produces a landscape that looks like the Moon. 'Browns' gradient produces a landscape that looks like Mars. " "Alan Horkan. Adrian Karstan Likins. " "Alan Horkan. Adrian Karstan Likins. " "2004 04 02" ; UTC format Dates. "RGB*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-ADJUSTMENT _"Random Seed" '(42 0 99999999 1 10 0 1) ; seed can be any INT32 SF-TOGGLE _"Randomise" FALSE SF-ADJUSTMENT _"Detail" '(4 0 15 1 5 0 0) ; detail must be 0-15 SF-ADJUSTMENT _"Land Height" '(60 1 65 1 10 0 0) SF-ADJUSTMENT _"Sea Depth" '(4 1 65 1 10 0 0) SF-ADJUSTMENT _"Scale X" '(4 0.1 16 1 5 0.1 0) SF-ADJUSTMENT _"Scale Y" '(4 0.1 16 1 5 0.1 0) SF-GRADIENT _"Gradient" "Land 1" ;; was "Land_1" in version 1.2 SF-TOGGLE _"Use Current Gradient" FALSE ) ;; ALAN: rewrote script to work on current image ;; ALAN: added Undo support ;; ALAN: rewrote even more to work on current selection (or not) ;; ALAN: added save and restore of current gradient ;; ALAN: added option use current gradient ;; ALAN: ported to 2.0 but kept the 1.2 information in comments. ;; ALAN: later split out the deprecated v1.2 information ;; Question: How much code can be reused as just fair use? ;; How much code must be rewritten for the GPL to no longer apply? ;; My work should be considered public domain, ;; Ask previous authors about licensing not me.