; Emap rel 0.01 ; Created by Graechan using the 'Environment script' from GnuTux and a highlight technique from Espers 'Science Labs' ; the default Logo font is from http://www.fontstock.net/10277/pt-banana-split.html ; 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 (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 (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-emap-logo text font-in font-size map-type ; Environment Map Type paint-mode ; Selected Paint Mode For Use WIth Blend Plug-in blend-direction ; Blend Direction blend-shape ; Blend Shape emap-gradient ; Selected Gradient For Environment Map texturesizex ; Drawable Width texturesizey ; Drawable Height blur-radius ; Gaussian Blur Radius turbulent hl-dist ds-off ds-blur bkg-type conserve ) (let* ( (image (car (gimp-image-new 256 256 RGB))) (border (/ font-size 4)) (font (if (> (string-length font-in) 0) font-in (car (gimp-context-get-font)))) (size-layer (car (gimp-text-fontname image -1 0 0 text border TRUE font-size PIXELS font))) (final-width (car (gimp-drawable-width size-layer))) (final-height (car (gimp-drawable-height size-layer))) (text-layer 0) (width 0) (height 0) (bkg-layer 0) (ver 2.8) ) (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") (if (= ver 2.8) (gimp-context-set-dynamics "Dynamics Off")) (gimp-context-set-foreground '(0 0 0)) (gimp-context-set-background '(255 255 255)) ;;;;Add the text layer for a temporary larger Image size (set! text-layer (car (gimp-text-fontname image -1 0 0 text (round (/ 250 4)) TRUE 250 PIXELS font))) (gimp-drawable-set-name text-layer "Text") ;;;;adjust text (gimp-text-layer-set-justification text-layer 2) ;;;;set the new width and height (set! width (car (gimp-drawable-width text-layer))) (set! height (car (gimp-drawable-height text-layer))) (gimp-image-remove-layer image size-layer) (gimp-image-resize-to-layers image) ;;;;set the text clolor (cond ((= ver 2.8) (gimp-image-select-item image 2 text-layer)) (else (gimp-selection-layer-alpha text-layer))) (gimp-edit-fill text-layer FOREGROUND-FILL) (gimp-selection-none image) ;;;;begin the script (script-fu-emap-alpha image text-layer map-type ; Environment Map Type paint-mode ; Selected Paint Mode For Use WIth Blend Plug-in blend-direction ; Blend Direction blend-shape ; Blend Shape emap-gradient ; Selected Gradient For Environment Map texturesizex ; Drawable Width texturesizey ; Drawable Height blur-radius ; Gaussian Blur Radius turbulent .2 1.50 .5 27 hl-dist ds-off ds-blur bkg-type conserve) ;;;;Scale Image to it's original size;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (gimp-image-scale-full image final-width final-height 2) (set! width (car (gimp-image-width image))) (set! height (car (gimp-image-height image))) (gimp-context-pop) (gimp-display-new image) ) ) (script-fu-register "script-fu-emap-logo" "Emap Logo" "The default font is from-http://www.fontstock.net/10277/pt-banana-split.html" "Graechan" "Graechan - http://gimpchat.com" "June 2011" "" SF-STRING "Text" "Gimp" SF-FONT "Font" "PT Banana Split" SF-ADJUSTMENT "Font size (pixels)" '(250 6 500 1 1 0 1) SF-OPTION _"Map Type" '("Topographical" "Cloud") SF-OPTION "Blending Mode" '("Normal" "Dissolve" "Behind" "Multiply" "Screen" "Overlay" "Difference" "Addition" "Subtract" "Darken" "Lighten" "Hue" "Saturation" "Color" "Value" "Divide" "Dodge" "Burn" "Hard Light" "Soft Light" "Grain Extract" "Grain Merge") SF-OPTION _"Blend Direction" '("Top-Botton" "Bottom-Top" "Left-Right" "Right-Left" "Diag-Top-Left" "Diag-Top-Right" "Diag-Bottom-Left" "Diag-Bottom-Right") SF-OPTION _"Blend Shape" '("Linear""Bilinear" "Radial" "Square" "Conical-Symmetric" "Conical-Asymmetric" "Shapeburst-Angular" "Shapburst-Spherical" "Shapeburst-Dimpled" "Spiral-CW" "Spiral-CCW") SF-GRADIENT _"Select Gradient" "Tropical Colors" SF-ADJUSTMENT _"Horizontal Texture Size" '(2.8 1 5 .1 .5 1 1) SF-ADJUSTMENT _"Vertical Texture Size" '(2.8 1 5 .1 .5 1 1) SF-ADJUSTMENT _"Blur Radius" '(5 0 30 1 5 0 1) SF-TOGGLE _"Turbulent Noise" TRUE SF-ADJUSTMENT "Highlight Dist fr Edge" '(6 0 10 1 1 0 0) SF-ADJUSTMENT "Drop Shadow Offset" '(8 0 50 1 1 0 1) SF-ADJUSTMENT "Drop Shadow Blur" '(15 0 100 1 5 0 1) SF-OPTION "Background Type" '("Transparency" "From Gradient" "Environment Map") SF-TOGGLE "Keep the Layers" FALSE ) (script-fu-menu-register "script-fu-emap-logo" "/Script-Fu/Logos") (define (script-fu-emap-alpha image layer map-type ; Environment Map Type paint-mode ; Selected Paint Mode For Use WIth Blend Plug-in blend-direction ; Blend Direction blend-shape ; Blend Shape emap-gradient ; Selected Gradient For Environment Map texturesizex ; Drawable Width texturesizey ; Drawable Height blur-radius ; Gaussian Blur Radius turbulent glow bright shine polish hl-dist ds-off ds-blur bkg-type conserve) (gimp-image-undo-group-start image) (let* ( (width (car (gimp-image-width image))) (height (car (gimp-image-height image))) (bkg-layer (car (gimp-layer-new image width height RGBA-IMAGE "Background" 100 NORMAL-MODE))) (highlight (car (gimp-layer-new image width height RGBA-IMAGE "Highlight" 100 NORMAL-MODE))) (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))))) (selection-channel 0) (bump-channel 0) (highlight-channel 0) (auto-hsv TRUE) (detail-level 1) (ver 2.8) ) (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) (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 ;;;;create bump-channel (gimp-selection-load bump-channel) ;---------------------------------------------create the 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 (gimp-selection-none image) ;;;;begin the script (plug-in-gauss-rle2 RUN-NONINTERACTIVE image bump-channel 10 10) ;-------------------------------------blur the bump-channel (gimp-image-set-active-layer image layer) (include-layer image bkg-layer layer 1) ;stack 0=above 1=below ;---------------------------------------add layer for environment map (the-environment-map image ; Image bkg-layer ; Drawable map-type ; Environment Map Type paint-mode ; Selected Paint Mode For Use WIth Blend Plug-in blend-direction ; Blend Direction blend-shape ; Blend Shape emap-gradient ; Selected Gradient For Environment Map detail-level ; Detail Level For Solid Noise Plug-in texturesizex ; Drawable Width texturesizey ; Drawable Height blur-radius ; Gaussian Blur Radius auto-hsv ; Autostretch HSV Flag turbulent) ; Turbulance Flag (set! bkg-layer (car (gimp-image-get-active-layer image))) (gimp-image-set-active-layer image layer) (plug-in-lighting 1 image ; IMAGE layer ; DRAWABLE bump-channel ; BUMP MAP (set to valid drawable) bkg-layer ; ENVIRONMENT MAP (set to 0 if disabled) FALSE ; ENABLE BUMPMAPPING TRUE ; ENABLE ENVMAPPING 2 ; TYPE OF MAPPING (0=linear,1=log, 2=sinusoidal, 3=spherical) 1 ; TYPE OF LIGHTSOURCE (0=point,1=directional,3=spot,4=none) '(255 255 255) ; LIGHTSOURCE COLOR -1.63 ; LIGHTSOURCE POS X -1.25 ; LIGHTSOURCE POS Y 1 ; LIGHTSOURCE POS Z -1 ; LIGHTSOURCE DIR X -1 ; LIGHTSOURCE DIR Y 1 ; LIGHTSOURCE DIR Z glow ; AMBIANT INTENSITY (GLOWING)0.20 0.50 ; DIFFUSE INTENSITY (BRIGHT)0.50 bright ; DIFFUSE REFLECTIVITY (INTENSITY)1 shine ; SPECULAR REFLECTIVITY (SHINY)0.50 polish ; HIGHLIGHT (POLISHED)27 TRUE ; ANTIALIASING FALSE ; CREATE NEW IMAGE FALSE) ; MAKE BACKGROUND TRANSPARENT (plug-in-bump-map RUN-NONINTERACTIVE image layer bump-channel 135 45 40 0 0 0 0 TRUE FALSE 1) ; { LINEAR (0), SPHERICAL (1), SINUSOIDAL (2) } ;;;;create the highlight (gimp-selection-load selection-channel) (include-layer image highlight layer 0) ;stack 0=above 1=below (gimp-selection-shrink image hl-dist) (gimp-context-set-foreground '(128 128 128)) (gimp-edit-fill highlight FOREGROUND-FILL) ;;;;create highlight-channel (gimp-selection-load highlight-channel) (set! highlight-channel (car (gimp-selection-save image))) (cond ((= ver 2.8) (gimp-item-set-name highlight-channel "highlight-channel")) (else (gimp-drawable-set-name highlight-channel "highlight-channel")) ) ;endcond (gimp-selection-none image) (plug-in-gauss-rle2 RUN-NONINTERACTIVE image highlight-channel 5 5) (gimp-image-set-active-layer image highlight) (plug-in-bump-map RUN-NONINTERACTIVE image highlight highlight-channel 135 15 10 0 0 0 255 TRUE FALSE 0) ;{LINEAR(0),SPHERICAL(1),SINUSOIDAL(2)} (plug-in-colortoalpha RUN-NONINTERACTIVE image highlight '(128 128 128)) ;;;;add a drop shadow (script-fu-drop-shadow image layer ds-off ds-off ds-blur "Black" 80 FALSE) ;;;;create alternate bkg (gimp-image-set-active-layer image bkg-layer) (gimp-context-set-gradient emap-gradient) (cond ((= bkg-type 0) (gimp-layer-add-alpha bkg-layer) (gimp-edit-clear bkg-layer)) ((= bkg-type 1)(gimp-edit-blend bkg-layer CUSTOM-MODE NORMAL-MODE GRADIENT-SHAPEBURST-SPHERICAL 100 0 REPEAT-NONE FALSE FALSE 3 0.2 TRUE 0 0 (/ width 2) (/ height 2))) ) ;endcond ;;;;finish the script (if (= conserve FALSE) (begin (set! layer (car (gimp-image-merge-down image layer EXPAND-AS-NECESSARY))) (set! layer (car (gimp-image-merge-down image layer EXPAND-AS-NECESSARY))) (set! layer (car (gimp-image-merge-down image highlight EXPAND-AS-NECESSARY))) (gimp-image-remove-channel image highlight-channel) (gimp-image-remove-channel image bump-channel) (gimp-image-remove-channel image selection-channel) )) ;endif (cond ((= ver 2.8) (gimp-item-set-name layer (string-append layer-name "\n" emap-gradient))) (else (gimp-drawable-set-name layer (string-append layer-name "\n" emap-gradient))) ) ;endcond (if (and (= conserve FALSE) (= alpha FALSE)) (gimp-layer-flatten layer)) (gimp-displays-flush) (gimp-image-undo-group-end image) (gimp-context-pop) ) ) (script-fu-register "script-fu-emap-alpha" "Emap Alpha" "Instructions" "Graechan" "Graechan - http://gimpchat.com" "2012" "RGB*" SF-IMAGE "image" 0 SF-DRAWABLE "drawable" 0 SF-OPTION _"Map Type" '("Topographical" "Cloud") SF-OPTION "Blending Mode" '("Normal" "Dissolve" "Behind" "Multiply" "Screen" "Overlay" "Difference" "Addition" "Subtract" "Darken" "Lighten" "Hue" "Saturation" "Color" "Value" "Divide" "Dodge" "Burn" "Hard Light" "Soft Light" "Grain Extract" "Grain Merge") SF-OPTION _"Blend Direction" '("Top-Botton" "Bottom-Top" "Left-Right" "Right-Left" "Diag-Top-Left" "Diag-Top-Right" "Diag-Bottom-Left" "Diag-Bottom-Right") SF-OPTION _"Blend Shape" '("Linear""Bilinear" "Radial" "Square" "Conical-Symmetric" "Conical-Asymmetric" "Shapeburst-Angular" "Shapburst-Spherical" "Shapeburst-Dimpled" "Spiral-CW" "Spiral-CCW") SF-GRADIENT _"Select Gradient" "Tropical Colors" SF-ADJUSTMENT _"Horizontal Texture Size" '(2.8 1 5 .1 .5 1 1) SF-ADJUSTMENT _"Vertical Texture Size" '(2.8 1 5 .1 .5 1 1) SF-ADJUSTMENT _"Blur Radius" '(5 0 30 1 5 0 1) SF-TOGGLE _"Turbulent Noise" TRUE SF-ADJUSTMENT "Glowing" '(.2 0 100000 .01 1 2 1) SF-ADJUSTMENT "Brightness" '(1.50 0 100000 .01 1 2 1) SF-ADJUSTMENT "Shiny" '(.5 0 100000 .01 1 2 1) SF-ADJUSTMENT "Polish" '(27 0 100000 .01 1 2 1) SF-ADJUSTMENT "Highlight Dist fr Edge" '(6 0 10 1 1 0 0) SF-ADJUSTMENT "Drop Shadow Offset" '(8 0 50 1 1 0 1) SF-ADJUSTMENT "Drop Shadow Blur" '(15 0 100 1 5 0 1) SF-OPTION "Background Type" '("Transparency" "From Gradient" "Environment Map") SF-TOGGLE "Keep the Layers" FALSE ) (script-fu-menu-register "script-fu-emap-alpha" "/Script-Fu/Alpha-to-Logo") (define (the-environment-map img ; Image drawable ; Drawable map-type ; Environment Map Type paint-mode ; Selected Paint Mode For Use WIth Blend Plug-in blend-direction ; Blend Direction blend-shape ; Blend Shape emap-gradient ; Selected Gradient For Environment Map detail-level ; Detail Level For Solid Noise Plug-in texturesizex ; Drawable Width texturesizey ; Drawable Height blur-radius ; Gaussian Blur Radius auto-hsv ; Autostretch HSV Flag turbulent) ; Turbulance Flag ; ;Declare Variables ; (let* ( (image-height 0) ; Drawable Height For Blend Plug-in (image-width 0) ; Drawable Width For Blend Plug-in (xblend-start 0) ; X Blend Starting Point (yblend-start 0) ; X Blend Starting Point (xblend-end 0) ; X Blend Ending Point (yblend-end 0) ; X Blend Ending Point ) ; ; Save Context ; (gimp-context-push) ; Start Undo Group (gimp-undo-push-group-start img) ; ; Call Solid Noise Plug-in ; (plug-in-solid-noise 1 ; Interactive img ; Input Image drawable ; Imput Drawable TRUE ; Tileable turbulent ; Turbulent Noise (random 999999) ; Random Seed detail-level ; Detail Level texturesizex ; Horizontal Texture Size texturesizey ; Vertical Texture Size ) ; ; Auto-stretch HSV ; (if (= auto-hsv TRUE) (begin (plug-in-autostretch-hsv 1 img drawable) ) ) ;endif ; ; Gaussian Blur ; (if (> blur-radius 0) (begin (plug-in-gauss 1 ; Non-interactive img ; Image to apply blur drawable ; Layer to apply blur blur-radius ; Blur Radius x blur-radius ; Blue Radius y 0 ; Method (IIR=0 RLE=1) ) ) ) ;endif ; ; Set Specified Gradient Active ; (gimp-context-set-gradient emap-gradient) ; ; Environment Map Type: Topographical ; (if (= map-type 0) (begin (plug-in-gradmap 1 img drawable) ; Map Gradient (gimp-layer-set-name drawable "EnviroMap: Topo") ; Name it ) ) ;endif ; ; Environment Map Type: Cloud ; (if (or (> paint-mode 0) (= map-type 1)) (begin (set! image-height (car (gimp-drawable-height drawable))) ; Get Height (set! image-width (car (gimp-drawable-width drawable))) ; Get Width ; ; Calculate Gradient Blend Start & End Points ; (cond ((= blend-direction 0) ; Top-Bottom (set! xblend-start 0) ; X Blend Starting Point (set! yblend-start 0) ; Y Blend Starting Point (set! xblend-end 0) ; X Blend Ending Point (set! yblend-end image-height) ; Y Blend Ending Point ) ((= blend-direction 1) ; Bottom-Top (set! xblend-start 0) ; X Blend Starting Point (set! yblend-start image-height) ; Y Blend Starting Point (set! xblend-end 0) ; X Blend Ending Point (set! yblend-end 0) ; Y Blend Ending Point ) ((= blend-direction 2) ; Left-Right (set! xblend-start 0) ; X Blend Starting Point (set! yblend-start 0) ; Y Blend Starting Point (set! xblend-end image-width) ; X Blend Ending Point (set! yblend-end 0) ; Y Blend Ending Point ) ((= blend-direction 3) ; Right-Left (set! xblend-start image-width) ; X Blend Starting Point (set! yblend-start 0) ; Y Blend Starting Point (set! xblend-end 0) ; X Blend Ending Point (set! yblend-end 0) ; Y Blend Ending Point ) ((= blend-direction 4) ; Diag-Top-Left (set! xblend-start 0) ; X Blend Starting Point (set! yblend-start 0) ; Y Blend Starting Point (set! xblend-end image-width) ; X Blend Ending Point (set! yblend-end image-height) ; Y Blend Ending Point ) ((= blend-direction 5) ; Diag-Top-Right (set! xblend-start image-width) ; X Blend Starting Point (set! yblend-start 0) ; Y Blend Starting Point (set! xblend-end 0) ; X Blend Ending Point (set! yblend-end image-height) ; Y Blend Ending Point ) ((= blend-direction 6) ; Diag-Bottom-Left (set! xblend-start 0) ; X Blend Starting Point (set! yblend-start image-height) ; Y Blend Starting Point (set! xblend-end image-width) ; X Blend Ending Point (set! yblend-end 0) ; Y Blend Ending Point ) ((= blend-direction 7) ; Diag-Bottom-Right (set! xblend-start image-width) ; X Blend Starting Point (set! yblend-start image-height) ; Y Blend Starting Point (set! xblend-end 0) ; X Blend Ending Point (set! yblend-end 0) ; Y Blend Ending Point ) ; (else ; ; For later use.. ; ) ) ;end cond ; ; Check Paint Mode ; (if (= paint-mode 0) (begin (set! paint-mode 4) ; Normal Makes No Sense For Cloud Map So Set To Screen As Default ) ) ;endif (gimp-edit-blend ; Blend (Gradient) drawable ; Drawable - (The affected drawable) CUSTOM ; Int32 - Blend Type (FG-BG-RGB-MODE (0)) paint-mode ; Int32 - Paint Mode (NORMAL-MODE (0)) blend-shape ; Int32 - Gradient Type (LINEAR (0)) 100 ; Float - Opacity (0 - 100) 0 ; Float - Offset ( >= 0) 0 ; Int32 - Repeat (NONE (0)) FALSE ; Int32 - Reverse (TRUE or FALSE) TRUE ; Int32 - Supersample (TRUE or FALSE) 3 ; Int32 - Supersampling Recursion Dept (1 - 9) 0.20 ; Float - Supersampling threshold (0 <= 4) TRUE ; Int32 - Dither (TRUE or FALSE) xblend-start ; Int32 - X Blend Starting Point yblend-start ; Int32 - Y Blend Starting Point xblend-end ; Int32 - X Blend Ending Point yblend-end ; Int32 - Y Blend Ending Point ) ; End Blend (gimp-layer-set-name drawable "EnviroMap: Cloud") ; Name Environment Map ) ) ;endif ; ; Ensure Environment Map Does Not Have An Alpha Channel So Flatten ; (gimp-layer-flatten drawable) ; ; End Undo Group ; (gimp-undo-push-group-end img) ; ; Update display ; (gimp-displays-flush) ; ; Restore Context ; (gimp-context-pop) ) ; End let ) ; End Main Procedure