; The GIMP -- an image manipulation program ; Copyright (C) 1995 Spencer Kimball and Peter Mattis ; ; Aqua Pill --- create an aqua pill web button ; Copyright (C) 2001 Iccii ; ; Additions and Gimp 2.0 Upgrade ; Copyright (C) 2003 Graham Smith ; ; -------------------------------------------------------------------- ; - Changelog - ; version 0.1 2001/03/06 Iccii ; - Initial relase ; version 0.2 2001/03/08 Iccii ; - Move the logo generator function from base code to extra code ; version 0.3 2001/03/13 Iccii ; - Create an Aqua Pill hrule ; version 0.4 2001/03/21 Iccii ; - Create a Round Aqua Pill ; version 0.5 2001/03/25 Iccii ; - Add the "remove-dust" function to remove the dust images ; version 0.5a 2001/04/02 Iccii ; - Add antialias option ; - Font size calculation make better ; version 0.5b 2001/05/25 Iccii ; - A bit optimize ; version 0.5c 2001/06/21 Iccii ; - Minor fix ; version 0.5d 2001/08/10 Iccii ; - Delete the "remove-dust" function ; version 0.6 2001/09/17 lasm ; - Fixed the "Flatten" bug ; version 0.7 2003/08/09 graham ; - Added commenting ; - Allowed setting of widget back ground color. ; - Changed bg-color to widget-color and added background-color ; - Removed unused parameters from script-fu-aqua-pill function ; version 1.1 2004/04/08 graham ; - Upgraded script to work with Gimp 2.0 buttons look slightly ; different but are pretty close ; - Added ability to set how many pixels of padding are draw ; around each of the 'buttons' rather than an abitary amount ; - Added a bunch of comments ; version 1.2 2005/02/23 graham ; -Upgraded script to work with Gimp 2.2 ; -Fixed layer ordering problems on upgrade ; -Properly fixed flatten bug so that you can now flatten ; buttons. ; -Removed all deprecated function calls ; -------------------------------------------------------------------- ; ; 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. ; ;######################################################################## ; START OF PILL DEFINITION ;######################################################################## (define (script-fu-aqua-pill img bg-color background-color width height ratio blur shadow flatten antialias button-padding display-image ) (define (remove-selection-corner img amount) (gimp-selection-feather img amount) (gimp-selection-sharpen img) ) (define (round-select img x y width height ratio) (let* ( (diameter (* ratio height) ) ) (gimp-ellipse-select img x y diameter height ADD FALSE 0 0) (gimp-ellipse-select img (+ x (- width diameter) ) y diameter height ADD FALSE 0 0 ) (gimp-rect-select img (+ x (/ diameter 2) ) y (- width diameter) height ADD FALSE 0 ) ) ) (let* ( (old-fg-color (car (gimp-context-get-foreground) ) ) (old-bg-color (car (gimp-context-get-background) ) ) (shadow-height (if (eqv? shadow TRUE) 1 0 ) ) (bluramount (if (> width height) (* blur height) (* blur width) ) ) (shiftx button-padding) (shifty button-padding) (width-all (+ width (* 1 shiftx) (* button-padding 2) ) ) (height-all (+ height (* 1 shifty) (* height shadow-height 0.5) (* button-padding 2) ) ) (whratio (sqrt (/ height width) ) ) (highlight-upper1-layer (car (gimp-layer-new img width-all height-all RGBA-IMAGE "Highlight Upper1" 75 SCREEN) ) ) (highlight-upper2-layer (car (gimp-layer-new img width-all height-all RGBA-IMAGE "Highlight Upper2" 40 SCREEN) ) ) (highlight-lower (car (gimp-layer-new img width-all height-all RGBA-IMAGE "Highlight Lower" 100 OVERLAY) ) ) (base1-layer (car (gimp-layer-new img width-all height-all RGBA-IMAGE "Base Layer1" 75 SCREEN) ) ) (base2-layer (car (gimp-layer-new img width-all height-all RGBA-IMAGE "Base Layer2" 100 NORMAL) ) ) ) ; end variable definition ;Added to img earlier to fix change in upgrade to gimp 2.2 (gimp-image-add-layer img base2-layer -1) (gimp-image-add-layer img base1-layer -1) (gimp-image-add-layer img highlight-lower -1) (gimp-image-add-layer img highlight-upper1-layer -1) (gimp-image-add-layer img highlight-upper2-layer -1) (gimp-image-undo-disable img) (gimp-selection-none img) (gimp-context-set-foreground bg-color) (gimp-context-set-background background-color) (gimp-drawable-fill base2-layer TRANS-IMAGE-FILL) (gimp-drawable-fill base1-layer TRANS-IMAGE-FILL) (gimp-drawable-fill highlight-lower TRANS-IMAGE-FILL) (gimp-drawable-fill highlight-upper2-layer TRANS-IMAGE-FILL) (gimp-drawable-fill highlight-upper1-layer TRANS-IMAGE-FILL) ;------------------------- START - DROP SHADOW EFFECT ----------------------------- (if (eqv? shadow TRUE) (begin (set! shadow1-layer (car (gimp-layer-new img width-all height-all RGBA-IMAGE "Shadow Layer1" 100 SCREEN) ) ) (set! shadow2-layer (car (gimp-layer-new img width-all height-all RGBA-IMAGE "Shadow Layer2" 100 NORMAL) ) ) (gimp-image-add-layer img shadow2-layer -1) (gimp-image-lower-layer-to-bottom img shadow2-layer) (gimp-image-add-layer img shadow1-layer -1) (gimp-image-lower-layer-to-bottom img shadow1-layer) (gimp-drawable-fill shadow2-layer TRANS-IMAGE-FILL) (gimp-drawable-fill shadow1-layer TRANS-IMAGE-FILL) (round-select img shiftx shifty width height ratio) (gimp-selection-shrink img (* height 0.1) ) (gimp-edit-fill shadow1-layer FOREGROUND-FILL) (gimp-hue-saturation shadow1-layer 0 0 75 0) (gimp-selection-grow img (+ 1 (* bluramount 0.3) ) ) (plug-in-gauss-iir2 1 img shadow1-layer (+ 1 (* bluramount 0.3) ) (+ 1 (* bluramount 0.3) ) ) (gimp-drawable-offset shadow1-layer 0 1 0 (* height 0.4) ) (gimp-selection-none img) (round-select img shiftx shifty width height ratio) (gimp-edit-fill shadow2-layer FOREGROUND-FILL) (gimp-hue-saturation shadow2-layer 0 0 0 -25) (gimp-selection-grow img (+ 1 (* bluramount 0.3) ) ) (plug-in-gauss-iir2 1 img shadow2-layer (+ 1 (* bluramount 0.3) ) (+ 1 (* bluramount 0.3) ) ) (gimp-drawable-offset shadow2-layer 0 1 0 (* height 0.4) ) (gimp-selection-none img) ) ) ;------------------------- END - DROP SHADOW EFFECT ----------------------------- (round-select img shifty shifty width height ratio) (gimp-edit-fill base2-layer FOREGROUND-FILL) (gimp-hue-saturation base2-layer 0 0 -75 -50) (gimp-selection-shrink img (* height 0.01) ) (gimp-edit-fill base1-layer FOREGROUND-FILL) (gimp-hue-saturation base1-layer 0 0 -50 -50) (gimp-selection-grow img (* height 0.01) ) (plug-in-gauss-iir2 1 img base1-layer (+ 1 (* bluramount 0.05) ) (+ 1 (* bluramount 0.05) ) ) (gimp-selection-none img) (if (eqv? antialias TRUE) (let ( (layer-width (car (gimp-drawable-width base2-layer) ) ) (layer-height (car (gimp-drawable-height base2-layer) ) ) ) (gimp-layer-scale base2-layer (* 2 layer-width) (* 2 layer-height) 0 ) (gimp-layer-scale base2-layer layer-width layer-height 0) ) ) (round-select img shifty shifty width height ratio) (gimp-rect-select img shifty shifty width (* height 0.5) SUB 0 0 ) (gimp-selection-shrink img (* height 0.05) ) (remove-selection-corner img (* 0.4 height) ) (gimp-edit-fill highlight-lower BACKGROUND-FILL) (gimp-selection-grow img (+ 1 (* bluramount 0.4) ) ) (plug-in-gauss-iir2 1 img highlight-lower (+ 1 (* bluramount 0.4) ) (+ 1 (* bluramount 0.4) ) ) (set! highlight-lower-copy (car (gimp-layer-copy highlight-lower FALSE) ) ) (gimp-selection-none img) (gimp-image-add-layer img highlight-lower-copy -1) ;ADDED FOR GIMP 2.2 (if (eqv? shadow TRUE) (begin (gimp-image-raise-layer-to-top img highlight-lower-copy) ) ) (gimp-image-lower-layer img highlight-lower-copy) (gimp-image-lower-layer img highlight-lower-copy) (round-select img shiftx shifty width height ratio) (gimp-rect-select img shiftx (+ shifty (* height 0.35) ) width height SUB 0 0 ) (gimp-selection-shrink img (* height 0.02 whratio) ) (remove-selection-corner img (+ (* height 0.4) ) ) (gimp-edit-fill highlight-upper2-layer BACKGROUND-FILL) (gimp-selection-grow img (+ 1 (* bluramount 0.08) ) ) (plug-in-gauss-iir2 1 img highlight-upper2-layer (+ 1 (* bluramount 0.08) ) (+ 1 (* bluramount 0.08) ) ) (gimp-selection-none img) (round-select img shiftx shifty width height ratio) (gimp-rect-select img shiftx (+ shifty (* height 0.28) ) width height SUB 0 0 ) (gimp-selection-shrink img (* height 0.09) ) (remove-selection-corner img (* 0.15 height) ) (gimp-edit-fill highlight-upper1-layer BACKGROUND-FILL) (gimp-selection-grow img (+ 1 (* bluramount 0.05) ) ) (plug-in-gauss-iir2 1 img highlight-upper1-layer (+ 1 (* bluramount 0.05) ) (+ 1 (* bluramount 0.05) ) ) (gimp-selection-none img) (gimp-image-undo-enable img) (gimp-image-undo-group-start img) (if (eqv? flatten TRUE) (gimp-image-flatten img) ) (gimp-image-undo-group-end img) (gimp-context-set-foreground old-fg-color) (gimp-context-set-background old-bg-color) (if (eqv? display-image TRUE) (gimp-display-new img) (gimp-displays-flush) ) ) ) ;######################################################################## ; END OF PILL DEFINITION ;######################################################################## ;######################################################################## ; START OF ROUND DEFINITION AND REGISTRATION ;######################################################################## (define (script-fu-aqua-pill-round baseradius button-padding widget-color background-color ratio blur shadow flatten antialias display-image ) (gimp-context-push) (let* ( (shadow-height (if (eqv? shadow TRUE) 1 0 ) ) (height baseradius) (radius (/ (* ratio height) 4 ) ) (width (+ 1 (* ratio height) ) ) (shiftx button-padding) (shifty button-padding) (height-all (+ height shiftx (* height shadow-height 0.5) (* button-padding 2) ) ) (width-all (+ width shifty (* button-padding 2) ) ) (img (car (gimp-image-new width-all height-all RGB) ) ) ) (script-fu-aqua-pill img widget-color background-color width height ratio blur shadow flatten antialias button-padding display-image) ) (gimp-context-pop) ) (script-fu-register "script-fu-aqua-pill-round" _"/Xtns/Script-Fu/Web Page Themes/Aqua Pill/Round..." "Create a round aqua pill image" "Iccii " "Iccii" "Jun 2001" "" SF-ADJUSTMENT _"Base Radius (pixel)" '(100 2 500 1 1 0 1) SF-ADJUSTMENT _"Padding" '(1 0 100 1 1 0 1) SF-COLOR _"Widget Color" '(121 161 248) SF-COLOR _"Background Color" '(229 238 255) SF-ADJUSTMENT _"Round Ratio" '(1 0.05 9 0.05 0.5 2 0) SF-ADJUSTMENT _"Blur Amount" '(1 0.05 5 0.05 0.5 2 0) SF-TOGGLE _"Drop Shadow" TRUE SF-TOGGLE _"Flatten" TRUE SF-TOGGLE _"Antialias" TRUE SF-TOGGLE _"Display Final Image" TRUE ) ;######################################################################## ; END OF ROUND DEFINITION AND REGISTRATION ;######################################################################## ;######################################################################## ; START OF HRULE DEFINITION AND REGISTRATION ;######################################################################## (define (script-fu-aqua-pill-hrule width height button-padding widget-color background-color ratio blur shadow flatten antialias display-image ) (gimp-context-push) (let* ( (shadow-height (if (eqv? shadow TRUE) 1 0 ) ) (radius (/ (* ratio height) 4 ) ) (shiftx button-padding) (shifty button-padding) (height-all (+ height shiftx (* height shadow-height 0.5) (* button-padding 2) ) ) (width-all (+ width shifty (* button-padding 2) ) ) (img (car (gimp-image-new width-all height-all RGB) ) ) ) (if (< (* height ratio) width ) (script-fu-aqua-pill img widget-color background-color width height ratio blur shadow flatten antialias button-padding display-image) (gimp-message "Warning: Bar Length is too short to create your image!") ) ) (gimp-context-pop) ) (script-fu-register "script-fu-aqua-pill-hrule" _"/Xtns/Script-Fu/Web Page Themes/Aqua Pill/Hrule..." "Create an Hrule with the aqua image" "Iccii " "Iccii" "Jun 2001" "" SF-ADJUSTMENT _"Bar Length" '(500 2 1500 1 1 0 1) SF-ADJUSTMENT _"Bar Height" '(25 2 500 1 1 0 1) SF-ADJUSTMENT _"Bar Padding" '(1 0 100 1 1 0 1) SF-COLOR _"Widget Color" '(121 161 248) SF-COLOR _"Background Color" '(229 238 255) SF-ADJUSTMENT _"Round Ratio" '(1 0.05 5 0.05 0.5 2 0) SF-ADJUSTMENT _"Blur Amount" '(1 0.05 5 0.05 0.5 2 0) SF-TOGGLE _"Drop Shadow" TRUE SF-TOGGLE _"Flatten" TRUE SF-TOGGLE _"Antialias" TRUE SF-TOGGLE _"Display Final Image" TRUE ) ;######################################################################## ; END OF HRULE DEFINITION AND REGISTRATION ;######################################################################## ;######################################################################## ; START OF BUTTON DEFINITION AND REGISTRATION ;######################################################################## (define (script-fu-aqua-pill-button text size font text-color widget-color background-color xpadding ypadding button-padding ratio blur shadow flatten antialias display-image ) (gimp-context-push) (let* ( (shadow-height (if (eqv? shadow TRUE) 1 0 ) ) (old-fg-color (car ;(gimp-palette-get-foreground) (gimp-context-get-foreground) ) ) ;save the old foreground color (old-bg-color (car ;(gimp-palette-get-background) (gimp-context-get-background) ) ) ;save the old background color (img (car (gimp-image-new 256 256 RGB) ) ) ;create and aquire a new image (tmp (gimp-context-set-foreground text-color) ) ;only change fg-color for text color (text-layer (car (gimp-text-fontname img -1 0 0 text 0 TRUE size PIXELS font) ) ) (text-width (car (gimp-drawable-width text-layer) ) ) ;width of the text (text-height (car (gimp-drawable-height text-layer) ) ) ;height of the text (radius (/ (* ratio text-height) 4 ) ) ; radius of the end caps ;this calulates how much space the text alone needs (height (+ (* 2 ypadding) text-height ) ) (width (+ (* 2 (+ radius xpadding) ) text-width ) ) ;shifts the text to the center of the image ;the button-padding tell use how much space should be around the button (shiftx button-padding) (shifty button-padding) ;this is where the overall size of the drawing is calculated ;note that this calculation all occus elsewhere ;you need to use twice the padding in order to make sure there ;are the same number of pixels onthe bottom and right as ;are on the top and left (height-all (+ height shiftx (* height shadow-height 0.5) (* button-padding 2) ) ) (width-all (+ width shifty (* button-padding 2) ) ) ) (gimp-context-set-foreground text-color) (gimp-context-set-background background-color) ;the image is resized to width-all x height-all so that the button will fit on it ;and the text is shifted to the center (gimp-image-resize img width-all height-all (+ shiftx xpadding radius) (+ shifty ypadding) ) (gimp-layer-set-offsets text-layer (+ shiftx xpadding radius) (+ shifty ypadding) ) ;(script-fu-aqua-pill img widget-color background-color width height ratio blur shadow flatten antialias button-padding display-image) ;correct fix for flatten bug (script-fu-aqua-pill img widget-color background-color width height ratio blur shadow FALSE antialias button-padding display-image) (gimp-image-undo-group-start img) (gimp-image-raise-layer-to-top img text-layer) (set! text-layer-copy (car (gimp-layer-copy text-layer FALSE) ) ) (set! text-layer-shadow (car (gimp-layer-copy text-layer FALSE) ) ) (gimp-image-add-layer img text-layer-copy -1) ;ADDED FOR GIMP 2.2 (gimp-image-raise-layer-to-top img text-layer-copy) (gimp-image-lower-layer img text-layer-copy) (gimp-image-add-layer img text-layer-shadow -1) ;ADDED FOR GIMP 2.2 (gimp-image-raise-layer-to-top img text-layer-shadow) (gimp-image-lower-layer img text-layer-shadow) (gimp-image-lower-layer img text-layer-shadow) (gimp-layer-set-mode text-layer-shadow MULTIPLY-MODE) (gimp-drawable-offset text-layer-copy 0 1 (- (* xpadding 0.1) ) (- (* ypadding 0.1) ) ) (gimp-drawable-offset text-layer-shadow 0 1 (- (* xpadding 0.1) ) (* height 0.1) ) (gimp-invert text-layer-copy) (gimp-selection-layer-alpha text-layer-shadow) (gimp-context-set-foreground widget-color) (gimp-edit-fill text-layer-shadow FOREGROUND-FILL) (gimp-selection-grow img (+ 1 (* height blur 0.1) ) ) (plug-in-gauss-iir2 1 img text-layer-shadow (+ 1 (* height blur 0.1) ) (+ 1 (* height blur 0.1) ) ) (gimp-selection-none img) (gimp-image-undo-group-end img) (gimp-image-undo-group-start img) (if (eqv? flatten TRUE) (gimp-drawable-set-name (car (gimp-image-flatten img) ) text ) ) (gimp-context-set-foreground old-fg-color) (gimp-context-set-background old-bg-color) (gimp-image-undo-group-end img) (gimp-displays-flush) ) (gimp-context-pop) ) (script-fu-register "script-fu-aqua-pill-button" _"/Xtns/Script-Fu/Web Page Themes/Aqua Pill/Button..." "Create an Aqua Pill Shaped Button" "iccii@hotmail.com" "iccii" "Aug 2003" "" SF-STRING _"Text" "The GIMP" SF-ADJUSTMENT _"Font Size (pixels)" '(16 2 500 1 1 0 1) SF-FONT _"Font" "Arial Black" SF-COLOR _"Text Color" '(0 0 0) SF-COLOR _"Widget Color" '(121 161 248) SF-COLOR _"Background Color" '(229 238 255) SF-ADJUSTMENT _"Text Padding X" '(1 0 100 1 10 0 1) SF-ADJUSTMENT _"Text Padding Y" '(1 0 100 1 10 0 1) SF-ADJUSTMENT _"Button Padding" '(1 0 100 1 10 0 1) SF-ADJUSTMENT _"Round Ratio" '(1 0.05 5 0.05 0.5 2 0) SF-ADJUSTMENT _"Blur Amount" '(1 0.05 5 0.05 0.5 2 0) SF-TOGGLE _"Drop Shadow" TRUE SF-TOGGLE _"Flatten" TRUE SF-TOGGLE _"Antialias" TRUE SF-TOGGLE _"Display Final Image" TRUE ) ;######################################################################## ; END OF BUTTON DEFINITION AND REGISTRATION ;########################################################################