; Metal Mesh rel 0.01 ; Created by Graechan ; You will need to install GMIC to run this Scipt ; GMIC can be downloaded from http://sourceforge.net/projects/gmic/files/ ; Comments directed to http://gimpchat.com or http://gimpscripts.com ; ; License: GPLv3 ; 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 3 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. ; ; To view a copy of the GNU General Public License ; visit: http://www.gnu.org/licenses/gpl.html ; ; ; ------------ ;| Change Log | ; ------------ ; Rel 0.01 - Initial Release ; ; Gradients blend direction list (define list-blend-dir '("Left to Right" "Top to Bottom" "Diagonal to centre" "Diagonal from centre")) ; ; Include layer Procedure (define (mesh-include-layer image newlayer oldlayer stack) ;stack 0=above 1=below (cond ((defined? 'gimp-image-get-item-position) ;test for 2.8 compatability (gimp-image-insert-layer image newlayer (car (gimp-item-get-parent oldlayer)) (+ (car (gimp-image-get-item-position image oldlayer)) stack)) ;For GIMP 2.8 ) (else (gimp-image-add-layer image newlayer (+ (car (gimp-image-get-layer-position image oldlayer)) stack)) ;For GIMP 2.6 ) ) ;end cond ) ;end include layer procedure ; ;find layer by name proceedure (define (mesh-find-layer-by-name image layerName) (let* ( (layerList (vector->list (cadr (gimp-image-get-layers image)))) (wantedLayerId -1) (layerId 0) (layerText "") ) (while (not (null? layerList)) (set! layerId (car layerList)) (set! layerText (cond ((defined? 'gimp-image-get-item-position) (car (gimp-item-get-name layerId))) (else (car (gimp-drawable-get-name layerId))))) (if (string=? layerText layerName) (set! wantedLayerId layerId)) (set! layerList (cdr layerList))) ;endwhile (if (= -1 wantedLayerId) (error (string-append "Could not find a layer with name:- " layerName))) (list wantedLayerId) ) ;end variables ) ;end find layer by name proceedure ; (define (script-fu-metal-mesh image layer type size keep-selection-in conserve ) (gimp-image-undo-group-start image) (let* ( (width (car (gimp-image-width image))) (height (car (gimp-image-height image))) (original-width width) (original-height height) (area (* 1000 1000)) (alpha (car (gimp-drawable-has-alpha layer))) (sel (car (gimp-selection-is-empty image))) (layer-name (cond ((defined? 'gimp-image-get-item-position) (car (gimp-item-get-name layer))) (else (car (gimp-drawable-get-name layer))))) (active-gradient (car (gimp-context-get-gradient))) (active-fg (car (gimp-context-get-foreground))) (active-bg (car (gimp-context-get-background))) (keep-selection keep-selection-in) (selection-channel 0) (ver 2.8) (bkg-layer 0) (bkg-copy 0) (grid-layer 0) (pattern-layer 0) (bump-channel 0) (shadow-layer 0) (background 0) (type (cond ((= type 0) 1) ((= type 1) 0) (type))) ) (cond ((not (defined? 'gimp-image-get-item-position)) (set! ver 2.6))) ;define the gimp version (gimp-context-push) (gimp-context-set-paint-method "gimp-paintbrush") (cond ((defined? 'gimp-context-set-dynamics) (gimp-context-set-dynamics "Dynamics Off"))) (gimp-context-set-foreground '(0 0 0)) (gimp-context-set-background '(255 255 255)) (if (= alpha FALSE) (gimp-layer-add-alpha layer)) ;;;;check that a selection was made if not make one (if (= sel TRUE) (set! keep-selection FALSE)) (if (= sel TRUE) (begin (cond ((= ver 2.8) (gimp-image-select-item image 2 layer)) (else (gimp-selection-layer-alpha layer)) ) ;endcond ) ) ;;;;create selection-channel (gimp-selection-load selection-channel) (set! selection-channel (car (gimp-selection-save image))) (cond ((= ver 2.8) (gimp-item-set-name selection-channel "selection-channel")) (else (gimp-drawable-set-name selection-channel "selection-channel")) ) ;endcond (gimp-image-set-active-layer image layer) (cond((= sel FALSE) (gimp-edit-clear layer)) (else (gimp-selection-none image)) ) ;endcond ;;;;begin the script (set! bkg-layer (car (gimp-layer-new image width height RGBA-IMAGE "Background" 100 NORMAL-MODE))) (mesh-include-layer image bkg-layer layer 1) ;stack 0=above 1=below (plug-in-plasma 1 image bkg-layer 0 1.0) (set! bkg-copy (car (gimp-layer-copy bkg-layer TRUE))) (mesh-include-layer image bkg-copy bkg-layer 0) ;stack 0=above 1=below (gimp-layer-set-mode bkg-copy SCREEN-MODE) (set! grid-layer (car (gimp-layer-new image width height RGBA-IMAGE "Grid" 100 NORMAL-MODE))) (mesh-include-layer image grid-layer bkg-copy 0) ;stack 0=above 1=below (plug-in-grid 1 image grid-layer 1 2 0 "Black" 255 1 2 0 "Black" 255 1 2 0 "Black" 255) (set! pattern-layer (car (gimp-layer-new image width height RGBA-IMAGE "Pattern" 100 NORMAL-MODE))) (mesh-include-layer image pattern-layer grid-layer 0) ;stack 0=above 1=below (gimp-context-swap-colors) (gimp-drawable-fill pattern-layer FOREGROUND-FILL) (plug-in-mosaic 1 image pattern-layer ;drawable size ;tile-size 1 ;tile-height (/ size 4) ;tile-spacing 1 ;tile-neatness FALSE ;tile-allow-split 135 ;light-dir 0 ;color-variation TRUE ;antialiasing FALSE ;color-averaging type ;tile-type Tile geometry { SQUARES (0), HEXAGONS (1), OCTAGONS (2), TRIANGLES (3) } 0 ;tile-surface 0) ;Grout color (black/white or fore/background) { BW (0), FG-BG (1) } (cond ((= ver 2.8) (gimp-image-select-item image 2 pattern-layer)) (else (gimp-selection-layer-alpha pattern-layer)) ) ;endcond (gimp-edit-clear pattern-layer) (gimp-selection-invert image) ;;;;create bump-channel (gimp-selection-load bump-channel) (set! bump-channel (car (gimp-selection-save image))) (cond ((= ver 2.8) (gimp-item-set-name bump-channel "bump-channel")) (else (gimp-drawable-set-name bump-channel "bump-channel")) ) ;endcond (plug-in-gauss-rle2 RUN-NONINTERACTIVE image bump-channel 15 15) (gimp-image-set-active-layer image pattern-layer) (gimp-context-set-background '(128 128 128)) (gimp-edit-blend pattern-layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 3 0.2 TRUE (/ width 2) 0 (/ width 2) height) (gimp-selection-none image) (plug-in-bump-map RUN-NONINTERACTIVE image pattern-layer bump-channel 135 45 32 0 0 0 0 TRUE FALSE 0) (plug-in-alienmap2 1 image pattern-layer 1 0 1 0 1 0 0 TRUE TRUE TRUE) (script-fu-drop-shadow image pattern-layer 4 4 15 '(0 0 0) 80 FALSE) (set! shadow-layer (car(mesh-find-layer-by-name image "Drop Shadow"))) (gimp-layer-resize-to-image-size shadow-layer) ;;;;finish the script (if (= conserve FALSE) (begin (set! background (car (gimp-image-merge-down image pattern-layer EXPAND-AS-NECESSARY))) (set! background (car (gimp-image-merge-down image background EXPAND-AS-NECESSARY))) (set! background (car (gimp-image-merge-down image background EXPAND-AS-NECESSARY))) (set! background (car (gimp-image-merge-down image background EXPAND-AS-NECESSARY))) (cond ((= ver 2.8) (gimp-item-set-name background (string-append "Metal-Mesh" "\nBackground"))) (else (gimp-drawable-set-name background (string-append "Metal-Mesh" "\nBackground"))) ) ;endcond (if (= sel FALSE) (begin (set! layer (car (gimp-image-merge-down image layer EXPAND-AS-NECESSARY))) (cond ((= ver 2.8) (gimp-item-set-name layer (string-append layer-name "\nMetal-Mesh"))) (else (gimp-drawable-set-name layer (string-append layer-name "\nMetal-Mesh"))) ) ;endcond )) ;endif )) ;endif (if (= keep-selection TRUE) (gimp-selection-load selection-channel)) (if (= conserve FALSE) (gimp-image-remove-channel image selection-channel)) (if (= conserve FALSE) (gimp-image-remove-channel image bump-channel)) (gimp-displays-flush) (gimp-image-undo-group-end image) (gimp-context-pop) ) ) (script-fu-register "script-fu-metal-mesh" "Metal Mesh..." "can create a 'Metal Mesh' background to selected layer or a fill for selection" "Graechan" "Graechan - http://gimpchat.com" "2012" "RGB*" SF-IMAGE "image" 0 SF-DRAWABLE "drawable" 0 SF-OPTION "Tile geometry" '("HEXAGONS" "SQUARES" "OCTAGONS" "TRIANGLES") SF-ADJUSTMENT "Size" '(64 4 100 1 10 0 0) SF-TOGGLE "Keep selection" FALSE SF-TOGGLE "Keep the Layers" FALSE ) (script-fu-menu-register "script-fu-metal-mesh" "/Filters/Render/Pattern")