A script fu wallpaper generator
Message-ID:<4ae5778f$0$31263$426a34cc@news.free.fr>
Subject:
A script-fu wallpaper generator
Date:Mon, 26 Oct 2009 11:19:01 +0100
A simple script-fu wallpaper generator.
A little sample here:
http://pgibe.deviantart.com/art/Gimp-soft-scale-wallpaper-140434798
Comment and criticisms are welcome.
;-)
Paolo
Save as soft_scales.scm:
--8<---- cut here ------------
; scipt-fu for the GIMP 2.4
;
; Simple scales background obtained by:
; 1. generating a plasma
; 2. use mosaic filter
; --deprecated --- 3. make seamless --- add no worth to the background
;
; Paolo Gibellini, 16/09/2009
;
; 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.
;
; References:
;http://www.gimp.org/tutorials/Basic_Scheme/
;http://manual.gimp.org/it/gimp-using-script-fu-tutorial-script.html
;http://docs.gimp.org/it//gimp-using-script-fu-tutorial-first-script.html
;http://en.wikipedia.org/wiki/Scheme_%28programming_language%29
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; script-fu-soft-scales-alfa: add a new layer in the current image
;
(define (script-fu-soft-scales-alfa img drw seed tile-size regularity
tile-type-custom)
(let*
(
; Image dimension
(img-width (car (gimp-image-width img)))
(img-height (car (gimp-image-height img)))
; Create a new layer
(layer-one (car (gimp-layer-new img img-width img-height RGB-IMAGE
"Soft scales Background" 100 NORMAL-MODE)))
;Local variables needs to be defined here, in order to be allowed to
use "set!" statement
(layer-two 0)
(layer-final 0)
; I want my own order in the list, so I must determinate here the Tile
type needed to Mosaic plugin:
; 0 SQUARES, 1 HEXAGONS, 2 OCTAGONS, 3 TRIANGLES
(tile-type (if (= tile-type-custom 0) 2 (if (= tile-type-custom 2) 0
tile-type-custom)))
)
(gimp-image-undo-disable img)
(gimp-image-add-layer img layer-one -1)
;Image generation
(plug-in-plasma 1 img layer-one seed 0.5)
;(plug-in-make-seamless 1 img layer-one) ; Deprectated due to the
insane edge effect
; A copy for the filter, above the plasma
(set! layer-two (car (gimp-layer-copy layer-one TRUE)))
(gimp-image-add-layer img layer-two -1)
; Grained mosaic on the copy
(plug-in-mosaic 1 img layer-two tile-size 5 1.5 regularity 1 135.0 0.2
1 1 tile-type 1 0)
; Merge the mosaic on the plasma
(set! layer-final (car (gimp-image-merge-down img layer-two 0)))
(gimp-image-set-active-layer img layer-final)
(gimp-image-undo-enable img)
(gimp-displays-flush img)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; script-fu-soft-scales: create a new image and invokes
script-fu-soft-scales-alfa
;
(define (script-fu-soft-scales width height seed tile-size regularity
tile-type-custom)
(let*
(
; Create a new image of given size
(img (car (gimp-image-new width height RGB)))
(drw (car (gimp-image-active-drawable img)))
)
; Invokes script-fu-soft-scales-alfa and show the image
(script-fu-soft-scales-alfa img drw seed tile-size regularity
tile-type-custom)
(gimp-display-new img)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Registration in Gimp of both the scripts
;
(script-fu-register
"script-fu-soft-scales"
_"Soft _Scales.."
"Creates a background with soft scales effect"
"Paolo Gibellini <p.gibellini@gmail.com>"
"Paolo Gibellini"
"2009, Sep"
""
SF-ADJUSTMENT _"Image width" '(1024 320 4096 1 10 0 1)
SF-ADJUSTMENT _"Image height" '(768 200 4096 1 10 0 1)
SF-ADJUSTMENT _"Random seed" '(123456 1 999999999 10 100 0 1)
SF-ADJUSTMENT _"Tile size" '(50 5 150 1 10 0 1)
SF-ADJUSTMENT _"Regularity [Highly perturbed 0 <---> 1 No
deformation]" '(0.8 0 1 0.01 0.1 2 0)
;SF-ADJUSTMENT _"Tile type: 0 SQUARES, 1 HEXAGONS, 2 OCTAGONS, 3
TRIANGLES" '(2 0 3 1 1 0 1)
SF-OPTION _"Tile type" '("OCTAGONS" "HEXAGONS" "SQUARES" "TRIANGLES")
;SF-COLOR _"Base Color" '(150 255 160)
)
(script-fu-register
"script-fu-soft-scales-alfa"
_"Soft _Scales.."
"Creates a background with soft scales effect"
"Paolo Gibellini <p.gibellini@gmail.com>"
"Paolo Gibellini"
"2009, Sep"
""
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT _"Random seed" '(123456 1 999999999 10 100 0 1)
SF-ADJUSTMENT _"Tile size" '(50 5 150 1 10 0 1)
SF-ADJUSTMENT _"Regularity [Highly perturbed 0 <---> 1 No
deformation]" '(0.8 0 1 0.01 0.1 2 0)
;SF-ADJUSTMENT _"Tile type: 0 SQUARES, 1 HEXAGONS, 2 OCTAGONS, 3
TRIANGLES" '(2 0 3 1 1 0 1)
SF-OPTION _"Tile type" '("OCTAGONS" "HEXAGONS" "SQUARES" "TRIANGLES")
;SF-COLOR _"Base Color" '(150 255 160)
)
(script-fu-menu-register "script-fu-soft-scales"
"<Image>/File/Create/Backgrounds")
(script-fu-menu-register "script-fu-soft-scales-alfa"
"<Toolbox>/Xtns/Custom/Backgrounds")



RSS News Feed