-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path299_Lord_of_the_Rings_Script.scm
405 lines (341 loc) · 15.5 KB
/
299_Lord_of_the_Rings_Script.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
;Modernized with ModernizeMatic8 for Gimp 2.10.28 by vitforlinux.wordpress.com - dont remove
; GIMP - The GNU Image Manipulation Program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; 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.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
;
; Creates a chiseled-looking text, similar to the Lord of the Rings Logo.
; In order for the effect to look very realistic, the Ringbearer font
; should be installed on your computer. This font is readily found on the
; web. But, the effect looks nice with any font.
;
; Just highlight the text layer and run the script, which is found on the
; Filters Menu > Alpha to Logo > Lord of the Rings....
;
; Script updated on October 3, 2008 to work with GIMP 2.6
; Script updated on April 24 2023 to work with GIMP 2.10.28 by Vitforlinux
;
; Better with Ringbearer medium font https://www.dafont.com/ringbearer.font or https://www.1001fonts.com/ringbearer-font.html
;
; Define the Function
;Fix code for 2.99.6 work 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)))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(define sfbggrad "Crown molding")
(define sfbggrad "Crown Molding") )
(cond ((not (defined? 'gimp-text-fontname)) (define (gimp-text-fontname fn1 fn2 fn3 fn4 fn5 fn6 fn7 fn8 PIXELS fn9) (gimp-text-font fn1 fn2 fn3 fn4 fn5 fn6 fn7 fn8 fn9))))
(define (script-fu-lotr299-text image
drawable
useColor
desiredColor
blendStyle
addShadow
offsetX
offsetY
blurRadius
shadowColor
opacity
; keepBumpMap
)
;Declare the Variables
(let* (
(theSelection 0)
(bumpMapLayer 0)
(originalLayer 0)
(gradientType 0)
(shadowLayer 0)
(position 0)
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background)))
)
; Set up the script so that user settings can be reset after the script is run
(gimp-context-push)
; Start an Undo Group so script can be undone in one step
(gimp-image-undo-group-start image)
; Save any active selections to a channel so script can be run on whole layers and then turn off selection
(set! theSelection (car (gimp-selection-save image)))
(gimp-selection-none image)
; Set the active layer
; (gimp-image-set-active-layer image drawable)
(cond ((defined? 'gimp-image-set-selected-layers) (gimp-image-set-selected-layers image (vector drawable)))
(else (gimp-image-set-active-layer image drawable))
)
; Assign the bumpMapLayer and originalLayer, add the originalLayer above the bumpMapLayer
; & add the layer name to bumpMapLayer. Lock the transparency for both layers so that
; fills will be added only to non-transparent areas. Alpha to selection was tried for this
; script, but results weren't as good. The bumpMapLayer and OriginalLayer are linked for
; later movement around the canvas if so desired.
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(set! bumpMapLayer (car (gimp-image-get-active-layer image)))
(set! bumpMapLayer (vector-ref (car (gimp-image-get-selected-layers image)) 0))
)
(set! originalLayer (car (gimp-layer-copy bumpMapLayer TRUE)))
(gimp-image-insert-layer image originalLayer 0 -1)
(gimp-item-set-name bumpMapLayer "Bump Map Layer")
;;; (gimp-layer-set-lock-alpha originalLayer TRUE) ;none 2.2
;;; (gimp-layer-set-lock-alpha bumpMapLayer TRUE) ;none 2.2
(gimp-layer-set-lock-alpha originalLayer TRUE) ;add 2.2
(gimp-layer-set-lock-alpha bumpMapLayer TRUE) ;add 2.2
;(gimp-item-set-linked originalLayer TRUE)
; (gimp-item-set-linked bumpMapLayer TRUE)
; Set the foreground/background colors
(gimp-context-set-foreground '(255 255 255))
(gimp-context-set-background '(0 0 0))
; Assign values to the Blend Style. See tutorial for example output of each style. Dimple
; appears to look the best and is set as the default. Then fill the bumpMapLayer with the
; chosen fill type
(if (= blendStyle 0)
(set! gradientType GRADIENT-SHAPEBURST-DIMPLED)
)
(if (= blendStyle 1)
(set! gradientType GRADIENT-SHAPEBURST-ANGULAR)
)
(if (= blendStyle 2)
(set! gradientType GRADIENT-SHAPEBURST-SPHERICAL)
)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY)
(gimp-context-set-gradient-fg-bg-rgb)
;(gimp-edit-blend bumpMapLayer BLEND-FG-BG-RGB LAYER-MODE-NORMAL-LEGACY gradientType 100 0 REPEAT-NONE FALSE TRUE 2 0.2 TRUE 0 0 1 1)
(gimp-drawable-edit-gradient-fill bumpMapLayer gradientType 0 FALSE 1 1 TRUE 0 0 1 1)
; Run the Sharpen plugin twice to enhance chisel effect.
;(plug-in-sharpen 1 image bumpMapLayer 50)
;(plug-in-sharpen 1 image bumpMapLayer 70) ;changed
; Set bumpMapLayer invisible
(gimp-item-set-visible bumpMapLayer FALSE)
; Set the originalLayer as active
;(gimp-image-set-active-layer image originalLayer)
(cond ((defined? 'gimp-image-set-selected-layers) (gimp-image-set-selected-layers image (vector originalLayer)))
(else (gimp-image-set-active-layer image originalLayer))
)
; If user decides they want to work with the existing color of the text, the text color is left
; unchanged. Otherwise, the color selected when the script is first run is set as the foreground
; color and used to fill the originalLayer
(if (= useColor FALSE)
(begin
(gimp-context-set-foreground desiredColor)
(gimp-drawable-edit-fill originalLayer FILL-FOREGROUND)
)
)
; The bump map plugin is run using the bumpMapLayer to give the originalLayer its chiseled look
(plug-in-bump-map 1 image originalLayer bumpMapLayer 135 45 5 0 0 0 0 TRUE FALSE 0)
; If the user wants to keep the bumpMapLayer for later use, it will be kept in this step.
; Otherwise, the layer is deleted.
; (if (= keepBumpMap FALSE)
(gimp-image-remove-layer image bumpMapLayer)
; )
; If the user wants to add a drop shadow, the parameters entered in when the script was first
; run are put into the existing GIMP drop shadow script.
(if (= addShadow TRUE)
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(script-fu-drop-shadow image originalLayer offsetX offsetY blurRadius shadowColor opacity TRUE) ;changed
(script-fu-drop-shadow image (vector originalLayer) offsetX offsetY blurRadius shadowColor opacity TRUE)) ;changed
)
; Determine the position of the shadowLayer in the stack and link it
; to the bumpMapLayer and OriginalLayer for later movement around the canvas if so desired.
;;;(set! position (car (gimp-image-get-item-position image originalLayer))) ;none 2.2
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(set! shadowLayer (aref (cadr (gimp-image-get-layers image)) (+ position 1)))
(set! shadowLayer (vector-ref (car (gimp-image-get-layers image)) (+ position 1))))
;(gimp-image-set-active-layer image shadowLayer)
(cond ((defined? 'gimp-image-set-selected-layers) (gimp-image-set-selected-layers image (vector shadowLayer)))
(else (gimp-image-set-active-layer image shadowLayer))
)
;(gimp-item-set-linked shadowLayer TRUE)
; The original selection is reloaded and its channel is deleted
(gimp-image-select-item image 2 theSelection)
(gimp-image-remove-channel image theSelection)
; The originalLayer is made active
;(gimp-image-set-active-layer image originalLayer)
(cond ((defined? 'gimp-image-set-selected-layers) (gimp-image-set-selected-layers image (vector originalLayer)))
(else (gimp-image-set-active-layer image originalLayer))
)
; Closes the undo group
(gimp-image-undo-group-end image)
; Tells GIMP that a change has been made
(gimp-context-set-foreground old-fg)
(gimp-context-set-background old-bg)
(gimp-displays-flush)
; Resets previous user settings
(gimp-context-pop)
)
)
; Registers the Script with the PB
(script-fu-register "script-fu-lotr299-text"
"Lord of the Rings 299...Alpha"
"Make a chiseled-looking alpha, similar to the Lord of the Rings"
"Art Wade"
"Art Wade"
"October 3, 2008"
"RGBA"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-TOGGLE "Use existing text color?" FALSE
SF-COLOR "Desired Text Color" '(213 206 95)
SF-OPTION "Gradient Blend Style" '("Dimpled" "Angular" "Spherical")
SF-TOGGLE "Add Drop Shadow?" TRUE
SF-ADJUSTMENT "Offset X" '(3 0 100 1 10 0 1)
SF-ADJUSTMENT "Offset Y" '(3 0 100 1 10 0 1)
SF-ADJUSTMENT "Blur radius" '(5 0 100 1 10 0 1)
SF-COLOR "Color" '(0 0 0)
SF-ADJUSTMENT "Opacity" '(80 0 100 1 10 0 0)
;SF-TOGGLE "Keep Bump Map Layer?" FALSE
)
(script-fu-menu-register "script-fu-lotr299-text" "<Image>/Script-Fu/Alpha-to-Logo/")
;;text
(define (script-fu-lotr299-text-text text size font justification letter-spacing line-spacing grow-text outline md color mgrad mtex blendStyle addShadow offsetX offsetY blurRadius shadowColor
opacity bg-md bg-color1 bggrad bgpat)
(let* ((img (car (gimp-image-new 256 256 RGB)))
;;text
(text-layer (car (gimp-text-fontname img -1 0 0 text 20 TRUE size PIXELS font)))
(justification (cond ((= justification 0) 2)
((= justification 1) 0)
((= justification 2) 1)
((= justification 3) 3)))
;;width height
(width (car (gimp-drawable-get-width text-layer)))
(height (car (gimp-drawable-get-height text-layer)))
(bg-layer 0)
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background)))
(old-grad (car (gimp-context-get-gradient)))
(old-pat (car (gimp-context-get-pattern)))
)
(gimp-image-undo-disable img)
(gimp-context-push)
(gimp-context-set-paint-mode 0)
(gimp-image-resize img (+ width offsetX) (+ height offsetY) 0 0)
;;
(gimp-context-set-foreground color)
(gimp-text-layer-set-letter-spacing text-layer letter-spacing) ; Set Letter Spacing
(gimp-text-layer-set-justification text-layer justification) ; Text Justification (Rev Value)
(gimp-text-layer-set-line-spacing text-layer line-spacing) ; Set Line Spacing
;;;;;; SHRINK/GROW text
(cond ((> grow-text 0)
(gimp-selection-none img)
(gimp-image-select-item img 2 text-layer)
(gimp-selection-grow img (round grow-text))
(gimp-drawable-edit-fill text-layer FILL-FOREGROUND)
)
((< grow-text 0)
(gimp-selection-none img)
(gimp-image-select-item img 2 text-layer)
(gimp-drawable-edit-clear text-layer)
(gimp-selection-shrink img (- grow-text))
(gimp-drawable-edit-fill text-layer FILL-FOREGROUND)
))
;;; outline
(cond ((> outline 0)
(gimp-selection-none img)
(gimp-image-select-item img 2 text-layer)
(gimp-selection-shrink img (round outline))
(gimp-drawable-edit-clear text-layer)
(gimp-image-select-item img 2 text-layer)
))
(gimp-image-resize img (car (gimp-drawable-get-width text-layer) ) (car (gimp-drawable-get-height text-layer) ) 0 0)
(gimp-selection-none img)
(gimp-layer-set-lock-alpha text-layer TRUE)
(gimp-drawable-edit-fill text-layer FILL-FOREGROUND)
(cond((= md 1)
(gimp-context-set-gradient mgrad)
;(gimp-blend text-layer BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY 0 100 20 REPEAT-NONE FALSE 0 0 0 0 0 0 width height)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY)
(gimp-drawable-edit-gradient-fill text-layer 0 0 REPEAT-NONE 1 1 FALSE 0 0 width height)
)
((= md 2)
(gimp-context-set-pattern mtex)
(gimp-image-select-item img 2 text-layer)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY)
(gimp-drawable-edit-fill text-layer FILL-PATTERN)
(gimp-selection-none img)
))
(script-fu-lotr299-text img
text-layer
TRUE
'(0 0 0)
blendStyle
addShadow
offsetX
offsetY
blurRadius
shadowColor
opacity
; keepBumpMap
)
(set! width (car (gimp-image-get-width img) ) )
(set! height (car (gimp-image-get-height img) ) )
(set! bg-layer (car (gimp-layer-new img 10 10 RGB-IMAGE "background" 100 LAYER-MODE-NORMAL-LEGACY) ) )
(gimp-image-insert-layer img bg-layer 0 2)
(gimp-drawable-edit-clear bg-layer)
(gimp-layer-resize bg-layer width height 0 0)
(gimp-context-set-foreground bg-color1)
(gimp-drawable-fill bg-layer FILL-FOREGROUND)
(cond((= bg-md 1)
(gimp-context-set-gradient bggrad)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY)
;(gimp-blend bg-layer BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY 0 100 20 REPEAT-NONE FALSE 0 0 0 0 0 0 width height)
(gimp-drawable-edit-gradient-fill bg-layer 0 20 REPEAT-NONE 1 1 FALSE 0 0 width height)
)
((= bg-md 2)
(gimp-selection-all img)
(gimp-context-set-pattern bgpat)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY)
(gimp-drawable-edit-bucket-fill bg-layer FILL-PATTERN 0 0)
(gimp-selection-none img)
))
(gimp-context-set-foreground old-fg)
(gimp-context-set-background old-bg)
(gimp-context-set-gradient old-grad)
(gimp-context-set-pattern old-pat)
(gimp-image-undo-enable img)
(gimp-context-pop)
(gimp-display-new img)
))
(script-fu-register "script-fu-lotr299-text-text"
"Lord of the Rings 299... Text"
"Make a chiseled-looking text, similar to the Lord of the Rings"
"Art Wade"
"Art Wade"
"October 3, 2008"
""
SF-TEXT "Text String" "Lord of the Rings"
SF-ADJUSTMENT "Font Size (pixels)" '(120 2 1000 1 10 0 1)
SF-FONT "Font" "QTBodini"
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 -40 40 1 10 0 0)
SF-ADJUSTMENT _"Outline" '(0 0 40 1 10 0 0)
SF-OPTION "mode" '(_"color" _"gradient" _"pattern")
SF-COLOR "Color" '(213 206 95)
SF-GRADIENT "Gradient" "Wood 1"
SF-PATTERN "Pattern" "Burlwood"
SF-OPTION "Gradient Blend Style" '("Dimpled" "Angular" "Spherical")
SF-TOGGLE "Add Drop Shadow?" TRUE
SF-ADJUSTMENT "Offset X" '(3 0 100 1 10 0 1)
SF-ADJUSTMENT "Offset Y" '(3 0 100 1 10 0 1)
SF-ADJUSTMENT "Blur radius" '(5 0 100 1 10 0 1)
SF-COLOR "Color" '(0 0 0)
SF-ADJUSTMENT "Opacity" '(80 0 100 1 10 0 0)
SF-OPTION "bg-mode" '(_"color" _"gradient" _"pattern")
SF-COLOR "Background Color" '(210 215 184)
SF-GRADIENT "Background Gradient" sfbggrad
SF-PATTERN "Background Pattern" "Crinkled Paper"
; SF-TOGGLE "Keep Bump Map Layer?" FALSE
)
(script-fu-menu-register "script-fu-lotr299-text-text" "<Image>/Script-Fu/Logos/")