8
8
; In interactive mode it creates an adjustment widget in the dialog.
11
; SF-ADJUSTMENT "label" '(value, lower, upper, step_inc, page_inc, digits, type)
11
; SF-ADJUSTMENT "label" '(value lower upper step_inc page_inc digits type)
13
13
; type is one of: SF-SLIDER(0), SF-SPINNER(1)
15
; ----------------------------------------------------------------------
17
; creates a color button in the dialog. It accepts either a list of three
18
; values for the red, green and blue components or a color name in CSS
22
; SF-COLOR "label" '(red green blue)
23
; SF-COLOR "label" "color"
14
25
; ----------------------------------------------------------------------
16
27
; creates a font-selection widget in the dialog. It returns a fontname as
41
53
; units as passed in as the default value.
44
; SF-BRUSH "Brush" '("Circle (03)" 1.0 44 0)
56
; SF-BRUSH "Brush" '("Circle (03)" 100 44 0)
46
58
; Here the brush dialog will be popped up with a default brush of Circle (03)
47
; opacity 1.0, spacing 44 and paint mode of Normal (value 0).
59
; opacity 100 spacing 44 and paint mode of Normal (value 0).
48
60
; If this selection was unchanged the value passed to the function as a
49
; paramater would be '("Circle (03)" 1.0 44 0). BTW the widget used
50
; is generally available in the libgimpui library for any plugin that
51
; wishes to select a brush.
61
; parameter would be '("Circle (03)" 100 44 0).
52
63
; ----------------------------------------------------------------------
54
65
; Only useful in interactive mode. It will create a widget in the control
109
124
; The value returned when the script is invoked is a string containing the
111
127
; ----------------------------------------------------------------------
113
129
; Only useful in interactive mode. It will create a widget in the control
114
; dialog. The widget is an option_menu showing the options that are passed
130
; dialog. The widget is a combo-box showing the options that are passed
115
131
; as a list. The first option is the default choice.
118
134
; SF-OPTION "Orientation" '("Horizontal" "Vertical")
120
136
; The value returned when the script is invoked is the number of the
121
; choosen option, where the option first is counted as 0.
137
; chosen option, where the option first is counted as 0.
139
; ----------------------------------------------------------------------
141
; Only useful in interactive mode. It will create a widget in the control
142
; dialog. The widget is a combo-box showing all enum values for the given
143
; enum type. This has to be the name of a registered enum, without the
144
; "Gimp" prefix. The second parameter speficies the default value, using
145
; the enum value's nick.
148
; SF-ENUM "Interpolation" '("InterpolationType" "linear")
150
; The value returned when the script is invoked corresponds to chosen
122
153
; ----------------------------------------------------------------------
125
156
(define (script-fu-test-sphere radius
146
(let* ((width (* radius 3.75))
147
(height (* radius 2.5))
148
(img (car (gimp-image-new width height RGB)))
149
(drawable (car (gimp-layer-new img width height RGB-IMAGE
150
"Sphere Layer" 100 NORMAL-MODE)))
151
(radians (/ (* light *pi*) 180))
154
(light-x (+ cx (* radius (* 0.6 (cos radians)))))
155
(light-y (- cy (* radius (* 0.6 (sin radians)))))
156
(light-end-x (+ cx (* radius (cos (+ *pi* radians)))))
157
(light-end-y (- cy (* radius (sin (+ *pi* radians)))))
158
(offset (* radius 0.1))
159
(text-extents (gimp-text-get-extents-fontname multi-text
162
(x-position (- cx (/ (car text-extents) 2)))
163
(y-position (- cy (/ (cadr text-extents) 2))))
179
(width (* radius 3.75))
180
(height (* radius 2.5))
181
(img (car (gimp-image-new width height RGB)))
182
(drawable (car (gimp-layer-new img width height RGB-IMAGE
183
"Sphere Layer" 100 NORMAL-MODE)))
184
(radians (/ (* light *pi*) 180))
187
(light-x (+ cx (* radius (* 0.6 (cos radians)))))
188
(light-y (- cy (* radius (* 0.6 (sin radians)))))
189
(light-end-x (+ cx (* radius (cos (+ *pi* radians)))))
190
(light-end-y (- cy (* radius (sin (+ *pi* radians)))))
191
(offset (* radius 0.1))
192
(text-extents (gimp-text-get-extents-fontname multi-text
195
(x-position (- cx (/ (car text-extents) 2)))
196
(y-position (- cy (/ (cadr text-extents) 2)))
165
201
(gimp-context-push)
172
208
(gimp-context-set-background '(20 20 20))
175
(or (and (>= light 45) (<= light 75))
176
(and (<= light 135) (>= light 105)))
178
(let ((shadow-w (* (* radius 2.5) (cos (+ *pi* radians))))
179
(shadow-h (* radius 0.5))
181
(shadow-y (+ cy (* radius 0.65))))
183
(prog1 (set! shadow-x (+ cx shadow-w))
184
(set! shadow-w (- shadow-w))))
211
(or (and (>= light 45) (<= light 75))
212
(and (<= light 135) (>= light 105)))
214
(let ((shadow-w (* (* radius 2.5) (cos (+ *pi* radians))))
215
(shadow-h (* radius 0.5))
217
(shadow-y (+ cy (* radius 0.65))))
219
(begin (set! shadow-x (+ cx shadow-w))
220
(set! shadow-w (- shadow-w))))
186
(gimp-ellipse-select img shadow-x shadow-y shadow-w shadow-h
187
CHANNEL-OP-REPLACE TRUE TRUE 7.5)
188
(gimp-context-set-pattern pattern)
189
(gimp-edit-bucket-fill drawable PATTERN-BUCKET-FILL MULTIPLY-MODE
222
(gimp-ellipse-select img shadow-x shadow-y shadow-w shadow-h
223
CHANNEL-OP-REPLACE TRUE TRUE 7.5)
224
(gimp-context-set-pattern pattern)
225
(gimp-edit-bucket-fill drawable PATTERN-BUCKET-FILL MULTIPLY-MODE
192
228
(gimp-ellipse-select img (- cx radius) (- cy radius)
193
(* 2 radius) (* 2 radius) CHANNEL-OP-REPLACE TRUE FALSE 0)
229
(* 2 radius) (* 2 radius) CHANNEL-OP-REPLACE TRUE FALSE 0)
195
231
(gimp-edit-blend drawable FG-BG-RGB-MODE NORMAL-MODE
196
GRADIENT-RADIAL 100 offset REPEAT-NONE FALSE
198
light-x light-y light-end-x light-end-y)
232
GRADIENT-RADIAL 100 offset REPEAT-NONE FALSE
234
light-x light-y light-end-x light-end-y)
200
236
(gimp-selection-none img)
203
239
(gimp-ellipse-select img 10 10 50 50 CHANNEL-OP-REPLACE TRUE FALSE 0)
205
241
(gimp-edit-blend drawable CUSTOM-MODE NORMAL-MODE
206
GRADIENT-LINEAR 100 offset REPEAT-NONE gradient-reverse
242
GRADIENT-LINEAR 100 offset REPEAT-NONE gradient-reverse
210
246
(gimp-selection-none img)
212
248
(gimp-context-set-foreground '(0 0 0))
213
249
(gimp-floating-sel-anchor (car (gimp-text-fontname img drawable
214
x-position y-position
250
x-position y-position
220
256
(gimp-image-undo-enable img)
221
257
(gimp-display-new img)
225
263
(script-fu-register "script-fu-test-sphere"
227
"Simple script to test and show the usage of the new Script-Fu API extensions."
228
"Spencer Kimball, Sven Neumann"
232
SF-ADJUSTMENT "Radius (in pixels)" '(100 1 5000 1 10 0 1)
233
SF-ADJUSTMENT "Lighting (degrees)" '(45 0 360 1 10 1 0)
234
SF-TOGGLE "Shadow" TRUE
235
SF-COLOR "Background color" '(255 255 255)
236
SF-COLOR "Sphere color" '(255 0 0)
237
SF-BRUSH "Brush" '("Circle (03)" 1.0 44 0)
238
SF-STRING "Text" "Script-Fu rocks!"
239
SF-TEXT "Multi-line text" "Hello,\nWorld!"
240
SF-PATTERN "Pattern" "Maple Leaves"
241
SF-GRADIENT "Gradient" "Deep Sea"
242
SF-TOGGLE "Gradient reverse" FALSE
243
SF-FONT "Font" "Agate"
244
SF-ADJUSTMENT "Font size (pixels)" '(50 1 1000 1 10 0 1)
245
SF-PALETTE "Palette" "Default"
246
SF-FILENAME "Environment map"
249
"/scripts/images/beavis.jpg")
250
SF-OPTION "Orientation" '("Horizontal" "Vertical")
251
SF-DIRNAME "Output directory" "/var/tmp/"
254
SF-CHANNEL "Channel" -1
255
SF-DRAWABLE "Drawable" -1)
265
"Simple script to test and show the usage of the new Script-Fu API extensions."
266
"Spencer Kimball, Sven Neumann"
270
SF-ADJUSTMENT "Radius (in pixels)" (list 100 1 5000 1 10 0 SF-SPINNER)
271
SF-ADJUSTMENT "Lighting (degrees)" (list 45 0 360 1 10 1 SF-SLIDER)
272
SF-TOGGLE "Shadow" TRUE
273
SF-COLOR "Background color" "white"
274
SF-COLOR "Sphere color" "red"
275
SF-BRUSH "Brush" '("Circle (03)" 1.0 44 0)
276
SF-STRING "Text" "Tiny-Fu rocks!"
277
SF-TEXT "Multi-line text" "Hello,\nWorld!"
278
SF-PATTERN "Pattern" "Maple Leaves"
279
SF-GRADIENT "Gradient" "Deep Sea"
280
SF-TOGGLE "Gradient reverse" FALSE
281
SF-FONT "Font" "Agate"
282
SF-ADJUSTMENT "Font size (pixels)" '(50 1 1000 1 10 0 1)
283
SF-PALETTE "Palette" "Default"
284
SF-FILENAME "Environment map"
285
(string-append gimp-data-directory
286
"/scripts/images/beavis.jpg")
287
SF-OPTION "Orientation" '("Horizontal"
289
SF-ENUM "Interpolation" '("InterpolationType" "linear")
290
SF-DIRNAME "Output directory" "/var/tmp/"
293
SF-CHANNEL "Channel" -1
294
SF-DRAWABLE "Drawable" -1
295
SF-VECTORS "Vectors" -1
257
298
(script-fu-menu-register "script-fu-test-sphere"
258
"<Toolbox>/Xtns/Script-Fu/Test")
299
"<Toolbox>/Xtns/Languages/Script-Fu/Test")