;;; Plugin  : Crayon Text
;;; Author  : Rod Detmer
;;; Date    : August 24th 2012
;;; Revision: 1.0
;;; 					
;;; Latest version at: http://www.gimpchat.com
;;; Required : Gimp 2.8 or later
;;;
;;; Description: 
;;; Applies a crayolal text effect to your text layer
;;; -----------------------------------------------------------------------------
;;; Change Log:
;;; Version-1.0
;;;
;;; License:
;;; 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-crayon-text image layer mycolor Myiterations)
  (gimp-image-undo-group-start image)
  (plug-in-spread RUN-NONINTERACTIVE image layer 2 2)
  (plug-in-displace RUN-NONINTERACTIVE image layer  5 4 0 0 layer layer 1)
  (gimp-context-set-foreground mycolor)
  (plug-in-engrave RUN-NONINTERACTIVE image layer 3 1)
  (gimp-image-select-item image 0 layer)
  (gimp-edit-bucket-fill layer 0 0 100 255 1 1 1)
  (plug-in-hsv-noise RUN-NONINTERACTIVE image layer 1 0 20 25)
  (gimp-selection-none image)
  (gimp-image-select-color image 0 layer mycolor)
  (plug-in-colortoalpha RUN-NONINTERACTIVE image layer mycolor)

  (plug-in-displace RUN-NONINTERACTIVE image layer  7 7 0 0 layer layer 1)
  ;;
  ;;test whirl and pinch settings
  (gimp-image-select-item image 0 layer)  
  (plug-in-wind RUN-NONINTERACTIVE image layer 10 0 10 1 1)
  (plug-in-whirl-pinch RUN-NONINTERACTIVE image layer 90 0 1)
  (gimp-image-select-color image 0 layer mycolor)
  (gimp-edit-bucket-fill layer 0 0 100 255 1 1 1)  
  ;;
  ;;
  ;;
  (plug-in-spread RUN-NONINTERACTIVE image layer 1 1)
  (plug-in-displace RUN-NONINTERACTIVE image layer  5 4 0 0 layer layer 1)
  (gimp-context-set-foreground mycolor)
  (plug-in-engrave RUN-NONINTERACTIVE image layer 3 1)
  (gimp-image-select-item image 0 layer)
  (gimp-edit-bucket-fill layer 0 0 100 255 1 1 1)
  (plug-in-hsv-noise RUN-NONINTERACTIVE image layer 1 0 20 25)
  (gimp-selection-none image)
  (gimp-image-select-color image 0 layer mycolor)
  (plug-in-colortoalpha RUN-NONINTERACTIVE image layer mycolor)
  ;;
  ;;
  (gimp-selection-none image) 

  (gimp-brightness-contrast layer -45 20)
  
  ;;
  ;;Test warp feature to allow iterations of messyness
  (gimp-layer-resize-to-image-size layer)  
  (plug-in-warp RUN-NONINTERACTIVE image layer 5 layer Myiterations 0 90 0 layer 0 1 0 0 0 0 0)
  (gimp-image-select-item image 0 layer)
  (gimp-context-set-foreground mycolor)
  (gimp-edit-bucket-fill layer 0 0 100 255 1 1 1) 
  (gimp-selection-none image)  
  (gimp-context-set-foreground '(0 0 0))
  (gimp-context-set-background '(255 255 255))   
  (gimp-displays-flush image)
  (gimp-image-undo-group-end image)  
)

(script-fu-register
 "script-fu-crayon-text"
 "<Image>/Script-Fu/Text Effects/Crayon Text"
 "Applies a crayolal text effect to your text layer"
 "Rod Detmer"
 "Rod Detmer"
 "August 2012" 
 "RGB* GRAY* INDEXED*"
 SF-IMAGE "The Image" 0
 SF-DRAWABLE "The Layer" 0
 SF-COLOR "Crayon Color (fg)" '(20 130 235)
 SF-ADJUSTMENT "Messyness" '(3 1 5 1 10 0 SF-SLIDER) 
)