; The GIMP -- an image manipulation program ; Copyright (C) 1995 Spencer Kimball and Peter Mattis ; ; Patchwork effect script for GIMP 1.2 ; Copyright (C) 2001 Iccii ; ; -------------------------------------------------------------------- ; version 0.1 by Iccii 2001/07/12 ; - Initial relase ; version 0.2 by Iccii 2001/07/14 ; - Change to better algorithm ; version 0.3 by Iccii 2001/07/16 ; - Add the round option to create round tile ; version 0.4 by Iccii 2001/07/19 ; - Add Tile Type options to select tile type ; version 0.5 by Iccii 2001/10/01 ; - Changed menu path because this script attempts to PS's filter ; - Added Angle option ; version 0.5a by Iccii 2001/10/02 ; - Fixed bug in keeping transparent area ; version 0.5b by Iccii 2001/10/02 ; - Fixed bug (get error when drawable doesn't have alpha channel) ; version 0.5c by Raymond Ostertag 2004/09 ; - 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-patchwork img ;; 対象画像 drawable ;; 対象レイヤー type ;; タイルの種類 size ;; タイルの大きさ depth ;; タイルの深度 angle ;; バンプマップの角度 level ;; タイルのばらつき度 ) (gimp-undo-push-group-start img) (let* ( (width (car (gimp-drawable-width drawable))) (height (car (gimp-drawable-height drawable))) (old-fg (car (gimp-palette-get-foreground))) (old-selection (car (gimp-selection-save img))) (tmp-layer1 (car (gimp-layer-copy drawable TRUE))) (tmp-layer2 (car (gimp-layer-copy drawable TRUE))) (depth-color (list depth depth depth)) (radius (- (/ size 2) 1)) (blur (cond ((= type 0) 1) ((= type 1) 0) ((= type 2) 0) ((= type 3) 0))) (hwidth (cond ((= type 0) 1) ((= type 1) 0) ((= type 2) 2) ((= type 3) 1))) (vwidth (cond ((= type 0) 1) ((= type 1) 2) ((= type 2) 0) ((= type 3) 1))) ) ; end variable definition ;; 一時的なレイヤー追加 (gimp-desaturate tmp-layer2) (if (eqv? (car (gimp-selection-is-empty img)) FALSE) (begin (gimp-selection-invert img) (gimp-edit-clear tmp-layer2) (gimp-selection-invert img))) (gimp-image-add-layer img tmp-layer1 -1) (gimp-image-add-layer img tmp-layer2 -1) ;; 一時的なレイヤーへ順番にフィルタ処理を行う (plug-in-noisify 1 img tmp-layer2 FALSE 1.0 1.0 1.0 0) (plug-in-pixelize 1 img tmp-layer1 size) (plug-in-pixelize 1 img tmp-layer2 size) (gimp-levels tmp-layer2 VALUE-LUT (+ 32 (* level 2)) (- 223 (* level 2)) 1.0 0 255) (plug-in-grid 1 img tmp-layer2 hwidth size 0 depth-color 255 vwidth size 0 depth-color 255 0 0 0 '(0 0 0) 255) ;; 丸めるオプションを有効にした場合 (if (= type 3) (let* ((selection-channel (car (gimp-selection-save img)))) (gimp-palette-set-foreground depth-color) (gimp-by-color-select tmp-layer2 depth-color 0 REPLACE FALSE 0 0 FALSE) (gimp-selection-grow img radius) (gimp-selection-shrink img radius) (gimp-edit-fill tmp-layer2 FG-IMAGE-FILL) (gimp-selection-load selection-channel) (gimp-image-remove-channel img selection-channel) (gimp-image-set-active-layer img tmp-layer2) ;; why do I need this line? (gimp-palette-set-foreground old-fg))) (plug-in-gauss-iir2 1 img tmp-layer2 (+ blur hwidth) (+ blur vwidth)) (plug-in-bump-map 1 img tmp-layer2 tmp-layer2 angle 30 (+ 4 level) 0 0 0 0 TRUE FALSE LINEAR) ;; 一時的なレイヤーの調整、結合 (gimp-layer-set-mode tmp-layer2 OVERLAY-MODE) (gimp-layer-set-opacity tmp-layer2 (+ level 84)) (set! final-layer (car (gimp-image-merge-down img tmp-layer2 EXPAND-AS-NECESSARY))) (if (eqv? (car (gimp-drawable-has-alpha drawable)) TRUE) (gimp-selection-layer-alpha drawable)) (if (eqv? (car (gimp-selection-is-empty img)) FALSE) (begin (gimp-selection-invert img) (gimp-edit-clear final-layer))) (gimp-selection-load old-selection) (gimp-edit-copy final-layer) (gimp-image-remove-layer img final-layer) (gimp-floating-sel-anchor (car (gimp-edit-paste drawable 0))) (gimp-selection-load old-selection) (gimp-image-remove-channel img old-selection) ;; 後処理 (gimp-palette-set-foreground old-fg) (gimp-undo-push-group-end img) (gimp-displays-flush) ) ; end of let* ) ; end of define (script-fu-register "script-fu-patchwork" "/Script-Fu/Alchemy/Patchwork..." "Creates patchwork image, which simulates Photoshop's Patchwork filter" "Iccii " "Iccii" "2001, Oct" "RGB*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-OPTION "Tile Type" '("Normal" "Horizontal" "Vertical" "Round") SF-ADJUSTMENT _"Block Size" '(10 2 127 1 10 0 1) SF-ADJUSTMENT _"Depth" '(127 0 255 1 10 0 1) SF-ADJUSTMENT _"Angle" '(135 0 360 1 10 0 0) SF-ADJUSTMENT _"Level" '(8 0 16 1 2 0 0) )