The full script (with better indentation and no line wrapping etc) is at:

http://www.crazysquirrel.com/software/gimp/aqua_gimp_2_0.scm

I didn't want to paste the whole thing as it is quite long but I've pasted it below

Thanks

Graham

;########################################################################
; START OF PILL DEFINITION
;########################################################################

(define
        (script-fu-aqua-pill
                img     
                bg-color
                background-color
                width   
                height  
                ratio   
                blur    
                shadow  
                flatten 
                antialias
                button-padding
        )       

        
  (define (remove-selection-corner img amount)
    (gimp-selection-feather img amount)
    (gimp-selection-sharpen img))
3
        
  (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-palette-get-foreground)))
(old-bg-color (car (gimp-palette-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 1 "Highlight Upper1" 75 SCREEN)))
(highlight-upper2-layer (car (gimp-layer-new img width-all height-all 1 "Highlight Upper2" 40 SCREEN)))
(highlight-lower (car (gimp-layer-new img width-all height-all 1 "Highlight Lower" 100 OVERLAY)))
(base1-layer (car (gimp-layer-new img width-all height-all 1 "Base Layer1" 75 SCREEN)))
(base2-layer (car (gimp-layer-new img width-all height-all 1 "Base Layer2" 100 NORMAL)))
) ; end variable definition




        (gimp-image-undo-disable img)
        (gimp-selection-none img)
        (gimp-palette-set-foreground bg-color)
        (gimp-palette-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 1 "Shadow Layer1" 100 SCREEN)))
(set! shadow2-layer (car (gimp-layer-new img width-all height-all 1 "Shadow Layer2" 100 NORMAL)))
(gimp-image-add-layer img shadow2-layer -1)
(gimp-image-add-layer img shadow1-layer -1)
(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 FG-IMAGE-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 FG-IMAGE-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 FG-IMAGE-FILL)
(gimp-hue-saturation base2-layer 0 0 -75 -50)
(gimp-selection-shrink img (* height 0.01))
(gimp-edit-fill base1-layer FG-IMAGE-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)
(gimp-image-add-layer img base2-layer -1)
(gimp-image-add-layer img base1-layer -1)
(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 BG-IMAGE-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)
(gimp-image-add-layer img highlight-lower -1)




(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 BG-IMAGE-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)
(gimp-image-add-layer img highlight-upper2-layer -1)




(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 BG-IMAGE-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-add-layer img highlight-upper1-layer -1)




        (gimp-image-undo-enable img)
        (gimp-undo-push-group-start img)
        (if (eqv? flatten TRUE)
            (gimp-image-flatten img))
        (gimp-undo-push-group-end img)
        (gimp-palette-set-foreground old-fg-color)
        (gimp-palette-set-background old-bg-color)
        (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
)
; (let* ((flatten TRUE)
(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)
))


(script-fu-register "script-fu-aqua-pill-round"
                    _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Aqua 
Pill/Round..."
                    "Create a round aqua pill image"
                    "Iccii <[EMAIL PROTECTED]>"
                    "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)

;########################################################################
; 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
)
; (let* ((flatten TRUE)
(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)
(gimp-message "Warning: Bar Length is too short to create your image!"))
))


(script-fu-register "script-fu-aqua-pill-hrule"
                    _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Aqua 
Pill/Hrule..."
                    "Create an Hrule with the aqua image"
                    "Iccii <[EMAIL PROTECTED]>"
                    "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)

;########################################################################
; 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
)

(let*
(
(flatten FALSE) ;switches flattening off because it blows up if it is switched on :oD
(shadow-height (if (eqv? shadow TRUE) 1 0))
(old-fg-color (car (gimp-palette-get-foreground))) ;save the old foreground color
(old-bg-color (car (gimp-palette-get-background))) ;save the old background color
(img (car (gimp-image-new 256 256 RGB))) ;create and aquire a new image
(tmp (gimp-palette-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-palette-set-foreground text-color)
(gimp-palette-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)
(script-fu-aqua-pill img widget-color background-color width height ratio blur shadow flatten antialias button-padding)

(gimp-undo-push-group-start img)
(gimp-image-raise-layer-to-top img text-layer)
(gimp-image-lower-layer img text-layer)
(gimp-image-lower-layer 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 3)
(gimp-image-add-layer img text-layer-shadow 4)
(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-palette-set-foreground widget-color)
(gimp-edit-fill text-layer-shadow FG-IMAGE-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-undo-push-group-end img)
(gimp-undo-push-group-start img)
(set! flatten TRUE)
(if (eqv? flatten TRUE)
(gimp-layer-set-name (car (gimp-image-flatten img)) text))
(gimp-palette-set-foreground old-fg-color)
(gimp-palette-set-background old-bg-color)
(gimp-undo-push-group-end img)
(gimp-displays-flush)
)
)


(script-fu-register
        "script-fu-aqua-pill-button"
        _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Aqua Pill/Button..."
        "Create an Aqua Pill Shaped Button"
        "[EMAIL PROTECTED]"
        "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
)

;########################################################################
; END OF BUTTON DEFINITION AND REGISTRATION
;########################################################################

Sven Neumann wrote:
Hi,

Graham Smith <[EMAIL PROTECTED]> writes:


I've got a bit of a problem with a script that I make fairly extensive
use of to create buttons for websites. It started out life as a
GIMP-1.1 script and I upgraded it to work with GIMP-2.0 but have
recently upgraded again to GIMP-2.2. Unfortunately this has broken the
script (right when I need it of curse) and I can't figure out what is
wrong.


The main problem is that you didn't sent us the full script and due to
the bad indentation it's rather difficult to see the problem. You are
most probably calling gimp-edit-fill on a drawable that has not yet
been added to the image. This has always been wrong and won't work any
longer in GIMP 2.2. See also http://developer.gimp.org/faq.html#id2779034


Sven
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user

Reply via email to