; The GIMP -- an image manipulation program ; Copyright (C) 1995 Spencer Kimball and Peter Mattis ; ; AquaPro script for GIMP 1.2 ; Copyright (C) 2001 Denis Bodor ; Copyright (C) 2001-2002 Iccii ; ; The original Perl-Fu script was written by Denis Bodor ; - http://www.linuxmag-france.org/redactor_zone/aquapl.html ; ; Translated into Script-Fu by Iccii ; ; -------------------------------------------------------------------- ; version 1.0 by Iccii 2001/09/14 ; - Initial relase (aquabou.scm) ; This version is directly translation version from Perl-Fu ; version 1.1 by Iccii 2001/09/17 ; - Second relase (aquabou2.scm) ; - Added two setting options which enable adjustment Width and Height ; version 1.1a by Iccii 2001/11/01 ; - Fixed wrong parameter name ...Thanks to _tom_ ; version 1.2 by Iccii 2001/11/02 ; - Added creating logo in aqua pill (script-fu-aquapro2-button) ; - Note that this relase has bugs in some situations ; version 1.2a by Iccii 2001/11/06 ; - Fixed above bugs ; - Moved menu path from /Script-Fu/AquaPro2* ; to /Script-Fu/Web Page Themes/AquaPro2/* ; version 1.3 by Iccii 2001/11/07 ; - Added new image creation function (script-fu-aquapro2-round) ; - Added new image creation function (script-fu-aquapro2-logo-in-ball) ; - Changed the top reflecting fusion ; version 1.3a by Iccii 2001/11/08 ; - Now, script-fu-aquapro2-logo-in-ball function allows white space ; in string to split into each balls per words ; version 1.3b by Iccii 2001/11/09 ; - Adjusted the top highlight reflection (looks better) ; version 1.3b by Iccii 2001/11/12 ; - Added "Transparent BG" toggle (Thanks to Darryn Lowe for advising) ; version 1.3c by Iccii 2001/11/12 ; - Fixed crazzy background color ; - Added undo stuff (try enter Ctrl-Z) ; version 1.3d by Iccii 2002/01/17 ; - Looks more better background color ; - Renamed "Logo in Ball" to "Logo in Pill" ; - I forgeted to delete unused Image ; - Deleted "Apply Lens" option in "Logo in Pill" ; version 1.3e by Iccii 2002/01/26 ; - Fixed drop shadow bug (thanks to KINO) ; ; -------------------------------------------------------------------- ; ; ################################################################################# ; # ; # aquabou.pl ; # A Gimp Perl-Fu that create a Aqua Style Button ; # ; # Copyright (C) 2001 Denis Bodor ; # ; # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ; # ; ################################################################################# ;追加 (define (script-fu-disp img oc1 coulop coulgrad coultex width height) ;;2.4追加 (let ( (oc2 0) (oc3 0) ) (set! oc2 (car (gimp-layer-copy oc1 0))) ;create layer copy (gimp-image-add-layer img oc2 0) ;add layer (set! oc3 (car (gimp-layer-copy oc2 0))) ;create layer copy (gimp-selection-all img) (cond((= coulop 1) (gimp-gradients-set-gradient coulgrad) (gimp-blend oc1 BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY 0 100 20 REPEAT-NONE FALSE 0 0 0 0 0 0 width height)) ((= coulop 2) (gimp-patterns-set-pattern coultex) (gimp-edit-bucket-fill oc1 BUCKET-FILL-PATTERN LAYER-MODE-NORMAL-LEGACY 100 255 FALSE 0 0) )) (gimp-edit-clear oc2) (gimp-selection-none img) (gimp-image-add-layer img oc3 0) ;add 2.8 (gimp-selection-layer-alpha oc3) (gimp-selection-feather img (/ height 10)) ;blur (gimp-palette-set-foreground '(0 0 0)) (gimp-edit-fill oc2 FILL-FOREGROUND) (gimp-selection-none img) ;;; (plug-in-gauss-iir2 1 img oc2 (/ height 10) (/ height 10)) (plug-in-displace 1 img oc1 (* (/ width 525) 15) (* (/ height 125) 20) TRUE TRUE oc2 oc2 1) ;displace (gimp-selection-layer-alpha oc3) (gimp-selection-invert img) ;invert selection (gimp-edit-clear oc1) ;delete selection (gimp-selection-none img) (gimp-image-remove-layer img oc3) ;add 2.8 (gimp-image-remove-layer img oc2) ;delete layer ;;2.4追加(let) ) ) ;; Create aqua style button (common function) (define (script-fu-aqua-button2 width height coulop coulfg coulbg coulgrad coultex coullt disp? trans-bg?) ; don't use (let* ( (trans-bg? TRUE) ; here... (xscale (/ width 512)) (yscale (/ height 286)) (radius2 (max (/ (min (* yscale 176) (* xscale 432)) 2) 2)) (WHITE '(255 255 255)) (BLACK '( 0 0 0)) (image (car (gimp-image-new width height RGB))) ;; Set new selections for the fore and background-color. (old-fg (car (gimp-palette-get-foreground))) (old-bg (car (gimp-palette-get-background))) (old-grad (car (gimp-gradients-get-gradient))) (old-pat (car (gimp-patterns-get-pattern))) (fond (car (gimp-layer-new image width height RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL-LEGACY))) (base (car (gimp-layer-new image width height RGBA-IMAGE "Base" 90 LAYER-MODE-NORMAL-LEGACY))) (ombre (car (gimp-layer-new image width height RGBA-IMAGE "Shadow" 70 LAYER-MODE-NORMAL-LEGACY))) (reflh (car (gimp-layer-new image width height RGBA-IMAGE "Top Reflect" 80 LAYER-MODE-SCREEN-LEGACY))) (lum (car (gimp-layer-new image width height RGBA-IMAGE "light" coullt LAYER-MODE-OVERLAY-LEGACY))) ;;2.4追加 (maskbase) (maskombre) ) ; end variable definition (define (selzone img) (if (> width height) (let* ((maxscale (max xscale yscale)) (minscale (min xscale yscale)) (diffscale (- maxscale minscale))) (gimp-ellipse-select img (* 40 xscale) (* 40 yscale) (* 2 radius2) (* 2 radius2) CHANNEL-OP-REPLACE TRUE 0 0) (gimp-ellipse-select img (- (* 472 xscale) (* 2 radius2)) (* 40 yscale) (* 2 radius2) (* 2 radius2) CHANNEL-OP-ADD TRUE 0 0) (gimp-rect-select img (+ (* 40 xscale) radius2) (* 40 yscale) (- (* 432 xscale) (* 2 radius2)) (* 2 radius2) CHANNEL-OP-ADD 0 0)) (gimp-ellipse-select img (* 40 xscale) (* 40 yscale) (* 432 xscale) (* 176 yscale) CHANNEL-OP-REPLACE TRUE 0 0) )) (gimp-image-undo-disable image) (gimp-palette-set-foreground coulfg) (gimp-palette-set-background WHITE) (gimp-image-add-layer image reflh 0) (gimp-image-add-layer image lum 1) (gimp-image-add-layer image base 2) (gimp-image-add-layer image ombre 3) (gimp-image-add-layer image fond 4) (gimp-edit-clear reflh) (gimp-edit-clear lum) (gimp-edit-clear base) (gimp-edit-clear ombre) (gimp-edit-clear fond) ;; fill the background (gimp-palette-set-foreground coulbg) (if (eqv? trans-bg? TRUE) (gimp-drawable-fill fond FILL-TRANSPARENT) (gimp-edit-fill fond FILL-FOREGROUND)) ;; make base of the button (set! maskbase (car (gimp-layer-create-mask base ADD-MASK-ALPHA))) (gimp-layer-add-mask base maskbase) ;;;;move1 (gimp-edit-clear maskbase) (gimp-palette-set-foreground WHITE) (gimp-edit-fill maskbase FILL-FOREGROUND) (selzone image) (gimp-palette-set-foreground coulfg) (cond((= coulop 0) (gimp-edit-fill base FILL-FOREGROUND)) ((= coulop 1) (gimp-gradients-set-gradient coulgrad) ; (cond((= fhoukou 1) ; (set! fa 0) ; (set! fb hheight)) ; ((= fhoukou 2) ; (set! fb hheight))) (gimp-blend base BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY 0 100 20 REPEAT-NONE FALSE 0 0 0 0 0 0 width height)) ((= coulop 2) (gimp-patterns-set-pattern coultex) (gimp-edit-bucket-fill base BUCKET-FILL-PATTERN LAYER-MODE-NORMAL-LEGACY 100 255 FALSE 0 0) )) ;(gimp-selection-shrink image (* 58 scale)) (gimp-selection-shrink image (/ radius2 1.52)) (gimp-palette-set-foreground '(160 160 160)) (gimp-edit-fill maskbase FILL-FOREGROUND) (gimp-selection-none image) ;(plug-in-gauss-rle2 TRUE image maskbase (* 74 xscale) (* 74 yscale)) (plug-in-gauss-rle2 TRUE image maskbase (/ radius2 1.19) (/ radius2 1.19)) ;;; (gimp-layer-add-mask base maskbase) ;;;move1 (gimp-drawable-set-visible maskbase FALSE) (if (and (= disp? TRUE) (> coulop 0)) (begin ;; (set! oc1 (car (gimp-layer-copy base 0))) ;create layer copy ;; (gimp-image-add-layer image oc1 2) ;add layer (script-fu-disp image base coulop coulgrad coultex width height) )) ;; Make shadow (selzone image) (gimp-selection-translate image 0 (* 50 yscale)) (gimp-palette-set-foreground coulfg) (gimp-edit-fill ombre FILL-FOREGROUND) (cond ((= coulop 1) (gimp-gradients-set-gradient coulgrad) ; (cond((= fhoukou 1) ; (set! fa 0) ; (set! fb hheight)) ; ((= fhoukou 2) ; (set! fb hheight))) (gimp-blend ombre BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY 0 100 20 REPEAT-NONE FALSE 0 0 0 0 (/ width 5) (/ height 5) (/ width 0.9) (/ height 0.9))) ;changed ((= coulop 2) (gimp-selection-layer-alpha ombre) (gimp-patterns-set-pattern coultex) (gimp-edit-bucket-fill ombre BUCKET-FILL-PATTERN LAYER-MODE-NORMAL-LEGACY 100 255 FALSE 0 0) (gimp-selection-none image) )) (gimp-selection-none image) ;(plug-in-gauss-rle2 TRUE image ombre (* 44 xscale) (* 44 yscale)) (plug-in-gauss-rle2 TRUE image ombre (/ radius2 (+ 2.00 0.5)) (/ radius2 (+ 2.00 0.5))) (gimp-palette-set-foreground coulfg) (set! maskombre (car (gimp-layer-create-mask ombre ADD-MASK-ALPHA))) (gimp-layer-add-mask ombre maskombre) ;;;;moved2 (gimp-edit-clear maskombre) (gimp-palette-set-foreground BLACK) (gimp-edit-fill maskombre FILL-FOREGROUND) (selzone image) (gimp-selection-invert image) (gimp-edit-clear maskombre) ;;; (gimp-layer-add-mask ombre maskombre) ;;;move2 (gimp-drawable-set-visible maskombre FALSE) ;; make light (gimp-selection-none image) (gimp-palette-set-foreground BLACK) (gimp-edit-fill lum FILL-FOREGROUND) (selzone image) ;(gimp-selection-shrink image (* 30 scale)) (gimp-selection-shrink image (/ radius2 2.92)) (gimp-selection-translate image 0 (* 45 yscale)) (gimp-palette-set-foreground WHITE) (gimp-edit-fill lum FILL-FOREGROUND) (gimp-selection-none image) ;(plug-in-gauss-rle2 TRUE image lum (* 50 xscale) (* 50 yscale)) (plug-in-gauss-rle2 TRUE image lum (/ radius2 (+ 1.76 0.5)) (/ radius2 (+ 1.76 0.5))) ;; Top reflect (gimp-selection-none image) (if (> width height) (begin (gimp-ellipse-select image (+ (* 40 xscale) (* 0.6 radius2)) (* 40 yscale) (* 0.6 radius2) (* 0.6 radius2) CHANNEL-OP-REPLACE TRUE 0 0) (gimp-ellipse-select image (- (* 472 xscale) (* 1.2 radius2)) (* 40 yscale) (* 0.6 radius2) (* 0.6 radius2) CHANNEL-OP-ADD TRUE 0 0) (gimp-rect-select image (+ (* 40 xscale) (* radius2 0.9)) (* 40 yscale) (- (* 432 xscale) (* radius2 1.8)) (* 0.6 radius2) CHANNEL-OP-ADD 0 0)) (begin (gimp-ellipse-select image (+ (* 40 xscale) (* 0.2 radius2)) (* 40 yscale) (- (* 432 xscale) (* 0.4 radius2)) (* 176 yscale 0.3) CHANNEL-OP-REPLACE TRUE 0 0))) ;(gimp-display-new image) ;(gimp-message 1) (gimp-palette-set-foreground BLACK) (gimp-drawable-fill reflh FILL-TRANSPARENT) (gimp-blend reflh BLEND-FG-BG-HSV LAYER-MODE-NORMAL-LEGACY GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE 0 0 0 0 (* 256 xscale) (* (- 97 10) yscale) (* 256 xscale) (* (- 50 10) yscale)) (gimp-perspective reflh FALSE (+ (* (- 122 70) xscale) (* 0.6 radius2)) (* 50 yscale 1.0) (- (* (+ 390 70) xscale) (* 0.6 radius2)) (* 50 yscale 1.0) (+ (* (- 80 50) xscale) (* 0.6 radius2)) (* 90 yscale 1.0) (- (* (+ 432 50) xscale) (* 0.6 radius2)) (* 90 yscale 1.0)) ;(gimp-message 1) (gimp-floating-sel-anchor (car (gimp-image-get-floating-sel image))) (gimp-image-set-active-layer image fond) (gimp-palette-set-foreground old-fg) (gimp-palette-set-background old-bg) (gimp-gradients-set-gradient old-grad) (gimp-patterns-set-pattern old-pat) (gimp-image-undo-enable image) ;; Return '(image display background shadow base light top_reflect) (list image (car (gimp-display-new image)) fond ombre base lum reflh) ) ; end of let* ) ;; Ceate an aqua button (aqua button without text) (define (script-fu-aquapro2-hrule width height foption fg-color bg-color grad tex lt disp? trans-bg? pill?) ;;2.4追加 (let ( (old-bg 0) ;2.6 (listed 0) ;2.6 (alayer-copy 0) ;2.6 (acopy-mask 0) ;2.6 ) (set! old-bg (car (gimp-palette-get-background))) (set! listed (if (eqv? pill? TRUE) (script-fu-aqua-button2 (/ (* width 512) 432) (/ (* height 286) 176) foption fg-color bg-color grad tex lt disp? trans-bg?) (script-fu-aqua-button2 width height foption fg-color bg-color grad tex lt disp? trans-bg?))) (if (eqv? trans-bg? FALSE) (let* ((xscale (/ width 432)) (yscale (/ height 176)) (radius2 (max (/ (min (* yscale 176) (* xscale 432)) 2) 2)) (image (car listed)) (old-bg (car (gimp-palette-get-background))) (active-layer (car (gimp-image-get-active-layer image)))) (begin (gimp-image-undo-group-start image) (gimp-palette-set-background bg-color) (gimp-drawable-fill active-layer FILL-BACKGROUND) (gimp-image-set-active-layer image active-layer) (set! alayer-copy (car (gimp-layer-copy active-layer TRUE))) (gimp-image-add-layer image alayer-copy -1) (set! acopy-mask (car (gimp-layer-create-mask alayer-copy ADD-MASK-WHITE))) (gimp-layer-add-mask alayer-copy acopy-mask) (gimp-edit-copy (car (gimp-layer-get-mask (cadr (cddr listed))))) (gimp-floating-sel-anchor (car (gimp-edit-paste acopy-mask FALSE))) (gimp-invert acopy-mask) (gimp-selection-layer-alpha (cadr (cddr listed))) (gimp-selection-shrink image (/ radius2 9 0.4)) (gimp-selection-feather image (/ radius2 6 0.4)) (gimp-edit-fill acopy-mask FILL-WHITE) (gimp-selection-none image) (gimp-drawable-set-visible active-layer FALSE) (gimp-image-merge-visible-layers image EXPAND-AS-NECESSARY) (gimp-drawable-set-visible active-layer TRUE) (gimp-image-undo-group-end image)))) (gimp-palette-set-background old-bg) (gimp-displays-flush) ;;2.4追加(let) ) ) (script-fu-register "script-fu-aquapro2-hrule" "/File/Create/AquaPro2/Hrule..." "Creates a aqua-style button\n This script creates a multi-layered aqua button. Thx to Wolfgang Mauerer." "Denis Bodor" "lefinnois@lefinnois.net" "0.0" "" SF-ADJUSTMENT "Width" '(512 10 9999 1 10 0 1) SF-ADJUSTMENT "Height" '(286 10 9999 1 10 0 1) SF-OPTION "Mode" '(_"COLOR" _"GRADIENT" _"TEXTURE") SF-COLOR "Foreground Color" '( 71 124 183) SF-COLOR "Background Color" '( 0 0 0) SF-GRADIENT "Gradient" "Pastel Rainbow" SF-PATTERN "Texture" "Marble #1" SF-ADJUSTMENT "lighting" '(100 0 100 1 2 0 0) SF-TOGGLE "Displace" TRUE SF-TOGGLE "Transparent BG" FALSE SF-TOGGLE "Pill's Width and Height?" FALSE ) ;; Ceate a round image (define (script-fu-aquapro2-round baseradius foption fg-color bg-color grad tex lt disp? trans-bg?) ;;2.4追加 (let ( (listed 0) ;2.6 (alayer-copy 0) ;2.6 (acopy-mask 0) ;2.6 ) (set! listed (script-fu-aqua-button2 (/ (* baseradius (* 512 2)) 432) (/ (* baseradius (* 286 2)) 176) foption fg-color bg-color grad tex lt disp? trans-bg?)) (if (eqv? trans-bg? FALSE) (let* ((xscale (/ (* baseradius 2) 432)) (yscale (/ (* baseradius 2) 176)) (radius2 (max (/ (min (* yscale 176) (* xscale 432)) 2) 2)) (image (car listed)) (old-bg (car (gimp-palette-get-background))) (active-layer (car (gimp-image-get-active-layer image)))) (begin (gimp-image-undo-group-start image) (gimp-palette-set-background bg-color) (gimp-drawable-fill active-layer FILL-BACKGROUND) (gimp-image-set-active-layer image active-layer) (set! alayer-copy (car (gimp-layer-copy active-layer TRUE))) (gimp-image-add-layer image alayer-copy -1) (set! acopy-mask (car (gimp-layer-create-mask alayer-copy ADD-MASK-WHITE))) (gimp-layer-add-mask alayer-copy acopy-mask) (gimp-edit-copy (car (gimp-layer-get-mask (cadr (cddr listed))))) (gimp-floating-sel-anchor (car (gimp-edit-paste acopy-mask FALSE))) (gimp-invert acopy-mask) (gimp-selection-layer-alpha (cadr (cddr listed))) (gimp-selection-shrink image (/ radius2 9 0.4)) (gimp-selection-feather image (/ radius2 6 0.4)) (gimp-edit-fill acopy-mask FILL-WHITE) (gimp-selection-none image) (gimp-drawable-set-visible active-layer FALSE) (gimp-image-merge-visible-layers image EXPAND-AS-NECESSARY) (gimp-drawable-set-visible active-layer TRUE) (gimp-image-undo-group-end image)))) (gimp-displays-flush) ;;2.4追加(let) ) ) (script-fu-register "script-fu-aquapro2-round" "/File/Create/AquaPro2/Round..." "Creates a aqua-style round button" "Iccii " "Iccii" "2001, Nov" "" SF-ADJUSTMENT "Base Radius (pixels)" '(60 2 1024 1 1 0 1) SF-OPTION "Mode" '(_"COLOR" _"GRADIENT" _"TEXTURE") SF-COLOR "Foreground Color" '( 71 183 124) SF-COLOR "Background Color" '(255 255 255) SF-GRADIENT "Gradient" "Pastel Rainbow" SF-PATTERN "Texture" "Marble #1" SF-ADJUSTMENT "lighting" '(100 0 100 1 2 0 0) SF-TOGGLE "Displace" TRUE SF-TOGGLE "Transparent BG" FALSE ) ;; Create an aqua button with text (define (script-fu-aquapro2-button text size fontname text-color foption fg-color bg-color grad tex lt disp? trans-bg? add-shadow?) (let* ( (old-fg (car (gimp-palette-get-foreground))) (old-bg (car (gimp-palette-get-background))) (img (car (gimp-image-new 256 256 RGB))) (x-padding (/ size 3.5)) (y-padding (/ size 3.5)) ;;2.4追加 (listed) (image) (alayer-copy) (acopy-mask) ) ; end variable definition (gimp-image-undo-disable img) (gimp-palette-set-foreground text-color) (let* ( (text-layer (car (gimp-text-fontname img -1 0 0 text 0 TRUE size PIXELS fontname))) (layer-width (car (gimp-drawable-width text-layer))) (layer-height (car (gimp-drawable-height text-layer))) ) (gimp-image-resize img layer-width layer-height 0 0) (gimp-drawable-set-name text-layer "text") (set! listed (script-fu-aqua-button2 (* (+ (* 2 x-padding) layer-width) (/ 512 432)) (* (+ (* 2 y-padding) layer-height) (/ 286 176)) foption fg-color bg-color grad tex lt disp? trans-bg?)) (set! image (car listed)) (gimp-edit-copy text-layer) ) (gimp-image-undo-enable img) (gimp-image-delete img) (gimp-image-undo-group-start image) (let* ( (active-layer (car (gimp-image-get-active-layer image))) (image-width (car (gimp-image-width image))) (image-height (car (gimp-image-height image))) (new-text-layer (car (gimp-layer-new image image-width image-height RGBA-IMAGE text 100 LAYER-MODE-NORMAL-LEGACY))) ) (gimp-drawable-fill new-text-layer FILL-TRANSPARENT) (gimp-image-add-layer image new-text-layer -1) (gimp-image-raise-layer-to-top image new-text-layer) (gimp-image-lower-layer image new-text-layer) (gimp-image-lower-layer image new-text-layer) (gimp-rect-select image (* image-width (/ 40 512)) (* image-height (/ 40 286)) (* image-width (/ 432 512)) (* image-height (/ 176 286)) CHANNEL-OP-ADD 0 0) (gimp-floating-sel-anchor (car (gimp-edit-paste new-text-layer TRUE))) (gimp-selection-none image) (if (eqv? add-shadow? TRUE) (let* ( (text-copy (car (gimp-layer-copy new-text-layer TRUE))) ) (gimp-image-add-layer image text-copy -1) (gimp-image-lower-layer image text-copy) (gimp-image-lower-layer image text-copy) (gimp-drawable-offset text-copy TRUE OFFSET-TRANSPARENT (/ size 32) (/ size 8)) (plug-in-gauss-iir2 1 image text-copy (/ size 9) (/ size 9)) )) (gimp-image-set-active-layer image new-text-layer) (gimp-image-undo-group-end image) (if (eqv? trans-bg? FALSE) (begin (gimp-image-undo-group-start image) (gimp-palette-set-background bg-color) (gimp-drawable-fill active-layer FILL-BACKGROUND) (gimp-image-set-active-layer image active-layer) (set! alayer-copy (car (gimp-layer-copy active-layer TRUE))) (gimp-image-add-layer image alayer-copy -1) (set! acopy-mask (car (gimp-layer-create-mask alayer-copy ADD-MASK-WHITE))) (gimp-layer-add-mask alayer-copy acopy-mask) (gimp-edit-copy (car (gimp-layer-get-mask (cadr (cddr listed))))) (gimp-floating-sel-anchor (car (gimp-edit-paste acopy-mask FALSE))) (gimp-invert acopy-mask) (gimp-selection-layer-alpha (cadr (cddr listed))) (gimp-selection-shrink image (/ size 9)) (gimp-selection-feather image (/ size 6)) (gimp-edit-fill acopy-mask FILL-WHITE) (gimp-selection-none image) (gimp-drawable-set-visible active-layer FALSE) (gimp-image-merge-visible-layers image EXPAND-AS-NECESSARY) (gimp-drawable-set-visible active-layer TRUE) (gimp-image-undo-group-end image))) ) (gimp-palette-set-foreground old-fg) (gimp-palette-set-background old-bg) (gimp-displays-flush) listed ; Return '(image display) )) (script-fu-register "script-fu-aquapro2-button" "/File/Create/AquaPro2/Button..." "Create the logo in aqua pill image" "Iccii " "Iccii" "2001, Oct" "" SF-STRING _"Text" "Aqua" SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 500 1 1 0 1) SF-FONT _"Font" ; Checking winsnap plug-in (Windows or not?) (if (symbol-bound? 'extension-winsnap (the-environment)) ; For Windows user "Times New Roman" ; Default setting "classicheavylight" ) SF-COLOR _"Text Color" '( 0 0 0) SF-OPTION "Mode" '(_"COLOR" _"GRADIENT" _"TEXTURE") SF-COLOR _"Base Color" '(183 71 124) SF-COLOR _"Background Color" '(255 255 255) SF-GRADIENT "Gradient" "Pastel Rainbow" SF-PATTERN "Texture" "Marble #1" SF-ADJUSTMENT "lighting" '(100 0 100 1 2 0 0) SF-TOGGLE "Displace" TRUE SF-TOGGLE "Transparent BG" FALSE SF-TOGGLE _"Add Drop-Shadow" TRUE ) ; (strbreakup "This is a string" " ") -> ("This" "is" "a" "string") ; を使って文字列を分けると簡単になるので改良する ;; Create logo in aqua ball (define (script-fu-aquapro2-logo-in-pill text size fontname text-color foption fg-color bg-color grad tex lt disp? trans-bg? add-shadow? flatten?) ; remove white-space from left and right side in text (set! text (string-trim text)) ; evaluates that an charactor str is white-space or not? (define (white-space-string? str) (or (equal? " " str) (equal? " " str))) ; return TRUE if there are any white-space in strings ; (eqv? (strcspn "This is a string" " \t") (string--length "This is a string")) ; を使うと空白スペースを判定できるかも? (define (string-have-white-space? strings) (let* ((text-length (string-length strings)) (have-white-space? FALSE)) (let ((n 0)) (while (< n text-length) (if (white-space-string? (substring strings n (+ n 1))) (set! have-white-space? TRUE)) (set! n (+ n 1)))) have-white-space?)) ; Return (let*) ; start から text を数えて一番始めに出現する空白スペースの位置を返す (define (count-next-space start) (let* ((n start) (hantei 1) (text-length (string-length text))) (if (eqv? (string-have-white-space? (substring text start text-length)) TRUE) (begin (while (not (white-space-string? (substring text n (+ n 1)))) (set! n (+ n 1))) (- n start)) (- text-length start)))) (let* ( (old-bg (car (gimp-palette-get-background))) (img (car (gimp-image-new 1 1 RGB))) (text-length (string-length text)) (count 0) ;;2.4追加 (height-mean2) (height-mean1) (image-layer) ) ; end variable definition (gimp-palette-set-background bg-color) ; 文字列の長さに達するまでカウントが増える (while (< count text-length) (let* ( ; 文字列 text 中の count 番目の一文字のアクア画像を作る (string-step (if (eqv? (string-have-white-space? text) TRUE) (count-next-space count) 1)) (listed (script-fu-aquapro2-button (substring text count (+ count string-step)) size fontname text-color foption fg-color bg-color grad tex lt disp? trans-bg? add-shadow?)) (image (car listed)) (image-width (car (gimp-image-width image))) (image-height (car (gimp-image-height image))) (img-width (car (gimp-image-width img))) (img-height (car (gimp-image-height img))) (img-layer (car (gimp-layer-new img image-width (max img-height image-height) RGBA-IMAGE (substring text count (+ count string-step)) 100 LAYER-MODE-NORMAL-LEGACY))) ) ; img is existing image, image is new added image (if (< img-height image-height) (begin (set! height-mean2 0) (set! height-mean1 (/ (- image-height img-height) 2)) (set! img-height image-height)) (begin (set! height-mean1 0) (set! height-mean2 (/ (- img-height image-height) 2)))) (gimp-image-resize img (+ img-width image-width) img-height 0 height-mean1) (gimp-image-resize image image-width img-height 0 height-mean2) (gimp-drawable-fill img-layer FILL-TRANSPARENT) ; (if (= count 0) ; (gimp-image-crop img (- image-width 1) img-height 0 0)) (set! image-layer (car (gimp-image-merge-visible-layers image EXPAND-AS-NECESSARY))) (gimp-image-add-layer img img-layer -1) (gimp-layer-set-offsets img-layer img-width 0) (gimp-edit-copy image-layer) (gimp-floating-sel-anchor (car (gimp-edit-paste img-layer 0))) ;delete image (gimp-display-delete (cadr listed)) ; count++ して、次の文字が空白であれば空白で無くなるまで count する (set! count (+ count string-step)) (if (and (< count text-length) (white-space-string? (substring text count (+ count 1)))) (set! count (+ count 1))) ) ; end of let* ) ; end of while (gimp-image-undo-group-start img) (let* ((img-width (car (gimp-image-width img))) (img-height (car (gimp-image-height img))) (bg-layer (car (gimp-layer-new img img-width img-height RGBA-IMAGE text 100 LAYER-MODE-NORMAL-LEGACY)))) (gimp-palette-set-background bg-color) (if (eqv? trans-bg? TRUE) (gimp-drawable-fill bg-layer FILL-TRANSPARENT) (gimp-drawable-fill bg-layer FILL-BACKGROUND)) (gimp-image-add-layer img bg-layer -1) (gimp-image-lower-layer-to-bottom img bg-layer) ) (gimp-image-undo-group-end img) (if (eqv? flatten? TRUE) (if (eqv? trans-bg? TRUE) (gimp-image-merge-visible-layers img EXPAND-AS-NECESSARY) (gimp-image-flatten img))) (gimp-palette-set-background old-bg) (gimp-displays-flush) (list img (car (gimp-display-new img))) ; Return '(image display) ) ; end of let* ) (script-fu-register "script-fu-aquapro2-logo-in-pill" "/File/Create/AquaPro2/Logo in Pill..." "Create the image which each logos is in each aqua pills" "Iccii " "Iccii" "2001, Nov" "" SF-STRING _"Text" "012 - 345" SF-ADJUSTMENT _"Font Size (pixels)" '(75 2 500 1 1 0 1) SF-FONT _"Font" ; Checking winsnap plug-in (Windows or not?) (if (symbol-bound? 'extension-winsnap (the-environment)) ; For Windows user "Times New Roman" ; Default setting "classicheavylight" ) SF-COLOR _"Text Color" '( 0 0 0) SF-OPTION "Mode" '(_"COLOR" _"GRADIENT" _"TEXTURE") SF-COLOR _"Base Color" '(124 183 71) SF-COLOR _"Background Color" '(255 255 255) SF-GRADIENT "Gradient" "Pastel Rainbow" SF-PATTERN "Texture" "Marble #1" SF-ADJUSTMENT "lighting" '(100 0 100 1 2 0 0) SF-TOGGLE "Displace" TRUE SF-TOGGLE _"Transparent BG" FALSE SF-TOGGLE _"Add Drop-Shadow" TRUE SF-TOGGLE _"Flatten Image" TRUE )