~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/beveled-button.scm

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
; The GIMP -- an image manipulation program
 
1
; GIMP - The GNU Image Manipulation Program
2
2
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
 
 
3
;
4
4
; Button00 --- create a simple beveled Web button
5
5
; Copyright (C) 1997 Federico Mena Quintero
6
6
; federico@nuclecu.unam.mx
7
 
 
7
;
8
8
; This program is free software; you can redistribute it and/or modify
9
9
; it under the terms of the GNU General Public License as published by
10
10
; the Free Software Foundation; either version 2 of the License, or
11
11
; (at your option) any later version.
12
 
 
12
;
13
13
; This program is distributed in the hope that it will be useful,
14
14
; but WITHOUT ANY WARRANTY; without even the implied warranty of
15
15
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
16
; GNU General Public License for more details.
17
 
 
17
;
18
18
; You should have received a copy of the GNU General Public License
19
19
; along with this program; if not, write to the Free Software
20
20
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39
39
  (cadr (cddr extents)))
40
40
 
41
41
(define (blend-bumpmap img
42
 
                       drawable
43
 
                       x1
44
 
                       y1
45
 
                       x2
46
 
                       y2)
 
42
                       drawable
 
43
                       x1
 
44
                       y1
 
45
                       x2
 
46
                       y2)
47
47
  (gimp-edit-blend drawable FG-BG-RGB-MODE DARKEN-ONLY-MODE
48
 
                   GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
49
 
                   FALSE 0 0 TRUE
50
 
                   x1 y1 x2 y2))
 
48
                   GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
 
49
                   FALSE 0 0 TRUE
 
50
                   x1 y1 x2 y2))
51
51
 
52
52
(define (script-fu-button00 text
53
 
                            size
54
 
                            font
55
 
                            ul-color
56
 
                            lr-color
57
 
                            text-color
58
 
                            padding
59
 
                            bevel-width
60
 
                            pressed)
61
 
  (let* ((text-extents (gimp-text-get-extents-fontname text
62
 
                                              size
63
 
                                              PIXELS
64
 
                                              font))
65
 
         (ascent (text-ascent text-extents))
66
 
         (descent (text-descent text-extents))
67
 
 
68
 
         (img-width (+ (* 2 (+ padding bevel-width))
69
 
                       (text-width text-extents)))
70
 
         (img-height (+ (* 2 (+ padding bevel-width))
71
 
                        (+ ascent descent)))
72
 
 
73
 
         (img (car (gimp-image-new img-width img-height RGB)))
74
 
 
75
 
         (bumpmap (car (gimp-layer-new img
76
 
                                       img-width img-height RGBA-IMAGE
77
 
                                       "Bumpmap" 100 NORMAL-MODE)))
78
 
         (gradient (car (gimp-layer-new img
79
 
                                        img-width img-height RGBA-IMAGE
80
 
                                        "Gradient" 100 NORMAL-MODE))))
 
53
                            size
 
54
                            font
 
55
                            ul-color
 
56
                            lr-color
 
57
                            text-color
 
58
                            padding
 
59
                            bevel-width
 
60
                            pressed)
 
61
  (let* (
 
62
        (text-extents (gimp-text-get-extents-fontname text
 
63
                                                      size
 
64
                                                      PIXELS
 
65
                                                      font))
 
66
        (ascent (text-ascent text-extents))
 
67
        (descent (text-descent text-extents))
 
68
 
 
69
        (img-width (+ (* 2 (+ padding bevel-width))
 
70
                      (text-width text-extents)))
 
71
        (img-height (+ (* 2 (+ padding bevel-width))
 
72
                       (+ ascent descent)))
 
73
 
 
74
        (img (car (gimp-image-new img-width img-height RGB)))
 
75
 
 
76
        (bumpmap (car (gimp-layer-new img
 
77
                                      img-width img-height RGBA-IMAGE
 
78
                                      "Bumpmap" 100 NORMAL-MODE)))
 
79
        (gradient (car (gimp-layer-new img
 
80
                                       img-width img-height RGBA-IMAGE
 
81
                                       "Gradient" 100 NORMAL-MODE)))
 
82
        )
81
83
 
82
84
    (gimp-context-push)
83
85
 
84
86
    (gimp-image-undo-disable img)
85
87
 
86
88
    ; Create bumpmap layer
87
 
    
 
89
 
88
90
    (gimp-image-add-layer img bumpmap -1)
89
91
    (gimp-context-set-foreground '(0 0 0))
90
92
    (gimp-context-set-background '(255 255 255))
111
113
    (gimp-context-set-background lr-color)
112
114
 
113
115
    (gimp-edit-blend gradient FG-BG-RGB-MODE NORMAL-MODE
114
 
                     GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
115
 
                     FALSE 0 0 TRUE
116
 
                     0 0 (- img-width 1) (- img-height 1))
 
116
                     GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
 
117
                     FALSE 0 0 TRUE
 
118
                     0 0 (- img-width 1) (- img-height 1))
117
119
 
118
120
    (plug-in-bump-map 1 img gradient bumpmap
119
 
                      135 45 bevel-width 0 0 0 0 TRUE pressed 0)
 
121
                      135 45 bevel-width 0 0 0 0 TRUE pressed 0)
120
122
 
121
123
    ; Create text layer
122
124
 
123
125
    (gimp-context-set-foreground text-color)
124
126
    (let ((textl (car (gimp-text-fontname
125
 
                       img -1 0 0 text 0 TRUE size PIXELS font))))
 
127
                       img -1 0 0 text 0 TRUE size PIXELS font))))
126
128
      (gimp-layer-set-offsets textl
127
 
                              (+ bevel-width padding)
128
 
                              (+ bevel-width padding descent)))
 
129
                              (+ bevel-width padding)
 
130
                              (+ bevel-width padding descent)))
129
131
 
130
132
    ; Done
131
133
 
133
135
    (gimp-image-undo-enable img)
134
136
    (gimp-display-new img)
135
137
 
136
 
    (gimp-context-pop)))
 
138
    (gimp-context-pop)
 
139
  )
 
140
)
137
141
 
138
142
(script-fu-register "script-fu-button00"
139
 
                    _"Simple _Beveled Button..."
140
 
                    "Simple beveled button"
141
 
                    "Federico Mena Quintero"
142
 
                    "Federico Mena Quintero"
143
 
                    "June 1997"
144
 
                    ""
145
 
                    SF-STRING     _"Text"               "Hello world!"
146
 
                    SF-ADJUSTMENT _"Font size (pixels)" '(16 2 100 1 1 0 1)
147
 
                    SF-FONT       _"Font"               "Sans"
148
 
                    SF-COLOR      _"Upper-left color"   '(0 255 127)
149
 
                    SF-COLOR      _"Lower-right color"  '(0 127 255)
150
 
                    SF-COLOR      _"Text color"         '(0 0 0)
151
 
                    SF-ADJUSTMENT _"Padding"            '(2 1 100 1 10 0 1)
152
 
                    SF-ADJUSTMENT _"Bevel width"        '(4 1 100 1 10 0 1)
153
 
                    SF-TOGGLE     _"Pressed"            FALSE)
 
143
  _"Simple _Beveled Button..."
 
144
  _"Create a simple, beveled button graphic for webpages"
 
145
  "Federico Mena Quintero"
 
146
  "Federico Mena Quintero"
 
147
  "June 1997"
 
148
  ""
 
149
  SF-STRING     _"Text"               "Hello world!"
 
150
  SF-ADJUSTMENT _"Font size (pixels)" '(16 2 100 1 1 0 1)
 
151
  SF-FONT       _"Font"               "Sans"
 
152
  SF-COLOR      _"Upper-left color"   '(0 255 127)
 
153
  SF-COLOR      _"Lower-right color"  '(0 127 255)
 
154
  SF-COLOR      _"Text color"         "black"
 
155
  SF-ADJUSTMENT _"Padding"            '(2 1 100 1 10 0 1)
 
156
  SF-ADJUSTMENT _"Bevel width"        '(4 1 100 1 10 0 1)
 
157
  SF-TOGGLE     _"Pressed"            FALSE
 
158
)
154
159
 
155
160
(script-fu-menu-register "script-fu-button00"
156
 
                         _"<Toolbox>/Xtns/Script-Fu/Buttons")
 
161
                         "<Toolbox>/Xtns/Buttons")