(define (sphinx-color-mul color factor) (cons (* factor (car color)) (cons (* factor (cadr color)) (cons (* factor (caddr color)) '())))) (define (sphinx-button text font fontsize textcolor basecolor bordercolor sizetext sizex sizey sizeb) (let* ((sizebb (+ sizeb sizeb)) (totalx (+ (+ (+ sizex sizetext) sizebb) 2)) (totaly (+ (+ sizey sizebb) 2))) (set! img (car (gimp-image-new totalx totaly RGB))) (set! layer (car (gimp-layer-new img totalx totaly RGB "Background" 100 NORMAL))) (gimp-image-undo-disable img) (gimp-image-add-layer img layer 0) (gimp-palette-set-foreground textcolor) (set! textlayer (car (gimp-text-fontname img -1 0 0 text 0 TRUE fontsize PIXELS font))) (gimp-drawable-set-name textlayer text) (let* ((width (car (gimp-drawable-width textlayer))) (height (car (gimp-drawable-height textlayer)))) (gimp-layer-set-offsets textlayer (+ 1 (+ sizeb (+ sizex (/ (- sizetext width) 2)))) (/ (- totaly height) 2)) (gimp-palette-set-background bordercolor) (gimp-edit-fill layer BG-IMAGE-FILL) (gimp-rect-select img 1 1 (- totalx 2) (- totaly 2) REPLACE 0 0) (gimp-palette-set-foreground (sphinx-color-mul basecolor (/ 1.0 0.85))) (gimp-palette-set-background (sphinx-color-mul basecolor (/ 0.7 0.85))) (gimp-edit-blend layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0 TRUE 1 1 1 (- totaly 2)) (if (> sizex 0) (begin (gimp-rect-select img (+ 1 sizeb) (+ 1 sizeb) sizex sizey REPLACE 0 0) (gimp-palette-set-foreground (sphinx-color-mul basecolor (/ 0.6 0.85))) (gimp-palette-set-background (sphinx-color-mul basecolor (/ 0.8 0.85))) (gimp-edit-blend layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0 TRUE 2 2 2 (- totaly 3)))) (gimp-rect-select img (+ 1 (+ sizeb sizex)) (+ 1 sizeb) sizetext sizey REPLACE 0 0) (gimp-palette-set-foreground (sphinx-color-mul basecolor (/ 0.9 0.85))) (gimp-palette-set-background (sphinx-color-mul basecolor (/ 0.8 0.85))) (gimp-edit-blend layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0 TRUE 2 2 2 (- totaly 3)) (gimp-selection-none img) (set! blank (cons-array 4 'byte)) (aset blank 0 0) (aset blank 1 0) (aset blank 2 0) (aset blank 3 0) (gimp-layer-add-alpha layer) (gimp-drawable-set-pixel layer 0 0 4 blank) (gimp-drawable-set-pixel layer 0 (- totaly 1) 4 blank) (gimp-drawable-set-pixel layer (- totalx 1) 0 4 blank) (gimp-drawable-set-pixel layer (- totalx 1) (- totaly 1) 4 blank) (gimp-display-new img) (gimp-image-undo-enable img)))) (script-fu-register "sphinx-button" "/Xtns/Script-Fu/Buttons/Sphinx Button" "Creation of a Sphinx-type web button" "Pierre-Louis Porté " "Pierre-Louis Porté" "2005-08-24" "" SF-STRING "Text" "KomiTê" SF-FONT "Font" "Arial" SF-ADJUSTMENT "Font size (px)" '(14 0 10000 1 10 0 1) SF-COLOR "Text color" '(0 0 0) SF-COLOR "Button color" '(130 195 217) SF-COLOR "Border color" '(127 127 127) SF-ADJUSTMENT "Text width" '(64 0 10000 1 10 0 1) SF-ADJUSTMENT "Icon width" '(36 0 10000 1 10 0 1) SF-ADJUSTMENT "Button height" '(24 0 10000 1 10 0 1) SF-ADJUSTMENT "Border width" '( 1 0 10000 1 10 0 1))