; Bling Text Logo V2.1 (Updated: 07-2014)
; Create animated or static bling text with drop shadow
; Apha To Logo option for selection
;
; Created by GnuTux
; Bling Graphic Animations and Patterns by Oregonian
;
;********************************* IMPORTANT ****************************************
; This script requires a set of patterns that are included in the zip file (/patterns)
;
; Copy these patterns to your local pattern folder in order to use this script
;**************************************************************************************
;
; Checking the animate toggle will direct script to generate 3 text layers with the selected font
; The text will be filled with the selected fill type and bling type
;
; Each layer will be shadowed and semifattened with the background color, for use as an animated .GIF
; All that is required as this point is to simply save the image as an animated .GIF
;
; Leaving the animate toggle unchecked will direct the script to generate a static image
;
; Selecting "Keep All Layers returns only the raw layers used to build the animation. 
;
; Comments and questions directed to http://gimpchat,com
;
; Compatible with all Gimp Versions 2.x - Enjoy!
;
; ------------
;| Change Log |
; ------------ 
; V1.0 - Initial Release
; V1.1 - Added shadow x/y offset, Shadow Opacity, Autocrop and Raw Layers Options
; V1.2 - Added four new Bling Patterns
; V1.3 - Added Heart Patterns and Checkered pattern              
; V1.4 - Updated Menus Locations for Gimp 2.6 - Changed Default Settings
; V2.0 - Complete Rewite With Alpha to Logo Option 
; V2.1 - For GIMP 2.10.x (Procedures Deprecated)
;      - (gimp-item-set-name)
;
;Apply Bing
; 
(define (apply-bling img fill-layer stype bling-op ani-fill)
;
  (let* (
           (tmps1 0) ; Bling Style Fill 1
           (tmps2 0) ; Bling Style Fill 2
           (tmps3 0) ; Bling Style Fill 3
        )
;
; Determine and set bling type
;
(if (= stype 0)
   (begin
     (set! tmps1 "Little Stars 1")
     (set! tmps2 "Little Stars 2")
     (set! tmps3 "Little Stars 3")
    ))

(if (= stype 1)
   (begin
     (set! tmps1 "Sparkle1")
     (set! tmps2 "Sparkle2")
     (set! tmps3 "Sparkle3")
    ))
(if (= stype 2)
   (begin
     (set! tmps1 "Single pixel bling1")
     (set! tmps2 "Single pixel bling2")
     (set! tmps3 "Single pixel bling3")
    ))
(if (= stype 3)
   (begin
     (set! tmps1 "Little Stars blurred1")
     (set! tmps2 "Little Stars blurred2")
     (set! tmps3 "Little Stars blurred3")
    ))
(if (= stype 4)
   (begin
     (set! tmps1 "mini-sparkle1")
     (set! tmps2 "mini-sparkle2")
     (set! tmps3 "mini-sparkle3")
    ))
(if (= stype 5)
   (begin
     (set! tmps1 "Bubbles 1")
     (set! tmps2 "Bubbles 2")
     (set! tmps3 "Bubbles 3")
    ))
(if (= stype 6)
   (begin
     (set! tmps1 "Bubble Fizz 1")
     (set! tmps2 "Bubble Fizz 2")
     (set! tmps3 "Bubble Fizz 3")
    ))
(if (= stype 7)
   (begin
     (set! tmps1 "Bling Stew 1")
     (set! tmps2 "Bling Stew 2")
     (set! tmps3 "Bling Stew 3")
    ))
(if (= stype 8)
   (begin
     (set! tmps1 "Bling Stew No Fizz 1")
     (set! tmps2 "Bling Stew No Fizz 2")
     (set! tmps3 "Bling Stew No Fizz 3")
    ))
(if (= stype 9)
   (begin
     (set! tmps1 "Hearts TBG 1")
     (set! tmps2 "Hearts TBG 2")
     (set! tmps3 "Hearts TBG 3")
    ))
(if (= stype 10)
   (begin
     (set! tmps1 "sparse-sparkle1")
     (set! tmps2 "sparse-sparkle2")
     (set! tmps3 "sparse-sparkle3")
    ))
(if (= stype 11)
   (begin
     (set! tmps1 "Little Stars Multicolor 1")
     (set! tmps2 "Little Stars Multicolor 2")
     (set! tmps3 "Little Stars Multicolor 3")
    ))

(if (= stype 12)
   (begin
     (set! tmps1 "Stars Only 1")
     (set! tmps2 "Stars Only 2")
     (set! tmps3 "Stars Only 3")
    ))

(if (= stype 13)
   (begin
     (set! tmps1 "Stars Only Small 1")
     (set! tmps2 "Stars Only Small 2")
     (set! tmps3 "Stars Only Small 3")
    ))
(if (= stype 14)
   (begin
     (set! tmps1 "Stars Pulse 1")
     (set! tmps2 "Stars Pulse 2")
     (set! tmps3 "Stars Pulse 3")
    ))
(if (= stype 15)
   (begin
     (set! tmps1 "Stars2 Pulse 1")
     (set! tmps2 "Stars2 Pulse 2")
     (set! tmps3 "Stars2 Pulse 3")
    ))

(if (= stype 16)
   (begin
     (set! tmps1 "WhiteNoise1")
     (set! tmps2 "Whitenoise2")
     (set! tmps3 "Whitenoise3")
    ))
;
; Fill text with bling patterns
;
(if (= ani-fill 1)
   (begin
      (gimp-context-set-pattern tmps1)
      (gimp-edit-bucket-fill fill-layer 2 0 bling-op 0 0 0 0)
    ))
(if (= ani-fill 2)
   (begin
      (gimp-context-set-pattern tmps2)
      (gimp-edit-bucket-fill fill-layer 2 0 bling-op 0 0 0 0)
    ))
(if (= ani-fill 3)
   (begin
      (gimp-context-set-pattern tmps3)
      (gimp-edit-bucket-fill fill-layer 2 0 bling-op 0 0 0 0)
    ))

   );end let
); end apply bling Procedure
;
;
; Define the apply Bling Text Logo procedure
;
(define (apply-bling-text img
                             logo-layer
                             bling-type
                             bling-op
                             fill-style
                             logo-color
                             bevel-amt
                             stroke-color
                             stroke-width
                             background-fill
                             bg-pattern
                             shadow-toggle
                             shadow-color
                             sf-flag
                             keep-layers
                             ani-fill
                             alpha2logo
        )
;
  (let* (
           (stroke-layer -1)                ; Stroke layer
           (effect-layer -1)                ; Effect Layer
           (fill-layer -1)                  ; Fill layer
           (background -1)                  ; Background Layer
           (tmp-logo -1)                    ; Temporary Logo Layer
           (saved-selection -1)             ; Saved Selection
           (image-height 0)                 ; Image Height
           (image-width 0)                  ; Image Width
           (current-pattern  -1)            ; Current Pattern
           (act-lay-pos 0)                  ; Active Layer Position 
           (tmpl1 0) 
           (tmpl2 0)
           (tmpl3 0)
           (tmps1 0)
           (tmps2 0)
           (tmps3 0)
 
        )
;
; Save Current Active Pattern
;

   (set! current-pattern  (car (gimp-context-get-pattern img)))    ; Save Active Pattern

;
; Selection Check
;

    (if (= (car (gimp-selection-is-empty img)) TRUE)      ; Check for a selection 
        (begin
          (gimp-selection-layer-alpha logo-layer)         ; Select alpha to logo If there isn't one
        )
     ) ; endif

(set! tmp-logo (car (gimp-layer-new-from-drawable logo-layer img))) ; New logo Layer 

;
;
; Create fill layer to hold fill style
;
  (set! fill-layer (car (gimp-layer-new-from-drawable logo-layer img))) ; New Fill Layer 
  (gimp-image-add-layer img fill-layer 1)                               ; Add it to image
  (gimp-image-set-active-layer img fill-layer)                          ; Make fill layer active
  (gimp-selection-invert img)                                           ; Invert the stroke selection
  (gimp-edit-clear fill-layer)                                          ; Clear stroke area
  (gimp-selection-invert img)                                           ; Invert the stroke selection
  (gimp-layer-set-name fill-layer "Fill")                               ; Name fill layer

;
; Fill With Color, Pattern or Gradient
;
    (if (= fill-style 0)
        (begin  
            (gimp-context-set-foreground logo-color)            ; Set logo color
            (gimp-edit-bucket-fill fill-layer 0 0 100 0 0 0 0)  ; Fill with color
            (gimp-layer-set-name fill-layer "Color Fill")       ; Name layer
         )
     ) ;endif
  
    (if (= fill-style 1)
        (begin
            (gimp-edit-bucket-fill fill-layer 2 0 100 0 0 0 0)  ; Fill with pattern
            (gimp-layer-set-name fill-layer "Pattern Fill")     ; Name layer
        )
     ) ;endif
;
; Fill with gradient
;

    (if (and (> fill-style 1)(< fill-style 5))      ; Check for gradient fill
        (begin 

          (if (= fill-style 2)                      ; Vertical gradient fill
            (begin
               (set! image-height (car (gimp-drawable-height fill-layer)))
            )
          ) ; endif
          (if (= fill-style 3)                      ; Horizontal gradient fill
            (begin
               (set! image-width (car (gimp-drawable-width fill-layer)))
            )
          ) ; endif
          (if (= fill-style 4)                      ; Diagonal gradient fill
            (begin
               (set! image-height (car (gimp-drawable-height fill-layer)))
               (set! image-width (car (gimp-drawable-width fill-layer)))
            )
          ) ; endif

             (plug-in-autocrop-layer 1 img fill-layer) ; Autocrop fill layer so gradient is fully applied 

             (gimp-edit-blend        ; Blend (Gradient)
                        fill-layer   ; Drawable - (The affected drawable)
               BLEND-FG-BG-RGB       ; Int32 - Blend Type (FG-BG-RGB-MODE (0))
             LAYER_MODE_NORMAL       ; Int32 - Paint Mode (NORMAL-MODE (0)) 
                        LINEAR       ; 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)
                        0            ; Int32 - X Blend Starting Point
                        0            ; Int32 - Y Blend Starting Point
                        image-width  ; Int32 - X Blend Ending Point  
                        image-height ; Int32 - Y Blend Ending Point
             ) ; End Blend

             (gimp-layer-resize-to-image-size fill-layer)      ; Restore Fill Layer To Image Size
             (gimp-layer-set-name fill-layer "Gradient Fill")  ; Name layer
        )
     ) ;endif

;
; Fill Logo Layer With Bling 
; 

(apply-bling img fill-layer bling-type bling-op ani-fill) ; Fill With Bing Type

;
; Bevel The Logo Layer
;
    (if (> bevel-amt 0) 
      (begin
         (script-fu-add-bevel img fill-layer bevel-amt 0 0)     ; Bevel fill layer again
      )
    );endif

;
;
; Create Stroke Layer (only if stroke width > 0)
;

   (if (> stroke-width 0)
       (begin

         (set! saved-selection (car (gimp-selection-save img))) ; Save selection

         (set! stroke-layer (car (gimp-layer-new-from-drawable logo-layer img))) ; New Stoke Layer 
         (set! act-lay-pos (car (gimp-image-get-item-position img fill-layer)))  ; Poition of Fill Layer

         (gimp-image-add-layer img stroke-layer act-lay-pos)        ; Add it to image
         (gimp-image-set-active-layer img stroke-layer)             ; Make stroke logo layer active
         (gimp-layer-set-name stroke-layer "Stroke")                ; Name the stroke layer
;
; Delete everything outside selection for Alpha Mode
;           
         (if (= alpha2logo 1)                                          ; Aplha stroke method
             (begin                                                    ;
               (gimp-selection-grow img 2)	                           ; Grow the selection
               (gimp-context-set-foreground stroke-color)              ; Set stroke color
               (gimp-edit-bucket-fill stroke-layer 0 0 100 0 0 0 0)    ; Fill with Stroke color
               (gimp-selection-shrink img 2)                           ; Shrink the selection
               (gimp-selection-invert img)                             ; Invert the selction
               (gimp-edit-clear stroke-layer)                          ; Clear stroke layer
               (gimp-selection-invert img)                             ; Invert the selction
            )
          ); endif
                                                             ; Text stroke method (always do this) 
         (gimp-selection-shrink img stroke-width)            ; Shrink by stroke width
         (gimp-edit-clear stroke-layer)                      ; Clear all but stroke

         (gimp-image-set-active-layer img fill-layer)        ; Make fill layer active
         (gimp-selection-load saved-selection)               ; Restore Selection
         (gimp-image-remove-channel img saved-selection)     ; Remove Selection Mask
         
        (if (= keep-layers FALSE)                            
          (set! fill-layer (car (gimp-image-merge-down img stroke-layer 0))) ; Merge Stroke Layer with Fill
        )
      )

   ) ; endif

;
; Create Drop Shadow  
;
;
    (if (= shadow-toggle TRUE)
      (begin
         (set! saved-selection (car (gimp-selection-save img)))            ; Save selection
         (gimp-selection-none img)                                         ; Clear Selection
         (script-fu-drop-shadow img fill-layer -5 5 7 shadow-color 50 1) ; Create Drop Shadow
         (gimp-selection-load saved-selection)                             ; Restore Selection
         (gimp-image-remove-channel img saved-selection)                   ; Remove Selection Mask

         (if (= keep-layers FALSE)
           (set! fill-layer (car (gimp-image-merge-down img fill-layer 0))) ; Merge Shadow With Fill
         )
       )
   ) ; endif 

;(if (= keep-layers FALSE)
     (set! act-lay-pos (car (gimp-image-get-item-position img fill-layer))) ; Position of Fill Layer
     (gimp-image-add-layer img tmp-logo (+ 1 act-lay-pos))                  ; Add it to image
     (set! fill-layer (car (gimp-image-merge-down img fill-layer 0)))       ; Merge Logo layer 
;
; Create Background Layer 
;
;
    (if (< background-fill 4)
      (begin

        (set! saved-selection (car (gimp-selection-save img)))                 ; Save selection
        (gimp-selection-none img)                                              ; Clear Selection

        (set! act-lay-pos (car (gimp-image-get-item-position img fill-layer))) ; Position of Fill Layer
        (set! background (car (gimp-layer-new-from-drawable logo-layer img)))  ; New layer

        (gimp-image-add-layer img background (+ act-lay-pos 1))                ; Add it to image under fill layer
        (script-fu-util-image-resize-from-layer img background)                ; Layer to image size
        (gimp-image-set-active-layer img background)                           ; Make BG layer active
        (gimp-edit-clear background)                                           ; Clear background
        (gimp-layer-set-name background "Background")                          ; Name backgound layer

        (if (= background-fill 0)                      ; Background Pattern
          (begin 
            (gimp-context-set-pattern bg-pattern)      ; Make effect pattern active
            (gimp-drawable-fill background 4)          ; Fill with pattern
          )
        )
        (if (= background-fill 1)                      ; Active Pattern
          (begin 
            (gimp-context-set-pattern current-pattern) ; Make effect pattern active
            (gimp-drawable-fill background 4)          ; Fill with pattern
          )
        )
        (if (= background-fill 2)       ; Active Gradient
          (begin 

            (set! image-height (car (gimp-drawable-height background))) ; Get Background Height 

            (gimp-edit-blend         ; Blend (Gradient)
                        background   ; Drawable - (The affected drawable)
               BLEND-FG-BG-RGB       ; Int32 - Blend Type (FG-BG-RGB-MODE (0))
             LAYER_MODE_NORMAL       ; Int32 - Paint Mode (NORMAL-MODE (0)) 
                        LINEAR       ; 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)
                        0            ; Int32 - X Blend Starting Point
                        0            ; Int32 - Y Blend Starting Point
                        0            ; Int32 - X Blend Ending Point  
                        image-height ; Int32 - Y Blend Ending Point
             ) ; End Blend
          )
        )

        (if (= background-fill 3)                          ; BG Color
            (gimp-drawable-fill background 1)              ; Fill with BG color
        )
        (gimp-selection-load saved-selection)               ; Restore Selection
        (gimp-image-remove-channel img saved-selection)     ; Remove Selection Mask

        (if (= keep-layers FALSE)
           (set! fill-layer (car (gimp-image-merge-down img fill-layer 0))) ; Merge Fill Down To BG 
           (begin 
              (if (= shadow-toggle TRUE)
                (gimp-image-lower-layer img background) ; Respositon BG layer (if there is a shadow layer)
              )
            )
         )
      )
   ) ; endif (end of background layer)
;


(if (= keep-layers FALSE)
  (gimp-item-set-name fill-layer "Test Name")  ; Frame Number
)

(if (and (= sf-flag TRUE) (= shadow-toggle TRUE))
      (begin 
         (set! saved-selection (car (gimp-selection-save img))) ; Save selection
         (gimp-selection-none img)                              ; Clear selection
        (if (= keep-layers FALSE)
         (plug-in-semiflatten 1 img fill-layer)                 ; Semiflatten Fill Layer
        )
         (gimp-selection-load saved-selection)                  ; Restore Selection
         (gimp-image-remove-channel img saved-selection)        ; Remove Selection Mask
      )
)


(gimp-context-set-pattern current-pattern) ; Restore Active Pattern

;
 ); endlet
) ; return (from apply-bling-text) 

;
;
; Display Message Procedure
;
(define (display_message
                 text_message                              ; Message to display
                 output_destination                        ; MESSAGE-BOX (0), CONSOLE (1), ERROR-CONSOLE (2)
        )
   (let* (
          (handler_state (car (gimp-message-get-handler))) ; Save current message handler state
         )
          (gimp-message-set-handler output_destination)    ; Set message handler to the desired output destination   
          (gimp-message text_message)                      ; Display the message
          (gimp-message-set-handler handler_state)         ; Restore message handler to saved state

   ) ;endlet
) ; return
;
;
; Define alpha to selection procedure
;
(define (script-fu-bling-text-alpha img
                                       logo-layer
                                       bling-type
                                       bling-op
                                       fill-style
                                       logo-color
                                       bevel-amt
                                       stroke-color
                                       stroke-width
                                       background-fill
                                       bg-pattern  
                                       shadow-toggle
                                       shadow-color
                                       sf-flag
                                       keep-layers
        )
  (let* (
          (alpha2logo 1) ; 0 - Text mode , 1 - Alpha mode
        )

;
; Save current GIMP context
;
    (gimp-context-push)               ; Push context onto stack
    (gimp-image-undo-group-start img) ; Begin undo group
;
; Call apply logo procedure  
;
    (apply-bling-text img logo-layer bling-type bling-op fill-style logo-color bevel-amt stroke-color stroke-width background-fill bg-pattern shadow-toggle shadow-color sf-flag keep-layers 1 alpha2logo)
    (apply-bling-text img logo-layer bling-type bling-op fill-style logo-color bevel-amt stroke-color stroke-width background-fill bg-pattern shadow-toggle shadow-color sf-flag keep-layers 2 alpha2logo)
    (apply-bling-text img logo-layer bling-type bling-op fill-style logo-color bevel-amt stroke-color stroke-width background-fill bg-pattern shadow-toggle shadow-color sf-flag keep-layers 3 alpha2logo)

;
; Drop logo layer to bottom
;

    (gimp-image-remove-layer img logo-layer)  ; Delete the logo layer
    (gimp-selection-none img)                 ; Clear selection

    (gimp-image-undo-group-end img)           ; End undo group
    (gimp-context-pop)                        ; Pop context off stack
    (gimp-displays-flush)                     ; Flush display

  ) ;endlet
) ; return  

;
; Register logo to alpha procedure
;
(script-fu-register "script-fu-bling-text-alpha"
                    _"_Bling Logo..."
                    _"Create Animated Bling Logo"
                    "GnuTux - http://gimpchat.com"
                    "GnuTux - GPLv3"
                    "07-2014"
                    "RGBA"
                    SF-IMAGE      "Image"                 0
                    SF-DRAWABLE   "Drawable"              0
                    SF-OPTION     _"Bling Type"            '("Tiny Stars" "Sparkle" "Pixel-Bling" "Star-Blur" "Mini-sparkle" "Bubbles" "Bubble Fizz" "Bling Stew" "Bling Stew No Fizz" "Hearts TBG" "Sparse-Sparkle""Little Stars Multicolor""Stars Only" "Stars Only Small" "Stars Pulse" "Stars Pulse2" "Whitenoise")
                    SF-ADJUSTMENT _"Bling Opacity"        '(70 1 100 1 5 0 0)
                    SF-OPTION     _"Fill Method"          '("Fill Color" "Active Pattern Fill" "Active Gradient Fill (Vertical)" "Active Gradient Fill (Horizonal)" "Active Gradient Fill (Diagonal)" "Bling Fill Only")
                    SF-COLOR      _"Fill Color"           '(43 176 231)
                    SF-ADJUSTMENT _"Bevel Depth"          '(6 0 50 1 1 0 0)
                    SF-COLOR      _"Stroke Color"         '(137 198 215)
                    SF-ADJUSTMENT _"Stroke Width"         '(0 0 50 1 1 0 0)
                    SF-OPTION     _"Background Layer"     '("Fill With Background Pattern" "Fill With Active Pattern" "Fill With Active Gradient" "Fill With Active BG Color" "None")
                    SF-PATTERN    _"Background pattern"   "Starfield"
                    SF-TOGGLE     _"Add Drop Shadow"      TRUE
                    SF-COLOR      _"Shadow Color"         '(114 198 237)
                    SF-TOGGLE     _"Semiflatten Shadow"   FALSE
                    SF-TOGGLE     _"Keep All Layers"      FALSE

)

(script-fu-menu-register "script-fu-bling-text-alpha"
                         "<Image>/Filters/Alpha to Logo")
;
; Define logo text procedure
;
(define (script-fu-bling-text text
                                 font
                                 size
                                 letter-spacing
                                 line-spacing 
                                 justification
                                 bling-type
                                 bling-op
                                 fill-style
                                 logo-color
                                 bevel-amt
                                 stroke-color
                                 stroke-width
                                 background-fill
                                 bg-pattern  
                                 shadow-toggle
                                 shadow-color
                                 sf-flag
                                 keep-layers 
        )
 (let*  (
          (img -1)                                 ; Declare and Init img
          (text-layer -1)                          ; Declare and init text-layer
          (logo-layer -1)                          ; Declare and init logo-layer 
          (alpha2logo 0)			               ; 0 - Text mode , 1 - Alpha mode
        )
  
  (gimp-context-push)                              ; Push context onto stack
  (set! img (car (gimp-image-new 256 256 RGB)))    ; Create a new image

;
; Original Text Layer (keep untouched)
;
   (gimp-context-set-foreground logo-color)                        ; Set FG to logo color
   (set! text-layer (car (gimp-text-fontname img -1 0 0 text 25 TRUE size PIXELS font))) ; Create text layer
   (gimp-text-layer-set-letter-spacing text-layer letter-spacing)  ; Set Letter Spacing
   (gimp-text-layer-set-justification text-layer (+ (* justification -1) 2)) ; Text Justification (Rev Value) 
   (gimp-text-layer-set-line-spacing text-layer line-spacing)      ; Set Line Spacing
   (script-fu-util-image-resize-from-layer img text-layer)         ; Logo layer to image size
   (gimp-layer-set-name text-layer "Text")                         ; Name text Layer
   (gimp-image-undo-group-start img)                               ; Begin undo group
                                                            
;          
; Logo layer (color with stroke color and pass to the logo procedure)  
;
  (gimp-context-set-foreground stroke-color)                       ; Set FG to stroke color
  (set! logo-layer (car (gimp-text-fontname img -1 0 0 text 25 TRUE size PIXELS font))) ; Create logo layer
  (gimp-layer-set-name logo-layer "Logo Layer")                    ; Name logo Layer
  (gimp-text-layer-set-letter-spacing logo-layer letter-spacing)   ; Set Letter Spacing
  (gimp-text-layer-set-line-spacing logo-layer line-spacing)       ; Set Line Spacing
  (gimp-text-layer-set-justification logo-layer (+ (* justification -1) 2)) ; Text Jusification (Rev Value)

;
; Call the bling text logo main procedure 
;
  (apply-bling-text img logo-layer bling-type bling-op fill-style logo-color bevel-amt stroke-color stroke-width background-fill bg-pattern shadow-toggle shadow-color sf-flag keep-layers 1 alpha2logo)
  (apply-bling-text img logo-layer bling-type bling-op fill-style logo-color bevel-amt stroke-color stroke-width background-fill bg-pattern shadow-toggle shadow-color sf-flag keep-layers 2 alpha2logo)
  (apply-bling-text img logo-layer bling-type bling-op fill-style logo-color bevel-amt stroke-color stroke-width background-fill bg-pattern shadow-toggle shadow-color sf-flag keep-layers 3 alpha2logo)

  (gimp-image-remove-layer img logo-layer)   ; Delete the logo layer
  (gimp-image-remove-layer img text-layer)   ; Delete the text

  (gimp-selection-none img)                  ; Clear selection
  (gimp-image-undo-group-end img)            ; End undo group
  (gimp-context-pop)                         ; Pop context off stack

   (gimp-display-new img)                    ; Show the image

 ) ; endlet
) ; return

;
; Register the script
;    
(script-fu-register "script-fu-bling-text"
                    _"_Bling Text Logo.."
                    _"Create Amnimated Bling logo"
                    "GnuTux - http://gimpchat.com"
                    "GnuTux - GPLv3"
                    "07-2014"
                    ""
                    SF-TEXT       _"Text"                  "Bling\nText"
                    SF-FONT       _"Font"                  "Arial Black"
                    SF-ADJUSTMENT _"Font size (pixels)"    '(250 10 1000 1 10 0 0)
                    SF-ADJUSTMENT _"Letter Spacing"        '(0 -50 50 1 5 0 0)
                    SF-ADJUSTMENT _"Line Spacing"          '(0 -300 300 1 10 0 0)
                    SF-OPTION     _"Text Justification"    '("Center" "Right" "Left")
                    SF-OPTION     _"Bling Type"            '("Tiny Stars" "Sparkle" "Pixel-Bling" "Star-Blur" "Mini-sparkle" "Bubbles" "Bubble Fizz" "Bling Stew" "Bling Stew No Fizz" "Hearts TBG" "Sparse-Sparkle""Little Stars Multicolor""Stars Only" "Stars Only Small" "Stars Pulse" "Stars Pulse2" "Whitenoise")
                    SF-ADJUSTMENT _"Bling Opacity"         '(70 1 100 1 5 0 0)
                    SF-OPTION     _"Fill Method"           '("Fill Color" "Active Pattern Fill" "Active Gradient Fill (Vertical)" "Active Gradient Fill (Horizonal)" "Active Gradient Fill (Diagonal)")
                    SF-COLOR      _"Fill Color"            '(43 176 231)
                    SF-ADJUSTMENT _"Bevel Depth"           '(8 0 30 1 1 0 0)
                    SF-COLOR      _"Stroke Color"          '(91 126 162)
                    SF-ADJUSTMENT _"Stroke Width"          '(1 0 50 1 1 0 0)
                    SF-OPTION     _"Background Layer"     '("Fill With Background Pattern" "Fill With Active Pattern" "Fill With Active Gradient" "Fill With Active BG Color" "None")
                    SF-PATTERN    _"Background pattern"    "Starfield"
                    SF-TOGGLE     _"Add Drop Shadow"        TRUE
                    SF-COLOR      _"Shadow Color"          '(114 198 237)
                    SF-TOGGLE     _"Semiflatten Shadow"     FALSE
                    SF-TOGGLE     _"Keep All Layers"        FALSE
)

(script-fu-menu-register "script-fu-bling-text"
                         _"<Image>/File/Create/Logos (gimpchat.com)/")
