-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDouble_bump_map.scm
430 lines (395 loc) · 17 KB
/
Double_bump_map.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
; following Oregonian's tutorial on Double Bump Map
; found at link: http://gimpchat.com/viewtopic.php?f=23&t=12
; author: Tin Tran
; date: 2014
; update and extend 2023 vitforlinux
; Fix code for gimp 2.99.6 working in 2.10
(cond ((not (defined? 'gimp-drawable-get-width)) (define gimp-drawable-get-width gimp-drawable-width)))
(cond ((not (defined? 'gimp-drawable-get-height)) (define gimp-drawable-get-height gimp-drawable-height)))
(cond ((not (defined? 'gimp-image-get-width)) (define gimp-image-get-width gimp-image-width)))
(cond ((not (defined? 'gimp-image-get-height)) (define gimp-image-get-height gimp-image-height)))
(define (apply-drop-shadow img fond x y blur color opacity number) (begin
(gimp-image-select-item img 2 fond)
(gimp-selection-translate img x y)
(gimp-selection-feather img blur)
(gimp-context-set-foreground color)
(gimp-context-set-opacity opacity)
(gimp-image-select-item img 1 fond)
(gimp-drawable-edit-fill fond FILL-FOREGROUND)
(gimp-context-set-opacity 100)
(gimp-selection-none img)
))
(define (script-fu-double-bump-map image layer
color
pattern
no-pattern
grow-distance
blur-radius
bump-azimuth
bump-elevation
bump-depth
;shadow settings
shadow
shadow-offset-X ;offset x
shadow-offset-Y ;offset y
shadow-blur-radius ;blur-radius
shadow-color ;color
shadow-opacity ;opacity
)
(let*
(
(dummy-variable-to-make-let-happy 0)
(image-width)
(image-height)
;vectors/paths related variables to create our own path and select it to cut after blur
(get-vectors-returned-values)
(vectors-count 0)
(vectors-array 0)
(current-vector 0)
(color-layer)
(pattern-layer)
) ;end of variable declaration
(gimp-context-push)
(gimp-image-undo-group-start image) ;undo-group in one step
(gimp-context-set-paint-mode 0)
(set! image-width (car (gimp-image-get-width image)))
(set! image-height (car (gimp-image-get-height image)))
;START
(gimp-layer-resize-to-image-size layer)
(gimp-image-select-item image CHANNEL-OP-REPLACE layer)
(gimp-drawable-edit-fill layer FILL-WHITE)
;grow selection, invert, the create vector path
(gimp-selection-grow image grow-distance)
(gimp-selection-invert image)
(gimp-selection-feather image 2)
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(plug-in-sel2path RUN-NONINTERACTIVE image layer)
(plug-in-sel2path RUN-NONINTERACTIVE image (vector layer)))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(set! get-vectors-returned-values (gimp-image-get-vectors image))
(set! get-vectors-returned-values (gimp-image-get-paths image)) )
(set! vectors-count (car get-vectors-returned-values))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(set! vectors-array (cadr get-vectors-returned-values))
(set! vectors-array (car get-vectors-returned-values)))
(set! current-vector (vector-ref vectors-array 0)) ;top path, our own created from selection
;blurs white bump map
(gimp-selection-none image)
(plug-in-gauss RUN-NONINTERACTIVE image layer
blur-radius blur-radius
1 ;1 RLE or 0 IIR
)
;creates new colored layer to bump map
(set! color-layer (car (gimp-layer-new image image-width image-height
RGBA-IMAGE "Color" 100 LAYER-MODE-HSL-COLOR-LEGACY ))) ;creates layer
(if (= no-pattern 0) (gimp-layer-set-mode color-layer LAYER-MODE-NORMAL-LEGACY))
;creates new pattern layer to bump map as well
(set! pattern-layer (car (gimp-layer-new image image-width image-height
RGBA-IMAGE "Pattern" 100 LAYER-MODE-NORMAL-LEGACY))) ;creates layer
;insert above current layer
(gimp-image-insert-layer image color-layer 0 (car (gimp-image-get-item-position image layer)))
(gimp-image-insert-layer image pattern-layer 0 (car (gimp-image-get-item-position image layer)))
;fill color layer with color
;(gimp-image-set-active-layer image color-layer)
(gimp-selection-all image)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill color-layer FILL-FOREGROUND)
;fill pattern layer with pattern
;(gimp-image-set-active-layer image pattern-layer)
(gimp-selection-all image)
(gimp-context-set-pattern pattern)
(gimp-drawable-edit-fill pattern-layer FILL-PATTERN)
;perform bump map 1st time (color layer)
(plug-in-bump-map 1 image color-layer layer
bump-azimuth ;Azimuth
bump-elevation ;Elevation
bump-depth ;Depth
0 ;X-offset
0 ;Y-offset
0 ;water level
0 ;ambient
TRUE ;compensate for darkening
FALSE ;invert
0 ;type of map LINEAR (0), SPHERICAL (1), SINUSOIDAL (2)
)
;perform bump map 1st time (pattern layer)
(plug-in-bump-map 1 image pattern-layer layer
bump-azimuth ;Azimuth
bump-elevation ;Elevation
bump-depth ;Depth
0 ;X-offset
0 ;Y-offset
0 ;water level
0 ;ambient
TRUE ;compensate for darkening
FALSE ;invert
0 ;type of map LINEAR (0), SPHERICAL (1), SINUSOIDAL (2)
)
;cut out color layer using previously created path
(gimp-image-select-item image CHANNEL-OP-REPLACE current-vector)
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(gimp-edit-cut color-layer)
(gimp-edit-cut (vector color-layer)) )
(gimp-selection-none image)
;cur out pattern layer using previously created path
(gimp-image-select-item image CHANNEL-OP-REPLACE current-vector)
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(gimp-edit-cut pattern-layer)
(gimp-edit-cut (vector pattern-layer)) )
(gimp-selection-none image)
;delete current-vector
;(gimp-image-remove-vectors image current-vector)
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(gimp-image-remove-vectors image current-vector)
(gimp-image-remove-path image current-vector) )
;bump map 2nd time (color layer)
(plug-in-bump-map 1 image color-layer layer
bump-azimuth ;Azimuth
bump-elevation ;Elevation
bump-depth ;Depth
0 ;X-offset
0 ;Y-offset
0 ;water level
0 ;ambient
TRUE ;compensate for darkening
FALSE ;invert
0 ;type of map LINEAR (0), SPHERICAL (1), SINUSOIDAL (2)
)
;bump map 2nd time (pattern layer)
(plug-in-bump-map 1 image pattern-layer layer
bump-azimuth ;Azimuth
bump-elevation ;Elevation
bump-depth ;Depth
0 ;X-offset
0 ;Y-offset
0 ;water level
0 ;ambient
TRUE ;compensate for darkening
FALSE ;invert
0 ;type of map LINEAR (0), SPHERICAL (1), SINUSOIDAL (2)
)
;drops shadow of color-layer
(if (= shadow TRUE)
(apply-drop-shadow image pattern-layer
shadow-offset-X ;offset x
shadow-offset-Y ;offset y
shadow-blur-radius ;blur-radius
shadow-color ;color
shadow-opacity ;opacity
TRUE ;allow resizing
))
;DONE
(gimp-image-undo-group-end image) ;undo group in one step
(gimp-context-pop)
(gimp-displays-flush)
) ;end of let*
) ;end of define
(script-fu-register
"script-fu-double-bump-map" ;function name
"Double Bump Map" ;menu register
"Creates Double Bump Map effect on your art/text/shapes." ;description
"Tin Tran" ;author name
"copyright info and description" ;copyright info or description
"2014" ;date
"RGB*, GRAY*" ;mode
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
SF-COLOR "Solid Color" '(0 129 229)
SF-PATTERN "Pattern" "Blue Squares"
SF-TOGGLE "Use Pattern instead of solid color" TRUE
SF-ADJUSTMENT "Grow Distance(from border to cut)" '(2 0 100 1 10 0 0)
SF-ADJUSTMENT "Bump Map Blur Radius" '(3 0 100 1 10 0 0)
SF-ADJUSTMENT "Bump Azimuth" '(135 0 360 1 10 0 0)
SF-ADJUSTMENT "Bump Elevation" '(33 0 100 1 10 0 0)
SF-ADJUSTMENT "Bump Depth" '(35 0 100 1 10 0 0)
SF-TOGGLE "Shadow" TRUE
SF-ADJUSTMENT "Shadow Offset X" '(4 0 100 1 10 0 0)
SF-ADJUSTMENT "Shadow Offset Y" '(4 0 100 1 10 0 0)
SF-ADJUSTMENT "Shadow Blur Radius" '(15 0 100 1 10 0 0)
SF-COLOR "Shadow Color" '(0 0 0)
SF-ADJUSTMENT "Shadow Opacity" '(60 0 100 1 10 0 0)
)
(script-fu-menu-register "script-fu-double-bump-map" "<Image>/Script-Fu/Alpha-to-Logo/")
(script-fu-register
"script-fu-double-bump-text" ;function name
"Double Bumped Text" ;menu label
"Creates a text, with double bump effect,\
font, font size, and color pattern, grow/shrink and outline, " ;description
"Michael Terry" ;author
"copyright 2023, vitforlinux;\
2009, the GIMP Documentation Team" ;copyright notice
"May 12, 2023" ;date created
"" ;image type that the script works on
SF-TEXT "Text" "Double Bumped Text" ;a string variable
SF-FONT "Font" "QTLautrecType" ;a font variable
SF-ADJUSTMENT "Font size" '(150 1 1000 1 10 0 0)
;a spin-button
SF-OPTION _"Text Justification" '("Centered" "Left" "Right" "Fill")
SF-ADJUSTMENT "Letter Spacing" '(0 -50 50 1 5 0 0)
SF-ADJUSTMENT "Line Spacing" '(-5 -300 300 1 10 0 0)
SF-ADJUSTMENT _"Shrink / Grow Text" '(0 -20 20 1 10 0 0)
SF-ADJUSTMENT _"Outline" '(0 0 20 1 10 0 0)
SF-COLOR "Solid Color" '(0 129 229)
SF-PATTERN "Pattern" "Blue Squares"
SF-TOGGLE "Use Pattern instead of solid color" TRUE
SF-COLOR "Background Color" '(255 255 255)
SF-ADJUSTMENT "Grow Distance(from border to cut)" '(2 0 100 1 10 0 0)
SF-ADJUSTMENT "Bump Map Blur Radius" '(3 0 100 1 10 0 0)
SF-ADJUSTMENT "Bump Azimuth" '(135 0 360 1 10 0 0)
SF-ADJUSTMENT "Bump Elevation" '(33 0 100 1 10 0 0)
SF-ADJUSTMENT "Bump Depth" '(35 0 100 1 10 0 0)
SF-TOGGLE "Shadow" TRUE
SF-ADJUSTMENT "Shadow Offset X" '(4 0 100 1 10 0 0)
SF-ADJUSTMENT "Shadow Offset Y" '(4 0 100 1 10 0 0)
SF-ADJUSTMENT "Shadow Blur Radius" '(15 0 100 1 10 0 0)
SF-COLOR "Shadow Color" '(0 0 0)
SF-ADJUSTMENT "Shadow Opacity" '(60 0 100 1 10 0 0)
SF-ADJUSTMENT "Buffer amount" '(35 3 100 1 10 1 0)
;a slider
SF-TOGGLE "Flatten" TRUE
)
(script-fu-menu-register "script-fu-double-bump-text" "<Image>/Script-Fu/Logos/")
(define (script-fu-double-bump-text inText inFont inFontSize justification letter-spacing line-spacing grow-text outline color pattern no-pattern bgcolor grow-distance blur-radius bump-azimuth bump-elevation bump-depth shadow shadow-offset-X shadow-offset-Y shadow-blur-radius shadow-color shadow-opacity inBufferAmount flatten)
(let*
(
; define our local variables
; create a new image:
(theImageWidth 10)
(theImageHeight 10)
(theImage)
(theImage
(car
(gimp-image-new
theImageWidth
theImageHeight
RGB
)
)
)
(theText) ;a declaration for the text
(theBuffer) ;create a new layer for the image
(theLayer
(car
(gimp-layer-new
theImage
theImageWidth
theImageHeight
RGB-IMAGE
"layer 1"
100
LAYER-MODE-NORMAL
)
)
)
(justification (cond ((= justification 0) 2)
((= justification 1) 0)
((= justification 2) 1)
((= justification 3) 3)))
) ;end of our local variables
(gimp-context-push)
(gimp-context-set-paint-mode 0)
(gimp-image-insert-layer theImage theLayer 0 0)
(gimp-context-set-background bgcolor )
(gimp-context-set-foreground color)
(gimp-drawable-fill theLayer FILL-BACKGROUND)
(set! theText
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(car
(gimp-text-fontname
theImage theLayer
0 0
inText
0
TRUE
inFontSize PIXELS
inFont)
)
(car
(gimp-text-font
theImage theLayer
0 0
inText
0
TRUE
inFontSize
inFont)
))
)
; (set! theImageWidth (car (gimp-drawable-get-width theText) ) )
;(set! theImageHeight (car (gimp-drawable-get-height theText) ) )
;(set! theBuffer (* theImageHeight (/ inBufferAmount 100) ) )
;(set! theImageHeight (+ theImageHeight theBuffer theBuffer) )
;(set! theImageWidth (+ theImageWidth theBuffer theBuffer) )
;;;;centre text on line
;(gimp-text-layer-set-justification theText 2)
(gimp-text-layer-set-letter-spacing theText letter-spacing) ; Set Letter Spacing
(gimp-text-layer-set-justification theText justification) ; Text Justification (Rev Value)
(gimp-text-layer-set-line-spacing theText line-spacing) ; Set Line Spacing
; (gimp-image-resize theImage theImageWidth theImageHeight 0 0)
;(gimp-layer-resize theLayer theImageWidth theImageHeight 0 0)
; (gimp-layer-set-offsets theText theBuffer theBuffer)
(gimp-floating-sel-to-layer theText)
;;;; shrink grow text
(cond ((> grow-text 0)
(gimp-selection-none theImage)
(gimp-image-resize-to-layers theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-selection-grow theImage (round grow-text))
(gimp-selection-feather theImage 2 )
(gimp-drawable-edit-fill theText FILL-FOREGROUND)
)
((< grow-text 0)
(gimp-selection-none theImage)
(gimp-image-resize-to-layers theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-drawable-edit-clear theText)
(gimp-selection-shrink theImage (- grow-text))
(gimp-selection-feather theImage 2 )
(gimp-drawable-edit-fill theText FILL-FOREGROUND)
))
;;; outline
(cond ((> outline 0)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-selection-feather theImage 2 )
(gimp-selection-shrink theImage (round outline))
(gimp-selection-feather theImage 2 )
(gimp-drawable-edit-clear theText)
(gimp-image-select-item theImage 2 theText)
))
; (gimp-layer-resize-to-image-size theText)
;(gimp-image-resize-to-layers theImage)
(set! theImageWidth (car (gimp-drawable-get-width theText) ) )
(set! theImageHeight (car (gimp-drawable-get-height theText) ) )
(set! theBuffer (* theImageHeight (/ inBufferAmount 100) ) )
(set! theImageHeight (+ theImageHeight theBuffer theBuffer) )
(set! theImageWidth (+ theImageWidth theBuffer theBuffer) )
(gimp-layer-set-offsets theText theBuffer theBuffer)
(gimp-image-resize theImage theImageWidth theImageHeight 0 0)
(gimp-layer-resize theLayer theImageWidth theImageHeight 0 0)
(gimp-display-new theImage)
(script-fu-double-bump-map theImage theText
color
pattern
no-pattern
grow-distance
blur-radius
bump-azimuth
bump-elevation
bump-depth
;shadow settings
shadow
shadow-offset-X ;offset x
shadow-offset-Y ;offset y
shadow-blur-radius ;blur-radius
shadow-color ;color
shadow-opacity ;opacity
)
(gimp-selection-none theImage)
(gimp-layer-resize-to-image-size theLayer)
(if (= flatten 1) (gimp-image-merge-visible-layers theImage 0))
(list theImage theLayer theText)
(gimp-context-pop)
(gimp-display-new theImage)
)
)