;;; Plugin  : Conbagui reptile skin typogrophy tutorial scripted - http://gimpchat.com/viewtopic.php?f=23&t=7321
;;; Author  : Rod Detmer
;;; Date    : December 2015
;;; Revision: v-01
;;;                
;;; Version : v-01
;;; Latest version at: http://www.gimpchat.com
;;; Required : Gimp 2.8 or later, and the included metalic pattern and Layerfx.py
;;;
;;; Description:
;;; Creates a reptile skin effect on a text layer. 
;;; If you have layerfx-2.8.py installed you must replace it with layerfx.py included.
;;; layerfx-2.8.py is too buggy for running through filters.
;;; Change Log:
;;; Version-1.0
;;;
; Information can be found at http://www.gimpchat.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

(define (script-fu-reptile-skin-typography-effect_RD image drawable mycolor mycoloropacity mypattern)
(gimp-image-undo-group-start image)

  ; save user settings
  (gimp-context-push)
 
  ; begin
 
  (let*
    ( 
	(width (car (gimp-image-width image)))
    (height (car (gimp-image-height image)))
    (original (car (gimp-layer-new-from-visible image image "Original")))	
    (pattern-fill (car (gimp-layer-new image width height RGBA-IMAGE "Pattern-Fill" 63 17)))	
    (color-fill (car (gimp-layer-new image width height RGBA-IMAGE "Color-Overlay" 47 17)))	
    )


	 ; add the layers	  
  (gimp-image-add-layer image original 0)
  (gimp-selection-layer-alpha original) ; our selection  	
  (gimp-context-set-foreground '(255 255 255))
  (gimp-edit-fill original FOREGROUND-FILL)
   
  (python-layer-fx-inner-shadow RUN-NONINTERACTIVE image original
                                  '(52 52 52) ; Shadow color
									 75.0     ; Shadow opacity
									     0    ; A contour used to modify the shadow's intensity curve (0 <= contour <= 11)
                                         0    ; The amount of noise applied to the shadow (0 <= noise <= 100)
							 MULTIPLY-MODE	  ; The shadow layer's combination mode 
							                  ;{ NORMAL-MODE (0), DISSOLVE-MODE (1), MULTIPLY-MODE (3), SCREEN-MODE 
										      ;(4), OVERLAY-MODE (5), DIFFERENCE-MODE (6), ADDITION-MODE (7), SUBTRACT-MODE 
											  ;(8), DARKEN-ONLY-MODE (9), LIGHTEN-ONLY-MODE (10), HUE-MODE 
											  ;(11), SATURATION-MODE (12), COLOR-MODE (13), VALUE-MODE (14), DIVIDE-MODE 
											  ;(15), DODGE-MODE (16), BURN-MODE (17), HARDLIGHT-MODE (18), SOFTLIGHT-MODE 
											  ;(19), GRAIN-EXTRACT-MODE (20), GRAIN-MERGE-MODE (21), COLOR-ERASE-MODE 
											  ;(22), ERASE-MODE (23), REPLACE-MODE (24), ANTI-ERASE-MODE (25) }
                                       1      ;	Source (0 = Center, 1 = Edge)
                                       0.00   ; Choke (0 <= choke <= 100)
                                       20.0   ; The size of the shadow's blur (0 <= size <= 250)
                                     131.0    ; The angle the shadow is cast in (-180 <= offset_angle <= 180)											  
                                       10.0   ; The distance between the layer and the shadow (0 <= offset_distance <= 30000)
                                         0    ; Merge with layer (TRUE or FALSE)
   ) 
  (gimp-item-set-visible drawable FALSE)
  (gimp-image-add-layer image pattern-fill 1)
  (gimp-image-raise-item-to-top image pattern-fill)
  (gimp-context-set-pattern mypattern)
  (gimp-drawable-fill pattern-fill PATTERN-FILL)
  (gimp-selection-layer-alpha original)
  (gimp-selection-invert image)
  (gimp-edit-clear pattern-fill)
  (gimp-selection-none image)
  
  (gimp-image-add-layer image color-fill 0)
  (gimp-image-raise-item-to-top image color-fill)	 
  (gimp-context-set-foreground mycolor)	
  (gimp-drawable-fill color-fill FOREGROUND-FILL)  
  (gimp-selection-layer-alpha original)
  (gimp-selection-invert image)
  (gimp-edit-clear color-fill)
  (gimp-layer-set-opacity color-fill mycoloropacity)
  (gimp-selection-none image)  
	;4) Now Regroup Lizard-with-dropshadow, select the Group, then Right click and select Layer Effect>Bevel and Emboss. 
	   ;Follow these settings: Style>Inner Bevel, Depth>65, Size>4, Surface Contour>Linear, Angle 131.0, Altitude>16, 
	   ;Gloss Contour>Rolling slope-descending, Highlight Mode>Burn with color b7b7b7, Opacity>100, Shadow Mode>Multiply 
	   ;with color 000000, Opacity >40. Check the use Texture box and click on browse to use the Pattern Metal with holes, 
	   ;Scale>100, Depth>24 and make sure Merge with layer is checked.
	   
	;5) Now go and Open the two Layer Group we’ve created and find the Original layer (mine is Lizard), then Right click and 
	   ;select Alpha to Selection. Grab the Blend tool and use a Metallic gradient or the one supplied and change the Shape 
	   ;to Bi-linear. Place your Cursor on top of any of the small letters and Drag to the bottom of the letters as indicated 
	   ;on the Illustration. Select>None.
	   
	;6) For the last step we’re going to Repeat the Bevel and Emboss filter but we need to Regroup the both Group layers. 
	   ;Once you Regroup, (make sure the Group Layer is selected and you know that by the darker shading on it). Since we 
	   ;used the Bevel and Emboss filter once, go to Filters and on top of the Drop down menu select Recently Used>Bevel and 
	   ;Emboss. Check the Preview box to Preview and click Ok. Done
	   
          ; end
  (gimp-selection-none image)    
  ; display new image and return user settings
  (gimp-context-pop)
  (gimp-image-undo-group-end image)
  (gimp-displays-flush image) 
     
  )
)


    ;register menu location and information   

(script-fu-register
"script-fu-reptile-skin-typography-effect_RD"
"<Image>/Rod/Alpha to Logo/reptile skin typography effect"
"creates a reptilian scales effect from any layer  -  script name: reptile-skin-typography-effect_RD.scm"
"Rod Detmer"
"Rod Detmer"
"December 2015"
"RGB* GRAY*"
SF-IMAGE       "The Image"            0
SF-DRAWABLE    "The Drawable"         0  
SF-COLOR       "Scales Color"        '(158 160 32)
SF-ADJUSTMENT  "Scale Color Opacity" '(100 1 100 1 10 0 SF-SLIDER)
SF-PATTERN "Select Pattern"          "Metal with Holes"                               
)