-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogo-workshop29916.scm
472 lines (429 loc) · 22.2 KB
/
logo-workshop29916.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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
;Modernized with ModernizeMatic7 for Gimp 2.10.22 by vitforlinux.wordpress.com - dont remove
; Logo Workshop Release Candidate Version RC 0.04 (10-2011)
;
; Created by GnuTux
; Comments directed to http://gimpchat.com or http://gimpscripts.com
;
; License: GPLv3
; 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 3 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.
;
; To view a copy of the GNU General Public License
; visit: http://www.gnu.org/licenses/gpl.html
;
; ------------
;| Change Log |
; ------------
; RC 0.01 - Initial Release Candidate
; RC 0.02 - Code clean-up, keep user selection, more descriptive variable names, eliminate tabs from source
; Add gloss layer and glass layer
; RC 0.03 - All elements on separate layers, Stroke to path implemented, allow shadow to be toggled off
; RC 0.04 - Dumped stroke to path, code optimization, dialog tweak, double stroke, double bevel, added
; three new effects (cubism, olify & plasma) to fill layer, proper layer arrangement
;
; Define the apply logo effect procedure
;
(cond ((not (defined? 'gimp-image-set-active-layer)) (define (gimp-image-set-active-layer image drawable) (gimp-image-set-selected-layers image 1 (vector drawable)))))
(define (apply-logo-workshop img
logo-layer
fill-style
logo-color
bevel-amt
stroke-color
stroke-width
shadow-color
shadowx
shadowy
shadow-opacity
effect-style
effect-pattern
effect-depth
alpha2logo)
(let* (
(stroke-layer -1) ; Stroke layer
(bump-layer -1) ; Bump Map layer
(effect-layer -1) ; Effect layer
(fill-layer -1) ; Fill layer
(feather-amt 3) ; Set global feather
(sindex 0) ; Stroke index counter
)
;
; Logo layer
;
; (script-fu-util-image-resize-from-layer img logo-layer) ; logo layer to image size
; (gimp-item-set-name logo-layer "Logo Layer") ; Name logo Layer
;
; Create Shadow Layer (only if opacity > 0)
;
(if (> shadow-opacity 0)
(begin
(script-fu-drop-shadow img logo-layer shadowx shadowy 3 shadow-color shadow-opacity 1) ; Create shadow
)
) ; endif
;
; Selection Check
;
(if (= (car (gimp-selection-is-empty img)) TRUE) ; Check for a selection
(begin
(gimp-image-select-item img 2 logo-layer) ; Select alpha to logo If there isn't one
)
) ; endif
;
; Create Stroke Layer (only if stroke width > 0)
;
(if (> stroke-width 0)
(begin
(set! stroke-layer (car (gimp-layer-new-from-drawable logo-layer img))) ; New Stoke Layer
(gimp-image-insert-layer img stroke-layer 0 0) ; Add it to image
(gimp-image-set-active-layer img stroke-layer) ; Make stroke logo layer active
(gimp-item-set-name stroke-layer "Stroke") ; Name the stroke layer
(gimp-selection-feather img feather-amt) ; Feather the selection
(if (= effect-style 5) ; Double stroke
(begin
(gimp-selection-shrink img effect-depth)
(gimp-selection-invert img) ; Invert the selction
(gimp-drawable-edit-clear stroke-layer) ; Clear stroke layer
(gimp-selection-invert img) ; Invert the selction
)
); endif
(if (= alpha2logo 1) ; Aplha stroke method
(begin
(gimp-selection-grow img 2) ; Grow the selection
(gimp-context-set-foreground stroke-color) ; Set stroke color
;(gimp-drawable-edit-bucket-fill stroke-layer 0 0 0) ; Fill with Stroke color
(gimp-drawable-edit-fill stroke-layer FILL-FOREGROUND)
(gimp-selection-shrink img 2) ; Shrink the selection
(gimp-selection-invert img) ; Invert the selction
(gimp-drawable-edit-clear stroke-layer) ; Clear stroke layer
(gimp-selection-invert img) ; Invert the selction
)
); endif
; Text stroke method (always do this)
(gimp-selection-shrink img stroke-width) ; Shrink by stroke width
(gimp-drawable-edit-clear stroke-layer) ; Clear all but stroke
)
) ; endif
;
; Create fill layer to hold fill style
;
(set! fill-layer (car (gimp-layer-new-from-drawable logo-layer img))) ; New Fill Layer
(gimp-image-insert-layer img fill-layer 0 1) ; Add it to image
(gimp-image-set-active-layer img fill-layer) ; Make fill layer active
(gimp-selection-invert img) ; Invert the stroke selection
(gimp-drawable-edit-clear fill-layer) ; Clear stroke area
(gimp-selection-invert img) ; Invert the stroke selection
(gimp-item-set-name fill-layer "Fill") ; Name fill layer
;
; Fill case structure (0-logo color fill, 1-current pattern, 2-current gradient)
(gimp-context-set-paint-mode 0)
;
(cond ((= fill-style 0)
(gimp-context-set-foreground logo-color) ; Set logo color
;(gimp-drawable-edit-bucket-fill fill-layer 0 0 0) ; Fill with color
(gimp-drawable-edit-fill fill-layer FILL-FOREGROUND)
)
((= fill-style 1)
;(gimp-drawable-edit-bucket-fill fill-layer 4 0 0) ; Fill with pattern)
(gimp-drawable-edit-fill fill-layer FILL-PATTERN)
)
(else
;(gimp-edit-blend fill-layer BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY GRADIENT-LINEAR 100 0 0 FALSE TRUE 3 0.20 TRUE 0 0 0 (car (gimp-drawable-height fill-layer))) ; Fill with gradient
(gimp-drawable-edit-gradient-fill fill-layer GRADIENT-LINEAR 0 0 100 0 0 0 0 0 (car (gimp-drawable-get-height fill-layer))) ; Fill with gradient
)
)
;
; Apply additional effects directly to fill style
;
(cond ((= effect-style 6)
(plug-in-cubism 1 img fill-layer effect-depth 3 0) ; Add cubism effect
)
((= effect-style 7)
(plug-in-oilify 1 img fill-layer effect-depth 0) ; Add olify effect
)
((= effect-style 8)
(gimp-selection-none img)
(gimp-layer-set-lock-alpha fill-layer TRUE)
(plug-in-plasma 1 img fill-layer (rand 999999999) effect-depth) ; Add plasma
)
((= effect-style 9)
; (plug-in-oilify 1 img fill-layer effect-depth 0) ; Add olify effect
(plug-in-rgb-noise 1 img fill-layer FALSE FALSE 0.6 0.6 0.6 0)
(plug-in-cubism 1 img fill-layer 1 5 0) ; Add cubism effect
)
)
;
; bevel (only if bevel-amt depth is > 0)
;
(if (> bevel-amt 0)
(begin
(script-fu-add-bevel img fill-layer bevel-amt 0 0) ; Bevel fill layer
(if (= effect-style 4) ; Effect case test
(begin ; Double bevel
(gimp-selection-shrink img stroke-width) ; Shrink by stroke width
(script-fu-add-bevel img fill-layer bevel-amt 0 0) ; Bevel fill layer again
(gimp-selection-grow img stroke-width) ; Reset by stroke width
)
);endif
)
);endif
;
; Pattern Bump (only if bump depth > 0 and additional effect = 1)
;
(if (and(> effect-depth 0)(= effect-style 1))
(begin
(set! effect-layer (car (gimp-layer-new-from-drawable fill-layer img))) ; New effect Layer
(gimp-image-insert-layer img effect-layer 0 -1) ; Add it to image
(gimp-item-set-name effect-layer "Bumped") ; Name effect layer
(set! bump-layer (car (gimp-layer-new-from-drawable fill-layer img))) ; New patten layer
(gimp-context-set-pattern effect-pattern) ; Make bump pattern active
(gimp-drawable-fill bump-layer FILL-PATTERN) ; Fill with pattern
;
; Call bump map procedure (pattern bump)
;
(plug-in-bump-map
1 ; Interactive (0), non-interactive (1)
img ; Input image
effect-layer ; Input drawable
bump-layer ; Bumpmap drawable
130 ; Azimuth (float)
55 ; Elevation (float)
effect-depth ; Depth
0 ; X offset
0 ; Y offset
0 ; Level that full transparency should represent
0 ; Ambient lighting factor
TRUE ; Compensate for darkening
FALSE ; Invert bumpmap
0) ; Type of map (0=linear, 1=spherical, 2=sinusoidal)
)
) ; endif
;
; Create Gloss Effect Layer
;
;
(if (and(> effect-depth 0)(= effect-style 2))
(begin
(set! bump-layer (car (gimp-layer-new-from-drawable logo-layer img))) ; New effect Layer
(gimp-image-insert-layer img bump-layer 0 -1) ; Add it to image
(gimp-item-set-name bump-layer "Gloss") ; Name effect layer
(gimp-selection-shrink img (- effect-depth 4)) ; Shrink selection
(gimp-context-set-foreground '(255 255 255)) ; Set FG to white
(gimp-drawable-edit-bucket-fill bump-layer 0 0 0) ; Fill with color
(plug-in-gauss 1 img bump-layer 5 5 1) ; Blur by 3
(gimp-selection-invert img) ; Invert Selection
(gimp-drawable-edit-clear bump-layer) ; Clear all but gloss
(gimp-layer-set-opacity bump-layer (- effect-depth 1)) ; Set Opacity
)
) ; endif
;
; Create Glass Effect Layer
;
;
(if (and(> effect-depth 0)(= effect-style 3))
(begin
(set! bump-layer (car (gimp-layer-new-from-drawable logo-layer img))) ; New effect Layer
(gimp-image-insert-layer img bump-layer 0 -1) ; Add it to image
(gimp-item-set-name bump-layer "Bump") ; Name effect layer
(gimp-context-set-foreground '(255 255 255)) ; Set FG to white
(gimp-drawable-edit-bucket-fill bump-layer 0 0 0) ; Fill with color
(plug-in-gauss 1 img bump-layer 5 5 1) ; Blur by 5
(set! effect-layer (car (gimp-layer-new-from-drawable logo-layer img))) ; New patten layer
(gimp-image-insert-layer img effect-layer 0 -1) ; Add it to image
(gimp-item-set-name effect-layer "Glass") ; Name effect layer
(plug-in-bump-map 1 img effect-layer bump-layer 135 45 (+ effect-depth 0) 0 0 0 0 0 0 0) ; Bump it
(gimp-image-set-active-layer img effect-layer) ; Ensure this layer active
(gimp-selection-shrink img (- effect-depth 1)) ; Shrink selection
(gimp-selection-feather img feather-amt) ; feather it
(gimp-drawable-curves-spline effect-layer 4 4 (get-glass-trans-curve 64)) ; Modify alpha channel curves
(gimp-selection-none img) ; Clear Selection
(gimp-drawable-hue-saturation effect-layer 0 0 0 -100 0) ; Desaturate to clear glass
(gimp-drawable-invert effect-layer FALSE) ; Invert colors
(gimp-image-remove-layer img bump-layer) ; Delete the bump layer
; (plug-in-sample-colorize 1 img effect-layer logo-layer TRUE TRUE TRUE TRUE 0 255 1 0 255)
; (gimp-image-remove-layer img bump-layer) ; Dump The Bump
)
) ; endif
); endlet
) ; return (from apply-logo-Workshop)
;
;
; Define function for glass translucency values
;
(define (get-glass-trans-curve parm)
(let* ((curve-value (cons-array 4 'byte)))
(aset curve-value 0 0)
(aset curve-value 1 0)
(aset curve-value 2 255)
(aset curve-value 3 parm)
curve-value
)
) ; return
;
; Define alpha to selection procedure
;
(define (script-fu-logo-workshop299-alpha img
logo-layer
fill-style
logo-color
bevel-amt
stroke-color
stroke-width
shadow-color
shadowx
shadowy
shadow-opacity
effect-style
effect-pattern
effect-depth)
(let* (
(alpha2logo 1) ; 0 - Text mode , 1 - Alpha mode
)
;
; Save current GIMP context
;
(gimp-context-push) ; Push context onto stack
(gimp-image-undo-group-start img) ; Begin undo group
;
; Call apply logo effect procedure
;
(apply-logo-workshop img logo-layer fill-style logo-color bevel-amt stroke-color stroke-width shadow-color shadowx shadowy shadow-opacity effect-style effect-pattern effect-depth alpha2logo)
;
; Drop logo layer to bottom
;
(gimp-image-lower-item-to-bottom img logo-layer) ; layer to botton
(gimp-item-set-visible logo-layer FALSE) ; Toggle layer off
(gimp-image-set-active-layer img logo-layer) ; Make it active
(gimp-image-undo-group-end img) ; End undo group
(gimp-context-pop) ; Pop context off stack
(gimp-displays-flush) ; Flush display
) ;endlet
) ; return
;
; Register logo effect to alpha procedure
;
(script-fu-register "script-fu-logo-workshop299-alpha"
_"_Logo Workshop Alpha 299..."
_"Create selected logo effect with a drop shadow"
"GnuTux - http://gimpchat.com"
"GnuTux - GPLv3"
"10-2011"
"RGBA"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-OPTION _"Logo Fill Method" '("Color Fill" "Fill With Active Pattern" "Fill With Active Gradient")
SF-COLOR _"Logo Fill Color" '(23 131 181)
SF-ADJUSTMENT _"Logo Bevel Depth" '(10 0 50 1 1 0 1)
SF-COLOR _"Stroke Color" '(9 45 68)
SF-ADJUSTMENT _"Stroke Width" '(3 0 19 1 1 0 1)
SF-COLOR _"Shadow Color" '(0 0 0)
SF-ADJUSTMENT _"Shadow Offset X" '(-6 -99 99 1 1 0 1)
SF-ADJUSTMENT _"Shadow Offset Y" '(4 -99 99 1 1 0 1)
SF-ADJUSTMENT _"Shadow Opacity" '(25 0 100 1 1 0 1)
SF-OPTION _"Added Effect" '("None" "Bump With Pattern" "Simple Gloss Layer" "Translucent/Glass Layer" "Double Bevel" "Double Stroke" "Cubism on Fill" "Oilify on Fill" "Plasma on fill" "Glitter on fill")
SF-PATTERN _"Added Effect Pattern" "Bricks"
SF-ADJUSTMENT _"Added Effect Depth" '(7 0 50 1 1 0 1))
(script-fu-menu-register "script-fu-logo-workshop299-alpha"
"<Image>/Filters/Alpha to Logo")
;
; Define logo effect text procedure
;
(define (script-fu-logo-workshop299 text
size
font
justification
letter-spacing
line-spacing
fill-style
logo-color
bevel-amt
stroke-color
stroke-width
shadow-color
shadowx
shadowy
shadow-opacity
effect-style
effect-pattern
effect-depth)
(let* (
(img (car (gimp-image-new 256 256 RGB))) ; Create a new image
(text-layer -1) ; Declare and init text-layer
(logo-layer -1) ; Declare and init logo-layer
(alpha2logo 0) ; 0 - Text mode , 1 - Alpha mode
(justification (cond ((= justification 0) 2)
((= justification 1) 0)
((= justification 2) 1)
((= justification 3) 3)))
)
(gimp-context-push) ; Push context onto stack
;
; Original Text Layer (keep untouched)
;
(gimp-context-set-foreground logo-color) ; Set FG to logo color
(set! text-layer (car (gimp-text-fontname img -1 0 0 text 10 TRUE size PIXELS font))) ; Create text layer
(script-fu-util-image-resize-from-layer img text-layer) ; logo layer to image size
(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
(gimp-item-set-name text-layer "Text") ; Name text Layer
;
; Logo layer (color woth stroke color and pass to the logo effects procedure)
;
(gimp-context-set-foreground stroke-color) ; Set FG to stroke color
(set! logo-layer (car (gimp-text-fontname img -1 0 0 text 10 TRUE size PIXELS font))) ; Create logo layer
(script-fu-util-image-resize-from-layer img logo-layer) ; logo layer to image size
(gimp-item-set-name logo-layer "Logo Layer") ; Name logo Layer
(gimp-text-layer-set-letter-spacing logo-layer letter-spacing) ; Set Letter Spacing
(gimp-text-layer-set-line-spacing logo-layer line-spacing) ; Set Line Spacing
(gimp-text-layer-set-justification logo-layer justification) ; Text Jusification (Rev Value)
(gimp-image-undo-disable img) ; Disallow undo
(gimp-image-resize-to-layers img)
;
; Call the logo effect procedure
;
(apply-logo-workshop img logo-layer fill-style logo-color bevel-amt stroke-color stroke-width shadow-color shadowx shadowy shadow-opacity effect-style effect-pattern effect-depth alpha2logo)
(gimp-image-remove-layer img logo-layer) ; Delete the logo layer (stroke color dup in this case)
(gimp-image-set-active-layer img text-layer) ; Make text layer active
(gimp-selection-none img) ; Clear selection
(gimp-image-undo-enable img) ; Allow undo
(gimp-context-pop) ; Pop context off stack
(gimp-display-new img) ; Show the image
) ; endlet
) ; return
;
; Register the script
;
(script-fu-register "script-fu-logo-workshop299"
_"_Logo Workshop 299..."
_"Create logo with selected fill type, drop shadow and effect"
"GnuTux - http://gimpchat.com"
"GnuTux - GPLv3"
"10-2011"
""
SF-TEXT _"Text" "Logo\nWorkshop\n2.99.16"
SF-ADJUSTMENT _"Font size (pixels)" '(220 2 1000 1 10 0 1)
SF-FONT _"Font" "Comic Sans MS Bold"
SF-OPTION _"Text Justification" '("Centered" "Left" "Right" "Fill")
SF-ADJUSTMENT _"Letter Spacing" '(0 -50 50 1 5 0 1)
SF-ADJUSTMENT _"Line Spacing" '(-5 -300 300 1 10 0 1)
SF-OPTION _"Logo Fill Method" '("Color Fill" "Fill With Active Pattern" "Fill With Active Gradient")
SF-COLOR _"Logo Fill color" '(23 131 181)
SF-ADJUSTMENT _"Logo Bevel Depth" '(10 0 50 1 1 0 1)
SF-COLOR _"Stroke color" '(9 45 68)
SF-ADJUSTMENT _"Stroke width" '(3 0 19 1 1 0 1)
SF-COLOR _"Shadow color" '(0 0 0)
SF-ADJUSTMENT _"Shadow Offset X" '(-6 -99 99 1 1 0 1)
SF-ADJUSTMENT _"Shadow Offset Y" '(4 -99 99 1 1 0 1)
SF-ADJUSTMENT _"Shadow Opacity" '(25 0 100 1 1 0 1)
SF-OPTION _"Added Effect" '("None" "Bump With Pattern" "Simple Gloss Layer" "Translucent/Glass Layer" "Double Bevel" "Double Stroke" "Cubism on Fill" "Oilify on Fill" "Plasma on fill" "Glitter on fill")
SF-PATTERN _"Added Effect Pattern" "Bricks"
SF-ADJUSTMENT _"Added Effect Depth" '(7 0 50 1 1 0 1))
(script-fu-menu-register "script-fu-logo-workshop299"
_"<Image>/File/Create/Logos (gimpchat.com)/")