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

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/pupi-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
; Round Button --- create a round beveled Web button.
5
5
; Copyright (C) 1998 Federico Mena Quintero & Arturo Espinosa Aldama
6
6
; federico@nuclecu.unam.mx arturo@nuclecu.unam.mx
10
10
; All calls to gimp-text-* have been converted to use the *-fontname form.
11
11
; The corresponding parameters have been replaced by an SF-FONT parameter.
12
12
; ************************************************************************
13
 
 
13
;
14
14
; This program is free software; you can redistribute it and/or modify
15
15
; it under the terms of the GNU General Public License as published by
16
16
; the Free Software Foundation; either version 2 of the License, or
17
17
; (at your option) any later version.
18
 
 
18
;
19
19
; This program is distributed in the hope that it will be useful,
20
20
; but WITHOUT ANY WARRANTY; without even the implied warranty of
21
21
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
22
; GNU General Public License for more details.
23
 
 
23
;
24
24
; You should have received a copy of the GNU General Public License
25
25
; along with this program; if not, write to the Free Software
26
26
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
27
 
28
 
(define (text-width extents)
29
 
  (car extents))
30
 
 
31
 
(define (text-height extents)
32
 
  (cadr extents))
33
 
 
34
 
(define (text-ascent extents)
35
 
  (caddr extents))
36
 
 
37
 
(define (text-descent extents)
38
 
  (cadr (cddr extents)))
39
 
 
40
 
(define (round-select img
41
 
                      x
42
 
                      y
43
 
                      width
44
 
                      height
45
 
                      ratio)
46
 
  (let* ((diameter (* ratio height)))
47
 
    (gimp-ellipse-select img x y diameter height CHANNEL-OP-ADD FALSE 0 0)
48
 
    (gimp-ellipse-select img (+ x (- width diameter)) y
49
 
                         diameter height CHANNEL-OP-ADD FALSE 0 0)
50
 
    (gimp-rect-select img (+ x (/ diameter 2)) y
51
 
                      (- width diameter) height CHANNEL-OP-ADD FALSE 0)))
52
 
 
53
28
(define (script-fu-round-button text
54
 
                                size
55
 
                                font
56
 
                                ul-color
57
 
                                lr-color
58
 
                                text-color
59
 
                                ul-color-high
60
 
                                lr-color-high
61
 
                                hlight-color
62
 
                                xpadding
63
 
                                ypadding
64
 
                                bevel
65
 
                                ratio
66
 
                                notpressed
67
 
                                notpressed-active
68
 
                                pressed)
 
29
                                size
 
30
                                font
 
31
                                ul-color
 
32
                                lr-color
 
33
                                text-color
 
34
                                ul-color-high
 
35
                                lr-color-high
 
36
                                hlight-color
 
37
                                xpadding
 
38
                                ypadding
 
39
                                bevel
 
40
                                ratio
 
41
                                notpressed
 
42
                                notpressed-active
 
43
                                pressed)
69
44
 
70
45
  (cond ((eqv? notpressed TRUE)
71
 
         (do-pupibutton text size font ul-color lr-color
72
 
                        text-color xpadding ypadding bevel ratio 0)))
 
46
         (do-pupibutton text size font ul-color lr-color
 
47
                        text-color xpadding ypadding bevel ratio 0)))
73
48
  (cond ((eqv? notpressed-active TRUE)
74
 
         (do-pupibutton text size font ul-color-high lr-color-high
75
 
                        hlight-color xpadding ypadding bevel ratio 0)))
 
49
         (do-pupibutton text size font ul-color-high lr-color-high
 
50
                        hlight-color xpadding ypadding bevel ratio 0)))
76
51
  (cond ((eqv? pressed TRUE)
77
 
         (do-pupibutton text size font ul-color-high lr-color-high
78
 
                        hlight-color xpadding ypadding bevel ratio 1))))
 
52
         (do-pupibutton text size font ul-color-high lr-color-high
 
53
                        hlight-color xpadding ypadding bevel ratio 1))))
79
54
 
80
55
(define (do-pupibutton text
81
 
                       size
82
 
                       font
83
 
                       ul-color
84
 
                       lr-color
85
 
                       text-color
86
 
                       xpadding
87
 
                       ypadding
88
 
                       bevel
89
 
                       ratio
90
 
                       pressed)
91
 
 
92
 
  (let* ((text-extents (gimp-text-get-extents-fontname text
93
 
                                                       size
94
 
                                                       PIXELS
95
 
                                                       font))
96
 
         (ascent (text-ascent text-extents))
97
 
         (descent (text-descent text-extents))
98
 
 
99
 
         (height (+ (* 2 (+ ypadding bevel))
100
 
                        (+ ascent descent)))
101
 
 
102
 
         (radius (/ (* ratio height) 4))
103
 
 
104
 
         (width (+ (* 2 (+ radius xpadding))
105
 
                   bevel
106
 
                   (text-width text-extents)))
107
 
 
108
 
         (img (car (gimp-image-new width height RGB)))
109
 
 
110
 
         (bumpmap (car (gimp-layer-new img width height
111
 
                                       RGBA-IMAGE "Bumpmap" 100 NORMAL-MODE)))
112
 
         (gradient (car (gimp-layer-new img width height
113
 
                                        RGBA-IMAGE "Button" 100 NORMAL-MODE))))
 
56
                       size
 
57
                       font
 
58
                       ul-color
 
59
                       lr-color
 
60
                       text-color
 
61
                       xpadding
 
62
                       ypadding
 
63
                       bevel
 
64
                       ratio
 
65
                       pressed)
 
66
 
 
67
  (define (text-width extents)
 
68
    (car extents))
 
69
 
 
70
  (define (text-height extents)
 
71
    (cadr extents))
 
72
 
 
73
  (define (text-ascent extents)
 
74
    (caddr extents))
 
75
 
 
76
  (define (text-descent extents)
 
77
    (cadr (cddr extents)))
 
78
 
 
79
  (define (round-select img
 
80
                        x
 
81
                        y
 
82
                        width
 
83
                        height
 
84
                        ratio)
 
85
    (let* ((diameter (* ratio height)))
 
86
      (gimp-ellipse-select img x y diameter height CHANNEL-OP-ADD FALSE 0 0)
 
87
      (gimp-ellipse-select img (+ x (- width diameter)) y
 
88
                           diameter height CHANNEL-OP-ADD FALSE 0 0)
 
89
      (gimp-rect-select img (+ x (/ diameter 2)) y
 
90
                        (- width diameter) height CHANNEL-OP-ADD FALSE 0)))
 
91
 
 
92
  (let* (
 
93
        (text-extents (gimp-text-get-extents-fontname text
 
94
                                                      size
 
95
                                                      PIXELS
 
96
                                                      font))
 
97
        (ascent (text-ascent text-extents))
 
98
        (descent (text-descent text-extents))
 
99
 
 
100
        (height (+ (* 2 (+ ypadding bevel))
 
101
                       (+ ascent descent)))
 
102
 
 
103
        (radius (/ (* ratio height) 4))
 
104
 
 
105
        (width (+ (* 2 (+ radius xpadding))
 
106
                  bevel
 
107
                  (text-width text-extents)))
 
108
 
 
109
        (img (car (gimp-image-new width height RGB)))
 
110
 
 
111
        (bumpmap (car (gimp-layer-new img width height
 
112
                                      RGBA-IMAGE "Bumpmap" 100 NORMAL-MODE)))
 
113
        (gradient (car (gimp-layer-new img width height
 
114
                                       RGBA-IMAGE "Button" 100 NORMAL-MODE)))
 
115
        )
114
116
 
115
117
    (gimp-context-push)
116
118
 
117
119
    (gimp-image-undo-disable img)
118
120
 
119
121
    ; Create bumpmap layer
120
 
    
 
122
 
121
123
    (gimp-image-add-layer img bumpmap -1)
122
124
    (gimp-selection-none img)
123
125
    (gimp-context-set-background '(0 0 0))
124
126
    (gimp-edit-fill bumpmap BACKGROUND-FILL)
125
127
 
126
128
    (round-select img (/ bevel 2) (/ bevel 2)
127
 
                  (- width bevel) (- height bevel) ratio)
 
129
                  (- width bevel) (- height bevel) ratio)
128
130
    (gimp-context-set-background '(255 255 255))
129
131
    (gimp-edit-fill bumpmap BACKGROUND-FILL)
130
132
 
140
142
    (gimp-context-set-background lr-color)
141
143
 
142
144
    (gimp-edit-blend gradient FG-BG-RGB-MODE NORMAL-MODE
143
 
                     GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
144
 
                     FALSE 0 0 TRUE
145
 
                     0 0 0 (- height 1))
 
145
                     GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
 
146
                     FALSE 0 0 TRUE
 
147
                     0 0 0 (- height 1))
146
148
 
147
149
    (gimp-selection-none img)
148
150
 
149
151
    (plug-in-bump-map 1 img gradient bumpmap
150
 
                      135 45 bevel 0 0 0 0 TRUE pressed 0)
 
152
                      135 45 bevel 0 0 0 0 TRUE pressed 0)
151
153
 
152
154
;     Create text layer
153
155
 
155
157
 
156
158
    (gimp-context-set-foreground text-color)
157
159
    (let ((textl (car (gimp-text-fontname
158
 
                       img -1 0 0 text 0 TRUE size PIXELS
159
 
                       font))))
 
160
                       img -1 0 0 text 0 TRUE size PIXELS
 
161
                       font))))
160
162
      (gimp-layer-set-offsets textl
161
 
                              (+ xpadding radius bevel)
162
 
                              (+ ypadding descent bevel)))
 
163
                              (+ xpadding radius bevel)
 
164
                              (+ ypadding descent bevel)))
163
165
 
164
166
;   Delete some fucked-up pixels.
165
167
 
177
179
    (gimp-image-undo-enable img)
178
180
    (gimp-display-new img)
179
181
 
180
 
    (gimp-context-pop)))
 
182
    (gimp-context-pop)
 
183
  )
 
184
)
181
185
 
182
186
(script-fu-register "script-fu-round-button"
183
 
                    _"_Round Button..."
184
 
                    "Round button"
185
 
                    "Arturo Espinosa (stolen from quartic's beveled button)"
186
 
                    "Arturo Espinosa & Federico Mena Quintero"
187
 
                    "June 1998"
188
 
                    ""
189
 
                    SF-STRING     _"Text"                 "The GIMP"
190
 
                    SF-ADJUSTMENT _"Font size (pixels)"   '(16 2 100 1 1 0 1)
191
 
                    SF-FONT       _"Font"                 "Sans"
192
 
                    SF-COLOR      _"Upper color"          '(192 192 0)
193
 
                    SF-COLOR      _"Lower color"          '(128 108 0)
194
 
                    SF-COLOR      _"Text color"           '(0 0 0)
195
 
                    SF-COLOR      _"Upper color (active)" '(255 255 0)
196
 
                    SF-COLOR      _"Lower color (active)" '(128 108 0)
197
 
                    SF-COLOR      _"Text color (active)"  '(0 0 192)
198
 
                    SF-ADJUSTMENT _"Padding X"            '(4 0 100 1 10 0 1)
199
 
                    SF-ADJUSTMENT _"Padding Y"            '(4 0 100 1 10 0 1)
200
 
                    SF-ADJUSTMENT _"Bevel width"          '(2 0 100 1 10 0 1)
201
 
                    SF-ADJUSTMENT _"Round ratio"          '(1 0.05 20 0.05 1 2 1)
202
 
                    SF-TOGGLE     _"Not pressed"          TRUE
203
 
                    SF-TOGGLE     _"Not pressed (active)" TRUE
204
 
                    SF-TOGGLE     _"Pressed"              TRUE)
 
187
  _"_Round Button..."
 
188
  _"Create images, each containing an oval button graphic"
 
189
  "Arturo Espinosa (stolen from quartic's beveled button)"
 
190
  "Arturo Espinosa & Federico Mena Quintero"
 
191
  "June 1998"
 
192
  ""
 
193
  SF-STRING     _"Text"                 "GIMP"
 
194
  SF-ADJUSTMENT _"Font size (pixels)"   '(16 2 100 1 1 0 1)
 
195
  SF-FONT       _"Font"                 "Sans"
 
196
  SF-COLOR      _"Upper color"          '(192 192 0)
 
197
  SF-COLOR      _"Lower color"          '(128 108 0)
 
198
  SF-COLOR      _"Text color"           "black"
 
199
  SF-COLOR      _"Upper color (active)" '(255 255 0)
 
200
  SF-COLOR      _"Lower color (active)" '(128 108 0)
 
201
  SF-COLOR      _"Text color (active)"  '(0 0 192)
 
202
  SF-ADJUSTMENT _"Padding X"            '(4 0 100 1 10 0 1)
 
203
  SF-ADJUSTMENT _"Padding Y"            '(4 0 100 1 10 0 1)
 
204
  SF-ADJUSTMENT _"Bevel width"          '(2 0 100 1 10 0 1)
 
205
  SF-ADJUSTMENT _"Round ratio"          '(1 0.05 20 0.05 1 2 1)
 
206
  SF-TOGGLE     _"Not pressed"          TRUE
 
207
  SF-TOGGLE     _"Not pressed (active)" TRUE
 
208
  SF-TOGGLE     _"Pressed"              TRUE
 
209
)
205
210
 
206
211
(script-fu-menu-register "script-fu-round-button"
207
 
                         _"<Toolbox>/Xtns/Script-Fu/Buttons")
 
212
                         "<Toolbox>/Xtns/Buttons")