2006-12-09 13:33:38 -08:00
|
|
|
; GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
2004-01-07 05:25:00 -08:00
|
|
|
;
|
1997-11-24 14:05:25 -08:00
|
|
|
; Beveled pattern button for web pages
|
|
|
|
|
; Copyright (C) 1997 Federico Mena Quintero
|
|
|
|
|
; federico@nuclecu.unam.mx
|
2004-01-07 05:25:00 -08:00
|
|
|
;
|
2009-01-17 14:28:01 -08:00
|
|
|
; This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
; it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
; the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08:00
|
|
|
; (at your option) any later version.
|
2004-01-07 05:25:00 -08:00
|
|
|
;
|
1997-11-24 14:05:25 -08:00
|
|
|
; 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.
|
2004-01-07 05:25:00 -08:00
|
|
|
;
|
1997-11-24 14:05:25 -08:00
|
|
|
; You should have received a copy of the GNU General Public License
|
2009-01-17 14:28:01 -08:00
|
|
|
; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-03-07 07:11:11 -08:00
|
|
|
; ************************************************************************
|
|
|
|
|
; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
|
|
|
|
|
; For use with GIMP 1.1.
|
|
|
|
|
; All calls to gimp-text-* have been converted to use the *-fontname form.
|
|
|
|
|
; The corresponding parameters have been replaced by an SF-FONT parameter.
|
|
|
|
|
; ************************************************************************
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
(define (text-width extents)
|
|
|
|
|
(car extents))
|
|
|
|
|
|
|
|
|
|
(define (text-height extents)
|
|
|
|
|
(cadr extents))
|
|
|
|
|
|
|
|
|
|
(define (text-ascent extents)
|
|
|
|
|
(caddr extents))
|
|
|
|
|
|
|
|
|
|
(define (text-descent extents)
|
|
|
|
|
(cadr (cddr extents)))
|
|
|
|
|
|
|
|
|
|
(define (script-fu-beveled-pattern-button
|
2006-10-15 18:08:54 -07:00
|
|
|
text text-size font text-color pattern pressed)
|
|
|
|
|
(let* (
|
|
|
|
|
(text-extents (gimp-text-get-extents-fontname
|
|
|
|
|
text text-size PIXELS font))
|
|
|
|
|
(ascent (text-ascent text-extents))
|
|
|
|
|
(descent (text-descent text-extents))
|
|
|
|
|
|
|
|
|
|
(xpadding 8)
|
|
|
|
|
(ypadding 6)
|
|
|
|
|
|
|
|
|
|
(width (+ (* 2 xpadding)
|
|
|
|
|
(text-width text-extents)))
|
|
|
|
|
(height (+ (* 2 ypadding)
|
|
|
|
|
(+ ascent descent)))
|
|
|
|
|
|
|
|
|
|
(img (car (gimp-image-new width height RGB)))
|
2010-10-09 16:52:15 -07:00
|
|
|
(background (car (gimp-layer-new img width height RGBA-IMAGE _"Background" 100 NORMAL-MODE)))
|
|
|
|
|
(bumpmap (car (gimp-layer-new img width height RGBA-IMAGE _"Bumpmap" 100 NORMAL-MODE)))
|
2006-10-15 18:08:54 -07:00
|
|
|
(textl (car
|
|
|
|
|
(gimp-text-fontname
|
|
|
|
|
img -1 0 0 text 0 TRUE text-size PIXELS font)))
|
|
|
|
|
)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2004-09-22 10:27:20 -07:00
|
|
|
(gimp-context-push)
|
|
|
|
|
|
1999-10-16 17:07:55 -07:00
|
|
|
(gimp-image-undo-disable img)
|
2011-03-01 23:55:43 -08:00
|
|
|
(gimp-image-insert-layer img background 0 1)
|
|
|
|
|
(gimp-image-insert-layer img bumpmap 0 1)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
; Create pattern layer
|
|
|
|
|
|
2004-09-22 11:43:09 -07:00
|
|
|
(gimp-context-set-background '(0 0 0))
|
2003-10-16 05:47:33 -07:00
|
|
|
(gimp-edit-fill background BACKGROUND-FILL)
|
2004-09-23 04:44:32 -07:00
|
|
|
(gimp-context-set-pattern pattern)
|
2004-01-07 05:25:00 -08:00
|
|
|
(gimp-edit-bucket-fill background PATTERN-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
; Create bumpmap layer
|
|
|
|
|
|
2003-10-16 05:47:33 -07:00
|
|
|
(gimp-edit-fill bumpmap BACKGROUND-FILL)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2004-09-22 11:43:09 -07:00
|
|
|
(gimp-context-set-background '(127 127 127))
|
2004-02-03 03:46:27 -08:00
|
|
|
(gimp-rect-select img 1 1 (- width 2) (- height 2) CHANNEL-OP-REPLACE FALSE 0)
|
2003-10-16 05:47:33 -07:00
|
|
|
(gimp-edit-fill bumpmap BACKGROUND-FILL)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2004-09-22 11:43:09 -07:00
|
|
|
(gimp-context-set-background '(255 255 255))
|
2004-02-03 03:46:27 -08:00
|
|
|
(gimp-rect-select img 2 2 (- width 4) (- height 4) CHANNEL-OP-REPLACE FALSE 0)
|
2003-10-16 05:47:33 -07:00
|
|
|
(gimp-edit-fill bumpmap BACKGROUND-FILL)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
(gimp-selection-none img)
|
|
|
|
|
|
|
|
|
|
; Bumpmap
|
|
|
|
|
|
2007-10-01 12:44:23 -07:00
|
|
|
(plug-in-bump-map RUN-NONINTERACTIVE img background bumpmap 135 45 2 0 0 0 0 TRUE pressed 0)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
; Color and position text
|
|
|
|
|
|
2004-09-22 11:43:09 -07:00
|
|
|
(gimp-context-set-background text-color)
|
2005-07-10 14:17:22 -07:00
|
|
|
(gimp-layer-set-lock-alpha textl TRUE)
|
2003-10-16 05:47:33 -07:00
|
|
|
(gimp-edit-fill textl BACKGROUND-FILL)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
(gimp-layer-set-offsets textl
|
2006-10-15 18:08:54 -07:00
|
|
|
xpadding
|
|
|
|
|
(+ ypadding descent))
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
; Clean up
|
|
|
|
|
|
|
|
|
|
(gimp-image-set-active-layer img background)
|
|
|
|
|
(gimp-image-remove-layer img bumpmap)
|
|
|
|
|
(gimp-image-flatten img)
|
|
|
|
|
|
1999-10-16 17:07:55 -07:00
|
|
|
(gimp-image-undo-enable img)
|
2004-09-22 10:27:20 -07:00
|
|
|
(gimp-display-new img)
|
|
|
|
|
|
2006-10-15 18:08:54 -07:00
|
|
|
(gimp-context-pop)
|
|
|
|
|
)
|
|
|
|
|
)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
(script-fu-register "script-fu-beveled-pattern-button"
|
2006-10-15 18:08:54 -07:00
|
|
|
_"B_utton..."
|
|
|
|
|
_"Create a beveled pattern button for webpages"
|
|
|
|
|
"Federico Mena Quintero"
|
|
|
|
|
"Federico Mena Quintero"
|
|
|
|
|
"July 1997"
|
|
|
|
|
""
|
2006-10-20 10:55:14 -07:00
|
|
|
SF-STRING _"Text" "Hello world!"
|
2006-10-15 18:08:54 -07:00
|
|
|
SF-ADJUSTMENT _"Font size (pixels)" '(32 2 1000 1 10 0 1)
|
2006-10-20 10:55:14 -07:00
|
|
|
SF-FONT _"Font" "Sans"
|
|
|
|
|
SF-COLOR _"Text color" "black"
|
|
|
|
|
SF-PATTERN _"Pattern" "Wood"
|
|
|
|
|
SF-TOGGLE _"Pressed" FALSE
|
2006-10-15 18:08:54 -07:00
|
|
|
)
|
2004-11-18 14:44:28 -08:00
|
|
|
|
|
|
|
|
(script-fu-menu-register "script-fu-beveled-pattern-button"
|
2008-09-19 05:01:12 -07:00
|
|
|
"<Image>/File/Create/Web Page Themes/Beveled Pattern")
|