; PEL small button for PEL web pages (www.pel.byu.edu, traces.byu.edu) ; Copyright (C) 1999 Alen Peacock ; inspired partly by: ; Beveled pattern button for web pages ; Copyright (C) 1997 Federico Mena Quintero ; federico@nuclecu.unam.mx ; ; 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 add-lighting-effects (lambda (img background widthbut height) (gimp-rect-select img 1 1 (- widthbut 1) (- height 2) REPLACE TRUE FALSE 0) (gimp-brightness-contrast img background -85 0) (gimp-ellipse-select img 5 -35 87 70 REPLACE FALSE TRUE 30) (gimp-brightness-contrast img background 85 100) (gimp-selection-none img))) (define render-PELsmallButton (lambda (text text-size foundry family weight slant set-width spacing fg-color bg-color pressed) (let* ( (old-bg-color (car (gimp-palette-get-background))) (width 130) (widthbut 92) (height 16) (img (car (gimp-image-new width height RGB))) (background (car (gimp-layer-new img width height RGBA_IMAGE "Background" 100 NORMAL))) (textl (car (gimp-text img -1 0 0 text 0 TRUE text-size PIXELS foundry family weight slant set-width spacing)))) (gimp-image-disable-undo img) (gimp-image-add-layer img background 10) ; Set Background (gimp-palette-set-foreground fg-color) (gimp-palette-set-background bg-color) (gimp-rect-select img 0 0 widthbut height REPLACE TRUE FALSE 0) (gimp-bucket-fill img background BG-BUCKET-FILL NORMAL 100 15 FALSE 0 0) (gimp-rect-select img widthbut 0 (- width widthbut) height REPLACE TRUE FALSE 0) (gimp-edit-clear img background) (gimp-selection-none img) ; Set Foreground, Draw borders / areas (gimp-palette-set-background fg-color) (gimp-rect-select img 1 1 (- widthbut 1) (- height 1) REPLACE FALSE 0) (gimp-bucket-fill img background FG-BUCKET-FILL NORMAL 100 15 FALSE 0 0) (gimp-rect-select img widthbut 0 1 height REPLACE FALSE 0) (gimp-bucket-fill img background FG-BUCKET-FILL NORMAL 100 15 FALSE 0 0) (gimp-rect-select img 0 (- height 1) widthbut 1 REPLACE FALSE 0) (gimp-bucket-fill img background FG-BUCKET-FILL NORMAL 100 15 FALSE 0 0) (gimp-selection-none img) ; Color and position text (gimp-palette-set-background bg-color) (gimp-layer-set-preserve-trans textl TRUE) (gimp-edit-fill img textl) (if (< (- widthbut 4) (car (gimp-drawable-width textl))) (gimp-layer-scale textl (- widthbut 4) (car (gimp-drawable-height textl)) TRUE)) (gimp-layer-set-offsets textl (+ (/ (- widthbut (car (gimp-drawable-width textl))) 2) 1) 3) ; If not pressed, do lighting effects (gimp-image-set-active-layer img background) (set! background (car (gimp-image-merge-visible-layers img EXPAND-AS-NECESSARY))) (if (= pressed FALSE) (add-lighting-effects img background widthbut height)) ; Clean up (if (= pressed TRUE) (gimp-image-set-filename img (string-append text "-on.gif")) (gimp-image-set-filename img (string-append text ".gif"))) (gimp-palette-set-background old-bg-color) (gimp-convert-indexed img FALSE 255) (gimp-image-enable-undo img) (gimp-display-new img) (gimp-image-clean-all img)))) (define (script-fu-PELsmallButton text text-size foundry family weight slant set-width spacing fg-color bg-color pressed) (render-PELsmallButton text text-size foundry family weight slant set-width spacing fg-color bg-color FALSE) (if (= pressed TRUE) (render-PELsmallButton text text-size foundry family weight slant set-width spacing fg-color bg-color TRUE))) (script-fu-register "script-fu-PELsmallButton" "/Xtns/Script-Fu/PEL/PEL Small Button" "PEL Small Button" "Alen Peacock" "Performance Evaluation Laboratory, BYU" "March 1999" "" SF-VALUE "Text" "\"Contact\"" SF-VALUE "Text size" "12" SF-VALUE "Foundry" "\"monotype\"" SF-VALUE "Family" "\"arial\"" SF-VALUE "Weight" "\"bold\"" SF-VALUE "Slant" "\"r\"" SF-VALUE "Set width" "\"*\"" SF-VALUE "Spacing" "\"p\"" SF-COLOR "Foreground color" '(66 49 222) SF-COLOR "Background color" '(255 255 255) SF-TOGGLE "Render Pressed too?" TRUE)