; The GIMP -- an image manipulation program ; Copyright (C) 1995 Spencer Kimball and Peter Mattis ; ; Random Dots script for GIMP 1.2 ; Copyright (C) 2001 Iccii ; ; -------------------------------------------------------------------- ; - Changelog - ; version 0.1 2001/06/21 iccii ; - Initial relase ; version 0.1a 2001/06/22 iccii ; - Add Square option ; version 0.1b 2001/09/26 iccii ; - Add Linear option ; version 0.2 Raymond Ostertag 2004/09 ; - Ported to Gimp2 ; - Changed menu entry ; -------------------------------------------------------------------- ; ; 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-random-dots inSize ; 大きさ inOption ; 種類 inRepeat ; 繰り返し inLimit ; 半径の制限 inInvert ; 色を反転させるか? ) ;; inStart から inEnd までのランダムな数を返す (define (get-random-coordinate inStart inEnd) (+ inStart (rand (- inEnd inStart)))) (let* ( (count 0) (old-fg (car (gimp-palette-get-foreground))) (old-bg (car (gimp-palette-get-background))) (theWidth inSize) (theHeight inSize) (theRadius (max theWidth theHeight)) (theImage (car (gimp-image-new theWidth theHeight RGB))) (theLayer (car (gimp-layer-new theImage theWidth theHeight RGB-IMAGE "Background" 100 NORMAL-MODE))) ) (gimp-image-undo-disable theImage) (gimp-image-add-layer theImage theLayer -1) (gimp-palette-set-foreground '(255 255 255)) (gimp-palette-set-background '(0 0 0)) (gimp-drawable-fill theLayer BACKGROUND-FILL) (while (< count inRepeat) (cond ;; Radius ((= inOption 0) (let* ((x-coordinate (get-random-coordinate 0 (- theWidth 1))) (y-coordinate (get-random-coordinate 0 (- theHeight 1)))) (gimp-edit-blend theLayer FG-BG-RGB-MODE LIGHTEN-ONLY-MODE GRADIENT-RADIAL 100 0 REPEAT-NONE FALSE FALSE 0 0.20 FALSE x-coordinate y-coordinate (+ x-coordinate (get-random-coordinate (/ theRadius inLimit) (/ theRadius inLimit inLimit))) (+ y-coordinate (get-random-coordinate (/ theRadius inLimit) (/ theRadius inLimit inLimit))))) ) ;; Square ((= inOption 1) (let* ((x-coordinate (get-random-coordinate 0 (- theWidth 1))) (y-coordinate (get-random-coordinate 0 (- theHeight 1)))) (gimp-edit-blend theLayer FG-BG-RGB-MODE LIGHTEN-ONLY-MODE GRADIENT-SQUARE 100 0 REPEAT-NONE FALSE FALSE 0 0.20 FALSE x-coordinate y-coordinate (+ x-coordinate (get-random-coordinate (/ theRadius inLimit) (/ theRadius inLimit inLimit))) (+ y-coordinate (get-random-coordinate (/ theRadius inLimit) (/ theRadius inLimit inLimit))))) ) ;; Linear ((= inOption 2) (let* ((x-coordinate (get-random-coordinate 0 (- theWidth 1))) (y-coordinate (get-random-coordinate 0 (- theHeight 1)))) (gimp-edit-blend theLayer FG-BG-RGB-MODE DIFFERENCE-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0.20 FALSE x-coordinate y-coordinate (+ x-coordinate (get-random-coordinate (/ theRadius inLimit -1) (/ theRadius inLimit))) (+ y-coordinate (get-random-coordinate (/ theRadius inLimit -1) (/ theRadius inLimit))))) ) ) (set! count (+ count 1)) ) (if (equal? inInvert TRUE) (gimp-invert theLayer)) (gimp-palette-set-foreground old-fg) (gimp-palette-set-background old-bg) (gimp-image-undo-enable theImage) (gimp-display-new theImage) (gimp-displays-flush) ) ) ; 登録など (script-fu-register "script-fu-random-dots" "/Xtns/Script-Fu/Misc/Random Dots..." "random dots" "Iccii " "Iccii" "Sep, 2001" "" SF-ADJUSTMENT _"Image Size" '(256 1 1024 1 10 0 1) SF-OPTION _"Seed" '(_"Radius" _"Square" _"Linear") SF-ADJUSTMENT _"Number" '(50 1 128 1 5 0 0) SF-ADJUSTMENT _"Radius" '(8.0 1.1 32 0.1 1.0 1 0) SF-TOGGLE _"Invert" FALSE )