(define (script-fu-edwin-webbar colour shadowcolour alltext fontsize fontname split blur offsetx offsety) (let* ( (wordlist (reverse (edwin-splitwords () alltext))) (img1 (car (gimp-image-new 256 256 RGB))) (old-bg (car (gimp-palette-get-background))) (old-fg (car (gimp-palette-get-foreground))) (dummy (gimp-palette-set-foreground '(255 255 255))) (entries (length wordlist)) (text-layers (mapcar (lambda(x) (car (gimp-text-fontname img1 -1 0 0 x -1 TRUE fontsize PIXELS fontname))) wordlist )) (text-width (apply max (mapcar (lambda(x) (car (gimp-drawable-width x))) text-layers ))) (text-height (apply max (mapcar (lambda(x) (car (gimp-drawable-height x))) text-layers ))) ; (let ((wlcopy wordlist)) ; (while (not (null? wlcopy)) ; (text-layer (car (gimp-text-fontname img1 -1 0 0 text1 -1 TRUE fontsize PIXELS fontname))) ; ) (edgewidth 8) ; (eltheight (car (gimp-drawable-height text-layer))) (eltheight text-height) (curvewidth eltheight) (curveheight eltheight) (width (+ curveheight curveheight text-width offsetx offsetx)) (height (+ curveheight curveheight (* eltheight entries) offsety offsety)) (layer1 (car (gimp-layer-new img1 width height RGBA_IMAGE "Layer 1" 100 0))) ) ; (if (< (+ offsety offsety))) (gimp-image-undo-disable img1) (gimp-image-resize img1 width height curvewidth curveheight) (let ((i 0) (d (+ curveheight offsety))) (while (< i entries) (gimp-layer-set-offsets (nth i text-layers) (+ curvewidth offsetx) d) (if (equal? blur TRUE) (plug-in-mblur 1 img1 (nth i text-layers) 2 7 0) ) (set! d (+ d text-height)) (set! i (+ i 1)) ) ) ; (mapcar (lambda(x,d) (gimp-layer-set-offsets x curvewidth (+ curveheight (* d text-height)))) text-layers ?? ) (gimp-image-add-layer img1 layer1 0) (gimp-selection-all img1) (gimp-edit-clear layer1) (gimp-selection-none img1) (gimp-palette-set-background '(255 255 255)) ; select outer round-cornered-rectangle. Probably easier ways... ; (gimp-rect-select img1 0 curveheight width (* entries curveheight) REPLACE 0 0) ; (gimp-rect-select img1 curvewidth 0 (- width (* curvewidth 2)) height ADD 0 0) ; (gimp-ellipse-select img1 0 0 (* curvewidth 2) (* curveheight 2) ADD TRUE 0 0) ; (gimp-ellipse-select img1 (- width (* curvewidth 2)) 0 (* curvewidth 2) (* curveheight 2) ADD TRUE 0 0) ; (gimp-ellipse-select img1 (- width (* curvewidth 2)) (- height (* curvewidth 2)) (* curvewidth 2) (* curveheight 2) ADD TRUE 0 0) ; (gimp-ellipse-select img1 0 (- height (* curvewidth 2)) (* curvewidth 2) (* curveheight 2) ADD TRUE 0 0) (edwin-curvedrect-select img1 0 0 width height curvewidth curveheight REPLACE TRUE 0 0) ; inner (edwin-curvedrect-select img1 edgewidth edgewidth (- width (* edgewidth 2)) (- height (* 2 edgewidth)) (- curvewidth edgewidth) (- curveheight edgewidth) SUB TRUE 0 0) ; (gimp-rect-select img1 edgewidth curveheight (- width (* edgewidth 2)) (* entries curveheight) SUB 0 0) ; (gimp-rect-select img1 curvewidth edgewidth (- width (* curvewidth 2)) (- height (* 2 edgewidth)) SUB 0 0) ; (let* ( ; (x (* 2 (- curvewidth edgewidth))) ; (y (* 2 (- curveheight edgewidth)))) ; (gimp-ellipse-select img1 edgewidth edgewidth x y SUB TRUE 0 0) ; (gimp-ellipse-select img1 (+ edgewidth (- width (* curvewidth 2))) edgewidth x y SUB TRUE 0 0) ; (gimp-ellipse-select img1 (+ edgewidth (- width (* curvewidth 2))) (+ edgewidth (- height (* curvewidth 2))) x y SUB TRUE 0 0) ; (gimp-ellipse-select img1 edgewidth (+ edgewidth (- height (* curvewidth 2))) x y SUB TRUE 0 0) ; ) (gimp-edit-fill layer1 BG-IMAGE-FILL) ; 0 = EXPAND_AS_NECESSARY ; Merge layers, and bevel and shadow as a sholw (let* ( (newlayer (car (gimp-image-merge-visible-layers img1 EXPAND-AS-NECESSARY)))) (gimp-selection-layer-alpha newlayer) (gimp-palette-set-foreground colour) (gimp-edit-fill newlayer FG-IMAGE-FILL) (script-fu-add-bevel img1 newlayer 5 FALSE FALSE) ; (gimp-image-resize img1 (+ width 20) (+ height 20) 0 0) (script-fu-drop-shadow img1 newlayer 8 8 12 shadowcolour 80 FALSE) ) (let* ((newwidth (apply max (mapcar (lambda(x) (car (gimp-drawable-width x))) (edwin-layers-list img1)))) (newheight (apply max (mapcar (lambda(x) (car (gimp-drawable-height x))) (edwin-layers-list img1))))) (gimp-image-resize img1 newwidth newheight 0 0) ; Add background of white. Probably be better if saves transparent image, but not sure of browser support.... (let* ( (newlayer (car (gimp-layer-new img1 (car (gimp-image-width img1)) (car (gimp-image-height img1)) RGBA-IMAGE "Background" 100 NORMAL-MODE)))) (gimp-image-add-layer img1 newlayer 0) (gimp-palette-set-background '(255 255 255)) (gimp-selection-all img1) (gimp-edit-fill newlayer BG-IMAGE-FILL) (gimp-image-lower-layer-to-bottom img1 newlayer) ) (let* ( (newlayer (car (gimp-image-merge-visible-layers img1 EXPAND-AS-NECESSARY))) (d 0)) ; (gimp-rect-select img1 0 0 50 50 REPLACE 0 0) ; (edwin-rect-to-new img1 newlayer 0 0 50 50) (if (equal? split TRUE) (begin (edwin-rect-to-new img1 newlayer 0 0 newwidth (+ curveheight offsety)) (while (< d entries) (edwin-rect-to-new img1 newlayer 0 (+ curveheight offsety (* d text-height)) newwidth text-height) (set! d (+ d 1)) ) (edwin-rect-to-new img1 newlayer 0 (+ curveheight offsety (* d text-height)) newwidth (- newheight (+ curveheight offsety (* d text-height)) )) )) ) ) (gimp-palette-set-background old-bg) (gimp-palette-set-foreground old-fg) (gimp-image-undo-enable img1) (gimp-display-new img1) ) ) (define (edwin-layers-list img1) (let* ( (array (car (cdr (gimp-image-get-layers img1)))) (list ()) (i 0)) (while (< i (length array)) (set! list (cons (aref array i) list)) (set! i (+ 1 i)) ) list ) ) (define (edwin-rect-to-new image layer x y width height) (gimp-rect-select image x y width height REPLACE 0 0) (gimp-edit-copy layer) (let* ((newimg (car (gimp-image-new width height RGB))) (newlayer (car (gimp-layer-new newimg width height RGBA-IMAGE "Pasted" 100 NORMAL-MODE))) ) (gimp-image-undo-disable newimg) (gimp-image-add-layer newimg newlayer -1) (gimp-floating-sel-anchor (car (gimp-edit-paste newlayer 0))) ; (gimp-image-resize newimg (car (gimp-drawable-width newlayer)) (car (gimp-drawble-width newlayer)) ) (gimp-image-undo-enable newimg) (gimp-display-new newimg) ) ) ; note: operation must be ADD or SUB else there will be funny behaviour... ; can now deal with REPLACE (define (edwin-curvedrect-select image x y width height curve-w curve-h operation antialias feather feather-rad) (gimp-rect-select image x (+ y curve-h) width (- height (* 2 curve-h)) operation feather feather-rad) (if (equal? operation REPLACE) (set! operation ADD)) (gimp-rect-select image (+ x curve-w) y (- width (* 2 curve-w)) height operation feather feather-rad) (gimp-ellipse-select image x y (* curve-w 2) (* curve-h 2) operation antialias feather feather-rad) (gimp-ellipse-select image (- (+ x width) (* 2 curve-w)) y (* curve-w 2) (* curve-h 2) operation antialias feather feather-rad) (gimp-ellipse-select image x (- (+ y height) (* 2 curve-h)) (* curve-w 2) (* curve-h 2) operation antialias feather feather-rad) (gimp-ellipse-select image (- (+ x width) (* 2 curve-w)) (- (+ y height) (* 2 curve-h)) (* curve-w 2) (* curve-h 2) operation antialias feather feather-rad) ) (define (edwin-splitwords list text) (let ((pos (string-search "," text))) (if (null? pos) (cons text list) (edwin-splitwords (cons (substring text 0 pos ) list) (substring text (+ pos 1) (string-length text)) ) ) ) ) (define (edwin-wl2layers list wordlist) (if (null? wordlist) (list) (edwin-wl2layers ((cons (car (gimp-text-fontname img1 -1 0 0 (car wordlist) -1 TRUE fontsize PIXELS fontname)) list) (cdr wordlist))) ) ) ;(define (edwin-splitwords text) ; ; (car (edwin-transfer () () (string->list text))) ;) ;(define (edwin-transfer finall charl inl) ; (if (null? inl) ; (if (null? charl) ; (finall) ; (cons (list->string charl) finall)) ; (if (equal? (string->list ",") (car inl)) ; (edwin-transfer ( (cons (list->string charl) finall) () (cdr inl))) ; (edwin-transfer ( finall (cons (car inl) charl) (cdr inl))))) ;) ;(define string->list ; (lambda (s) ; (while ((i (- (string-length s) 1) (- i 1)) ; (ls '() (cons (string-ref s i) ls))) ; ((< i 0) ls)))) ; (string-ref string n) ; (substring string start end) ; (string-length string) ;(define (edwin-transfer l r) ; (if (or (null? r) ; (equal? #\, (car r))) ; (l (cdr r)) ; (edwin-transfer (l (cdr r))) ;) (script-fu-register "script-fu-edwin-webbar" _"/Xtns/Script-Fu/Edwin/Web bar" "Create Edwin's web bar" "Edwin Carter " "Edwin Carter" "Born 19th May 2001" "" SF-COLOR _"Colour" '(4 98 214) SF-COLOR _"Shadow colour" '(43 9 93) ;'(8 34 86) SF-STRING _"Entry1,Entry2,..." "Me" ; SF-STRING _"Line 2" "Physics" ; SF-STRING _"Line 3" "Something" ; SF-STRING _"Line 4" "Else" SF-ADJUSTMENT _"Font Size (pixels)" '(25 2 1000 1 10 0 1) SF-FONT _"Font" "-urw-palatino-bold-r-normal-*-25-*-*-*-p-*-iso8859-1" SF-TOGGLE _"Split" FALSE SF-TOGGLE _"Motion blur" FALSE ; Guess:: default min max arrow-shift page-shift ? ? SF-ADJUSTMENT _"Text Offset x" '(0 -100 100 1 10 0 1) SF-ADJUSTMENT _"Text Offset y" '(0 -100 100 1 10 0 1) )