;I've got a new script, but I've not been able to publish it due it
;network faults + firewalls...

;I include it here, should you find a way to publish it for me.
;I appologise for how cheesy it is.

;(From the creator of fuzzy-selection and camo etc...)

; "Dracula!" or "Cheesy Goth"

;
; Chris Gutteridge (cjg@ecs.soton.ac.uk)
; At ECS Dept, University of Southampton, England.

; 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-blood-logo inText inFont inFontSize inBorder inDrip)

    (define oldFore (car(gimp-palette-get-foreground)) )
    (define oldBack (car(gimp-palette-get-background)) )

    (define theImage (car(gimp-image-new 100 100 RGB)) ) 
    (define textLayer (car(gimp-layer-new theImage 10 10 RGBA_IMAGE "text layer" 100 NORMAL)) )
    (define bloodLayer (car(gimp-layer-new theImage 10 10 RGBA_IMAGE "blood layer" 100 NORMAL)) )
    (define backLayer(car(gimp-layer-new theImage 10 10 RGBA_IMAGE "Background" 100 NORMAL)) )
    (gimp-palette-set-background '(0 0 0) )
    (gimp-palette-set-foreground '(255 255 255))
    (gimp-image-add-layer theImage textLayer 0)
    (gimp-image-add-layer theImage bloodLayer 1)
    (gimp-image-add-layer theImage backLayer 2)
    (gimp-selection-all theImage)
    (gimp-edit-clear theImage textLayer)
    (gimp-edit-clear theImage bloodLayer)
    (gimp-selection-none theImage)
    (define theText (car (gimp-text theImage textLayer 0 0 inText 0 TRUE inFontSize PIXELS "*" inFont "*" "r" "*" "*"))) 
    (define theBuffer (+ inBorder inDrip inDrip))
    (gimp-layer-set-offsets theText theBuffer theBuffer)
    (define theWidth (+ (car(gimp-drawable-width theText)) theBuffer theBuffer) )
    (define theHeight (+ (car(gimp-drawable-height theText)) theBuffer theBuffer) )
    (gimp-image-resize theImage theWidth theHeight 0 0)
    (gimp-layer-resize textLayer theWidth theHeight 0 0)
    (gimp-layer-resize bloodLayer theWidth theHeight 0 0)
    (gimp-layer-resize backLayer theWidth theHeight 0 0)
    (gimp-floating-sel-anchor theText)

    (gimp-selection-all theImage)
    (gimp-edit-fill theImage backLayer)
    (gimp-selection-none theImage)
             
    (gimp-selection-layer-alpha theImage textLayer)
    (gimp-selection-grow theImage inBorder)
    (gimp-edit-fill theImage bloodLayer)
    (gimp-selection-none theImage)
  
    (gimp-layer-scale bloodLayer theWidth (/ theHeight 8) TRUE)
    (define (smear n) (if (> n 0) (prog1 (plug-in-spread TRUE theImage bloodLayer 0 1) (smear (- n 1)))))
    (smear inDrip)
    (gimp-layer-scale bloodLayer theWidth theHeight TRUE)

    (gimp-selection-layer-alpha theImage textLayer)
    (gimp-selection-grow theImage inBorder)
    (gimp-edit-fill theImage bloodLayer)
    (gimp-selection-none theImage)

    (plug-in-gauss-iir TRUE theImage bloodLayer 4 TRUE TRUE)
    (plug-in-threshold-alpha TRUE theImage bloodLayer 127)

    (gimp-selection-layer-alpha theImage bloodLayer)
    (gimp-palette-set-foreground '(255 0 0))
    (gimp-bucket-fill theImage bloodLayer FG-BUCKET-FILL 0 100 0 0 0 0)
    (gimp-selection-none theImage)
    (plug-in-gauss-iir TRUE theImage bloodLayer 1 TRUE TRUE)

    (define oneLayer (car(gimp-image-flatten theImage)) )
    (plug-in-autocrop TRUE theImage oneLayer)
    
    (gimp-palette-set-foreground oldFore)
    (gimp-palette-set-background oldBack)

    (gimp-display-new theImage)
) 



; Register the function with the GIMP:

(script-fu-register
    "script-fu-blood-logo"
    "<Toolbox>/Xtns/Script-Fu/Logos/Dracula"
    "Draws the given text string with a border of dripping blood(!)"
    "Christopher Gutteridge"
    "1998, Christopher Gutteridge"
    "October 06, 1998"
    ""
    SF-VALUE "Text:"       "\"Dracula\""
    SF-VALUE "Font:"       "\"becker\""
    SF-VALUE "Font size:"  "80"
    SF-VALUE "Border size:"  "4"
    SF-VALUE "Max Drip size:"  "10"
)

