;
; "Rough text" .scAm B-) script (c) Urpo Lankinen 12.7.1997
; Not very elegant script, but what the heck, it works. Sometimes.
;
; $Id: roughtext.scm,v 1.2 1998/05/10 06:26:07 urpo Exp urpo $
;

(define (script-fu-rough-text text font size amount trsh)
  (let* ((img (car (gimp-image-new 256 256 GRAY)))
	 (bg-layer (car (gimp-text img -1 0 0 text 10 TRUE
				     size PIXELS "*" font "*" "r" "*" "*")))
	 (text-layer (car (gimp-text img -1 0 0 text 10 TRUE
				     size PIXELS "*" font "*" "r" "*" "*")))
	 (width (car (gimp-drawable-width text-layer)))
	 (height (car (gimp-drawable-height text-layer)))
	 (old-fg (car (gimp-palette-get-foreground)))
	 (old-bg (car (gimp-palette-get-background))))

    (gimp-image-disable-undo img)
    (gimp-layer-set-name text-layer "Text")
    (gimp-layer-set-name bg-layer "Background")
    (gimp-image-resize img width height 0 0)

    (gimp-image-set-active-layer img text-layer)
    (gimp-palette-set-foreground '(0 0 0))

    ; Spread. Repeat x times...?
    (plug-in-spread 1 img text-layer amount amount)
    (plug-in-spread 1 img text-layer amount amount)

    (plug-in-gauss-rle 1 img text-layer (* amount 1.2) TRUE TRUE)
    (plug-in-c-astretch 1 img text-layer)
    (gimp-layer-set-preserve-trans text-layer TRUE)

    (gimp-image-set-active-layer img bg-layer)
    (gimp-palette-set-foreground '(255 255 255))
    (gimp-edit-fill img bg-layer)

    (set! newlayer (car (gimp-image-flatten img)))
    (gimp-threshold img newlayer trsh 255)

    (gimp-palette-set-background old-bg)
    (gimp-palette-set-foreground old-fg)
    (gimp-image-enable-undo img)
    (gimp-display-new img)))
;
; Hajaa-ho!
;
(script-fu-register
 "script-fu-rough-text"
 "<Toolbox>/Xtns/Script-Fu/Logos/Rough Text"
 "Creates text that looks like enlarged text from an old typewriter.
  Based on the \"Rough text\" tutorial by Zach."
 "Urpo Lankinen <wwwwolf@iki.fi>"
 "Urpo Lankinen <wwwwolf@iki.fi>"
 "1997"
 ""
 SF-VALUE "Text String" "\"Top secret\""
 SF-VALUE "Font" "\"courier\""
 SF-VALUE "Font Size" "50"
 SF-VALUE "Spread amount" "3"    ; 5
 SF-VALUE "Threshold" "150")     ; 170

