RSS/Atom feed Twitter
Site is read-only, email is disabled

Script Problem

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

8 of 8 messages available
Toggle history

Please log in to manage your subscriptions.

Script Problem Graham Smith 22 Feb 09:55
  Script Problem Sven Neumann 22 Feb 21:38
   Script Problem Graham Smith 22 Feb 23:06
    Script Problem Sven Neumann 23 Feb 00:46
  Script Problem Sven Neumann 23 Feb 01:28
   Script Problem Graham Smith 23 Feb 10:11
    Script Problem Graham Smith 23 Feb 12:01
   Script Problem Graham Smith 23 Feb 12:39
Graham Smith
2005-02-22 09:55:42 UTC (about 19 years ago)

Script Problem

Hi,

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 offending section is below with a comment above the first line that breaks. According to the PDB gimp-edit-fill requires a drawable and an int32 which I think I am giving it but it just dies with "Procedural database execution failed". Any ideas? If you want to see the full script it is hosted here:

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

If I can fix this I will of course make a new version of the script available.

Many Thanks

-------------------

(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)) ;This is where it breaks first
(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)

))

Sven Neumann
2005-02-22 21:38:23 UTC (about 19 years ago)

Script Problem

Hi,

Graham Smith 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.

You are using deprecated constant names (FG-IMAGE-FILL should be FOREGROUND-FILL). I am however somewhat surprised since the old names are still supposed to work. Try if starting gimp with the '--pdb-compat-mode on' or '--pdb-compat-mode warn' command-line options makes a difference.

Sven

Graham Smith
2005-02-22 23:06:45 UTC (about 19 years ago)

Script Problem

--pdb-compat-mode on : made no difference

--pdb-compat-mode warn : produced the following error messages on std out (between #############)

############################################################ GIMP: WARNING: Plug-In "script-fu"
(/usr/lib/gimp/2.0/plug-ins/script-fu) called deprecated procedure 'gimp_palette_set_background'. It should call 'gimp_context_set_background' instead!

GIMP: WARNING: Plug-In "script-fu" (/usr/lib/gimp/2.0/plug-ins/script-fu) called deprecated procedure 'gimp_palette_get_foreground'. It should call 'gimp_context_get_foreground' instead!

GIMP: WARNING: Plug-In "script-fu" (/usr/lib/gimp/2.0/plug-ins/script-fu) called deprecated procedure 'gimp_palette_get_background'. It should call 'gimp_context_get_background' instead!

GIMP: WARNING: Plug-In "script-fu" (/usr/lib/gimp/2.0/plug-ins/script-fu) called deprecated procedure 'gimp_palette_set_foreground'. It should call 'gimp_context_set_foreground' instead!

GIMP: WARNING: Plug-In "script-fu" (/usr/lib/gimp/2.0/plug-ins/script-fu) called deprecated procedure 'gimp_palette_set_background'. It should call 'gimp_context_set_background' instead!

Button: Error while executing (script-fu-aqua-pill-button "The GIMP" 16 "Arial Black" '(0 0 0) '(121 161 248) '(229 238 255) 1 1 1 1 1 TRUE TRUE TRUE TRUE) ERROR: Procedural database execution failed: (gimp_edit_fill 7 0)
#######################################

Using non-deprecated FOREGROUND-FILL constant or the number 1 rather than FG-IMAGE-FILL causes the above error message to be displayed (so I don't think it is related to the constant)

Using the constant the PDB seems to recommend GIMP-FOREGROUND-FILL results in an "unbound variable" error being displayed. Why does FOREGROUND-FILL work and GIMP-FOREGROUND-FILL fail? Is that a mistake in the PDB or should I just know to knock GIMP- off the front of the name?

Any ideas?

Many Thanks.

Graham

Sven Neumann wrote:

Hi,

Graham Smith 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.

You are using deprecated constant names (FG-IMAGE-FILL should be FOREGROUND-FILL). I am however somewhat surprised since the old names are still supposed to work. Try if starting gimp with the '--pdb-compat-mode on' or '--pdb-compat-mode warn' command-line options makes a difference.

Sven

Sven Neumann
2005-02-23 00:46:16 UTC (about 19 years ago)

Script Problem

Hi,

Graham Smith writes:

--pdb-compat-mode on : made no difference

It shouldn't since that's the default. But I wanted to make sure. I also checked the code and the old enums are always available. The command-line option only affects deprecated function names.

--pdb-compat-mode warn : produced the following error messages on stdout

These warnings indicate that you should port your code to the new context API. It will continue to work with the old API but the new stuff has some advantages. You can call gimp-context-push / gimp-context-pop around your script and have it run in it's own context, thus not affecting the foreground/background colors in the user context.

Using the constant the PDB seems to recommend GIMP-FOREGROUND-FILL results in an "unbound variable" error being displayed. Why does FOREGROUND-FILL work and GIMP-FOREGROUND-FILL fail? Is that a mistake in the PDB or should I just know to knock GIMP- off the front of the name?

You are supposed to know. The Procedure Browser and the API docs show the C API. The Script-Fu API uses slightly different style.

Sven

Sven Neumann
2005-02-23 01:28:41 UTC (about 19 years ago)

Script Problem

Hi,

Graham Smith 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

Graham Smith
2005-02-23 10:11:42 UTC (about 19 years ago)

Script Problem

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" _"/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)

;######################################################################## ; 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" _"/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)

;######################################################################## ; 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"
_"/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
)

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

Sven Neumann wrote:

Hi,

Graham Smith 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

Graham Smith
2005-02-23 12:01:08 UTC (about 19 years ago)

Script Problem

Ok, for your reading pleasure I have completely fixed the indentation :o) to what I think is right. It uses hard tabs so should look fine in any text editor. And I have upgraded it to use the new context api (as best as I can) so that it no longer generates any deprecated warnings. You can find it here:

http://www.crazysquirrel.com/software/gimp/aqua_gimp_2_2_v1-1.scm

or pasted 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
display-image
)

(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)
(gimp-context-get-foreground)
)
)
(old-bg-color
(car
;(gimp-palette-get-background)
(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 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-context-set-foreground bg-color) ;(gimp-palette-set-background background-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 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-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)
(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 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) (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 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)
(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 BAKGROUND-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-context-set-foreground old-fg-color) ;(gimp-palette-set-background old-bg-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
)
; (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 display-image) )
)

(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
)
;removed on upgrade to 2.0
;(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 display-image) (gimp-message "Warning: Bar Length is too short to create your image!") )
)
)

(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
)

(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)
(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-palette-set-foreground text-color) (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-palette-set-foreground text-color) (gimp-context-set-foreground text-color) ;(gimp-palette-set-background background-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) (script-fu-aqua-pill img widget-color background-color width height ratio blur shadow flatten antialias button-padding display-image)

(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-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-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-context-set-foreground old-fg-color) ;(gimp-palette-set-background old-bg-color) (gimp-context-set-background old-bg-color) (gimp-undo-push-group-end img)
(gimp-displays-flush)
)
)

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

Graham Smith wrote:

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" _"/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)

;######################################################################## ; 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" _"/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)

;######################################################################## ; 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"
_"/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 )

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

Sven Neumann wrote:

Hi,

Graham Smith 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

Graham Smith
2005-02-23 12:39:58 UTC (about 19 years ago)

Script Problem

After correctly indenting the script and think about what you suggested I realized the mistake. You were spot-on right. There was a layer further down the script that was modified before being added to the image.

The fix was to simply move the layer addition high up the script. It has caused a couple of minor problems with the final image but I can fix those myself (probably :o).

Many Thanks

Graham

Sven Neumann wrote:

Hi,

Graham Smith 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