; The GIMP -- an image manipulation program ; Copyright (C) 1995 Spencer Kimball and Peter Mattis ; ; Tile Pattern shades script (easy version) for GIMP 1.2 ; Copyright (C) 2001 Iccii ; ; -------------------------------------------------------------------- ; version 0.1 by Iccii 2001/12/21 ; - Initial relase ; version 0.1a by Iccii 2001/12/31 ; - Added Lighting degree option ; version 0.2 by 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. ; ;; Brick wall script (define (script-fu-brick-wall img ;; Target Image drawable ;; Target Drawable (Layer) size ;; Brick wall block size direction ;; Horizontal or Vectrical style ;; Brick wall style degree ;; Lighting angle in degree ) (define (list-ref l n) (nth n l)) (define (draw-block-line layer) (let* ((w-size (* 2 size)) (strokes (cons-array 4 'double)) (old-brush (car (gimp-brushes-get-brush)))) (gimp-drawable-fill layer WHITE-FILL) (gimp-brushes-set-brush "Circle (01)") (gimp-palette-set-foreground '(127 127 127)) (aset strokes 0 0) (aset strokes 1 (/ size 2)) (aset strokes 2 w-size) (aset strokes 3 (/ size 2)) (gimp-paintbrush layer 0 4 strokes PAINT-CONSTANT 0) (aset strokes 0 0) (aset strokes 1 (+ (/ size 2) size)) (aset strokes 2 w-size) (aset strokes 3 (+ (/ size 2) size)) (gimp-paintbrush layer 0 4 strokes PAINT-CONSTANT 0) (aset strokes 0 (/ size 2)) (aset strokes 1 (/ size 2)) (aset strokes 2 (/ size 2)) (aset strokes 3 (+ (/ size 2) size)) (gimp-paintbrush layer 0 4 strokes PAINT-CONSTANT 0) (aset strokes 0 (+ (/ size 2) size)) (aset strokes 1 0) (aset strokes 2 (+ (/ size 2) size)) (aset strokes 3 (/ size 2)) (gimp-paintbrush layer 0 4 strokes PAINT-CONSTANT 0) (aset strokes 0 (+ (/ size 2) size)) (aset strokes 1 (+ (/ size 2) size)) (aset strokes 2 (+ (/ size 2) size)) (aset strokes 3 w-size) (gimp-paintbrush layer 0 4 strokes PAINT-CONSTANT 0) (gimp-drawable-offset layer TRUE OFFSET-BACKGROUND (- (/ size 2)) (- (/ size 2))) (gimp-brushes-set-brush old-brush))) (let* ( (old-fg (car (gimp-palette-get-foreground))) (bounds (cdr (gimp-selection-bounds img))) (x1 (car bounds)) (y1 (cadr bounds)) (x2 (car (cddr bounds))) (y2 (cadr (cddr bounds))) (org-width (- x2 x1)) (org-height (- y2 y1)) (tmp-img (car (gimp-image-new org-width org-height RGB))) (tmp-layer1 (car (gimp-layer-new tmp-img org-width org-height RGBA-IMAGE "Dummy1" 100 NORMAL-MODE))) (tmp-layer2 (car (gimp-layer-new tmp-img org-width org-height RGBA-IMAGE "Dummy2" 100 NORMAL-MODE))) (tmp-mask2 (car (gimp-layer-create-mask tmp-layer2 ADD-BLACK-MASK))) (old-selection (if (equal? (car (gimp-selection-is-empty img)) TRUE) 0 (car (gimp-selection-save img)))) (w-size (* size 2)) ) (gimp-image-undo-group-start img) ;(gimp-display-new tmp-img) ;; Initialize (gimp-drawable-fill tmp-layer1 TRANSPARENT-FILL) (gimp-drawable-fill tmp-layer2 TRANSPARENT-FILL) (gimp-image-add-layer tmp-img tmp-layer1 -1) (gimp-image-add-layer tmp-img tmp-layer2 -1) (gimp-layer-add-mask tmp-layer2 tmp-mask2) (gimp-edit-copy drawable) (gimp-floating-sel-anchor (car (gimp-edit-paste tmp-layer1 FALSE))) (gimp-floating-sel-anchor (car (gimp-edit-paste tmp-layer2 FALSE))) ;; レイヤーマスクに一行おきに白黒を (let* ((end (cond ((= direction 0) org-height) ((= direction 1) org-width))) (pos 0)) (while (< pos end) (let* ((x-start (if (= direction 0) 0 pos)) (y-start (if (= direction 1) 0 pos)) (x-end (if (= direction 0) org-width size)) (y-end (if (= direction 1) org-height size))) (gimp-rect-select tmp-img x-start y-start x-end y-end CHANNEL-OP-REPLACE FALSE 0) (if (equal? (car (gimp-selection-is-empty img)) TRUE) (gimp-edit-fill tmp-mask2 WHITE-FILL)) (set! pos (+ pos w-size))))) (gimp-selection-none tmp-img) ;; plug-in-pxelize を tmp-layer1 に適用するため、はみ出ている部分を引き伸ばして着色 (gimp-layer-resize tmp-layer1 (+ org-width size) (+ org-height size) size size) (gimp-rect-select tmp-img 0 0 1 org-height CHANNEL-OP-REPLACE FALSE 0) (gimp-edit-copy tmp-layer1) (set! float (car (gimp-selection-float tmp-layer1 (- size) 0))) (gimp-floating-sel-to-layer float) (gimp-layer-scale float (* size 2) org-height TRUE) (gimp-rect-select tmp-img 0 0 org-width 1 CHANNEL-OP-REPLACE FALSE 0) (gimp-edit-copy tmp-layer1) (set! float (car (gimp-selection-float tmp-layer1 0 (- size)))) (gimp-floating-sel-to-layer float) (gimp-layer-scale float org-width (* size 2) TRUE) (gimp-image-raise-layer-to-top tmp-img tmp-layer2) (set! tmp-layer1 (car (gimp-image-merge-down tmp-img (car (gimp-image-merge-down tmp-img float EXPAND-AS-NECESSARY)) CLIP-TO-BOTTOM-LAYER))) (plug-in-pixelize 1 tmp-img tmp-layer1 w-size) (plug-in-pixelize 1 tmp-img tmp-layer2 w-size) ;; 最終工程1 (set! final-layer (car (gimp-image-merge-visible-layers tmp-img CLIP-TO-IMAGE))) (cond ((= style 1) (plug-in-bump-map 1 tmp-img final-layer final-layer degree 35.0 5 0 0 0 0 TRUE FALSE 0)) ((= style 2) (let* ((style-layer (car (gimp-layer-new tmp-img w-size w-size RGBA-IMAGE "Style Layer" 100 NORMAL-MODE)))) (draw-block-line style-layer) (if (= direction 1) (plug-in-rotate 1 tmp-img style-layer 3 FALSE)) (plug-in-tile 1 tmp-img style-layer org-width org-height FALSE) (plug-in-bump-map 1 tmp-img final-layer style-layer degree 45.0 3 0 0 0 0 TRUE FALSE 0))) ) ; end of cond ;; 最終工程2 (if (equal? old-selection TRUE) (gimp-selection-load old-selection)) (gimp-edit-copy final-layer) (gimp-floating-sel-anchor (car (gimp-edit-paste drawable TRUE))) (if (equal? old-selection TRUE) (begin (gimp-selection-load old-selection) (gimp-image-remove-channel img old-selection))) (gimp-palette-set-foreground old-fg) (gimp-image-undo-group-end img) (gimp-displays-flush) ) ; end of let* ) (script-fu-register "script-fu-brick-wall" "/Script-Fu/Alchemy/Brick Wall..." "Effects like a brick wall" "Iccii " "Iccii" "2001, Nov" "RGB* GRAY*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-ADJUSTMENT "Size" '(8 1 100 1 10 0 1) SF-OPTION "Direction" '("Horizontal" "Vertical") SF-OPTION "Brick Style" '("Flat" "Embedded" "Brick") SF-ADJUSTMENT "Lighting (degrees)" '(135 0 360 1 10 0 0) )