;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; SCRIPT-FU-RANDOM-BRUSH produces an image of a random brush stamps
; version 1.0 12/2/2010
; Copyright (c) 2010 Daniel Wilkerson
;
;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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;
;Copy of the license at http://td-e.com/site/gpl.php
(define (script-fu-random-brush curr-layer numStamps tempbrush brushColor isRandomColor)
(let* (
; Save the foreground & background colors
(old-fg (car (gimp-palette-get-foreground)))
(old-bg (car (gimp-palette-get-background)))
(old-brush (car (gimp-context-get-brush)))
(width (car (gimp-drawable-width curr-layer)))
(height (car (gimp-drawable-height curr-layer)))
(image (car (gimp-drawable-get-image curr-layer)))
(layer-one (car (gimp-layer-new image width height RGB-IMAGE "Stamps" 100 NORMAL-MODE)))
(ii 0)
(ns 0)
(xs 0)
(ys 0)
(randomColor '(100 100 100))
(pixw (cons-array 2 'byte))
)
(srand (realtime))
(gimp-image-undo-disable image)
(gimp-image-add-layer image layer-one 0)
(gimp-context-set-foreground brushColor)
(gimp-layer-add-alpha layer-one)
(gimp-drawable-fill layer-one 3) ;0 FG, 1 BG, 2 white, 3 trans
(gimp-context-set-brush (car tempbrush))
;generating stamps
(while (< ns numStamps)
(set! ns (+ ns 1))
(set! xs (rand width))
(set! ys (rand height))
(aset pixw 0 (rand width))
(aset pixw 1 (rand height))
(if (= isRandomColor TRUE)
(set! randomColor (gimp-image-pick-color image curr-layer xs ys FALSE FALSE 1))
); end if
(if (= isRandomColor TRUE)
(gimp-context-set-foreground randomColor)
);
(gimp-paintbrush-default layer-one 2 pixw)
; preparing the exit of the loop
(set! ii (+ ii 1))
(if (> ii 10000) (set! ns numStamps))
) ; end of loop
; Restore the old foreground & brush
(gimp-context-set-foreground old-fg)
(gimp-context-set-brush old-brush)
;(gimp-display-new image)
(gimp-image-undo-enable image)
)
)
(script-fu-register "script-fu-random-brush"
"<Toolbox>/Xtns/Script-Fu/Patterns/Random Brush"
"Creates a Random Brush pattern."
"D. Wilkerson"
"D. Wilkerson"
"2010.12.02"
""
SF-DRAWABLE "Image" 0
SF-ADJUSTMENT "Number of Stamps" '(400 1 10000 10 10 0 1)
SF-BRUSH "Brush" '("Circle (03)" 100 44 0)
SF-COLOR "Color" '(0 102 255)
SF-TOGGLE "Random Colors" TRUE
)