-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShiny-Chrome300.scm
379 lines (337 loc) · 15.4 KB
/
Shiny-Chrome300.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
; Shiny Chrome rel 0.02
; Created by Graechan using details from a tutorial by 'The Warrior'
; You will need to install GMIC to run this Scipt
; GMIC can be downloaded from http://sourceforge.net/projects/gmic/files/
; 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 |
; ------------
; Rel 0.01 - Initial Release
; Rel 0.02 - improved undo function of Logo Script and improved both scripts output
; Rel 300 - Fix for Gimp 3.0 rc1
; Gradients blend direction list
; 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-drawable-get-offsets)) (define gimp-drawable-get-offsets gimp-drawable-offsets)))
(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)))
(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 (apply-gauss img drawable x y)(begin (if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(plug-in-gauss 1 img drawable x y 0)
(plug-in-gauss 1 img drawable (* x 0.32) (* y 0.32) 0) )))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(define sffont "QTBookmann Bold")
(define sffont "QTBookmann-Bold"))
(define list-blend-dir '("Left to Right" "Top to Bottom" "Diagonal to centre" "Diagonal from centre"))
(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)
))
;
; Include layer Procedure
(define (include-layer image newlayer oldlayer stack) ;stack 0=above 1=below
(cond ((defined? 'gimp-image-get-item-position) ;test for 2.8 compatability
(gimp-image-insert-layer image newlayer (car (gimp-item-get-parent oldlayer))
(+ (car (gimp-image-get-item-position image oldlayer)) stack)) ;For GIMP 2.8
)
(else
(gimp-image-insert-layer image newlayer 0 (+ (car (gimp-image-get-item-position image oldlayer)) stack)) ;For GIMP 2.6
)
) ;end cond
) ;end add layer procedure
;
(define (script-fu-shiny-chrome-300-logo
text
justify
letter-spacing
line-spacing
font-in
font-size
shadow
bkg-type
pattern
bkg-color
gradient
gradient-type
reverse
blendir)
(gimp-context-push)
(gimp-context-set-paint-mode 0)
(gimp-context-set-foreground '(0 0 0))
(let* (
(width 0)
(height 0)
(offx 0)
(offy 0)
(image (car (gimp-image-new 50 50 RGB)))
(area (* 1000 1000))
(border (/ font-size 4))
(font font-in)
(text-layer (car (gimp-text-fontname image -1 0 0 text border TRUE font-size PIXELS font)))
(text-width (car (gimp-drawable-get-width text-layer)))
(text-height (car (gimp-drawable-get-height text-layer)))
(active-gradient (car (gimp-context-get-gradient)))
(active-fg (car (gimp-context-get-foreground)))
(active-bg (car (gimp-context-get-background)))
(bkg-layer 0)
(text-selection 0)
(justify (cond ((= justify 0) 2)
((= justify 1) 0)
((= justify 2) 1)))
(x1 0)
(y1 0)
(x2 0)
(y2 0)
(ver 2.8)
)
;(cond ((not (defined? 'gimp-image-get-item-position)) (set! ver 2.6))) ;define the gimp version
(gimp-context-set-paint-method "gimp-paintbrush")
; (if (defined? 'gimp-context-enable-dynamics) (gimp-context-enable-dynamics TRUE))
;(if (= ver 2.8) (gimp-context-set-dynamics "Pressure Opacity"))
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
;;;;adjust text
(gimp-text-layer-set-justification text-layer justify)
(gimp-text-layer-set-letter-spacing text-layer letter-spacing)
(gimp-text-layer-set-line-spacing text-layer line-spacing)
;;;;set the new width and height
(set! width (car (gimp-drawable-get-width text-layer)))
(set! height (car (gimp-drawable-get-height text-layer)))
(gimp-image-resize-to-layers image)
;;;;set the new Image size
(if (> text-width (car (gimp-image-get-width image))) (set! width text-width))
(if (> text-height (car (gimp-image-get-height image))) (set! height text-height))
;;;;resize the image
(gimp-image-resize image width height 0 0)
;;;;centre the text layer
(set! offx (/ (- width text-width) 2))
(set! offy (/ (- height text-height) 2))
(gimp-layer-set-offsets text-layer offx offy)
(gimp-image-resize-to-layers image)
;;;;start of script;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(gimp-image-undo-group-start image)
(script-fu-shiny-chrome-300 image text-layer
shadow
bkg-type
pattern
bkg-color
gradient
gradient-type
reverse
blendir)
;;;;end of script;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(gimp-context-pop)
(gimp-display-new image)
(gimp-image-undo-group-end image)
)
)
(script-fu-register "script-fu-shiny-chrome-300-logo"
"Shiny Chrome 300 Logo"
"Create an image with a text layer over a pattern layer"
"Graechan"
"Graechan - http://gimpchat.com"
"March 2015"
""
SF-TEXT "Text" "CHROME"
SF-OPTION "Justify" '("Centered" "Left" "Right")
SF-ADJUSTMENT "Letter Spacing" '(0 -100 100 1 5 0 0)
SF-ADJUSTMENT "Line Spacing" '(0 -100 100 1 5 0 0)
SF-FONT "Font" sffont
SF-ADJUSTMENT "Font size (pixels)" '(175 6 500 1 1 0 1)
SF-TOGGLE "Shadow" TRUE
SF-OPTION "Background Type" '("None" "Color" "Pattern" "Gradient" "Active Gradient")
SF-PATTERN "Pattern" "Pink Marble"
SF-COLOR "Background color" "Blue"
SF-GRADIENT "Background Gradient" "Abstract 3"
SF-ENUM "Gradient Fill Mode" '("GradientType" "gradient-linear")
SF-TOGGLE "Reverse the Gradient" FALSE
SF-OPTION "Blend Direction" list-blend-dir
)
(script-fu-menu-register "script-fu-shiny-chrome-300-logo" "<Image>/Script-Fu/Logos/")
;
(define (script-fu-shiny-chrome-300 image drawable
shadow
bkg-type
pattern
bkg-color
gradient
gradient-type
reverse
blendir)
(gimp-image-undo-group-start image)
(gimp-image-resize-to-layers image)
(let* (
(width (car (gimp-drawable-get-width drawable)))
(height (car (gimp-drawable-get-height drawable)))
(offx (car (gimp-drawable-get-offsets drawable)))
(offy (cadr (gimp-drawable-get-offsets drawable)))
(bkg-layer (car (gimp-layer-new image width height RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL-LEGACY)))
(chrome (car (gimp-layer-new image width height RGBA-IMAGE "Chrome" 100 LAYER-MODE-NORMAL-LEGACY)))
(alpha (car (gimp-drawable-has-alpha drawable)))
(no-sel (car (gimp-selection-is-empty image)))
(active-gradient (car (gimp-context-get-gradient)))
(active-fg (car (gimp-context-get-foreground)))
(active-bg (car (gimp-context-get-background)))
(chrome-copy 0)
(ver 2.8)
(x1 0)
(y1 0)
(x2 0)
(y2 0)
)
;(cond ((not (defined? 'gimp-image-get-item-position)) (set! ver 2.6))) ;define the gimp version
(gimp-context-push)
(gimp-context-set-paint-mode 0)
(gimp-context-set-paint-method "gimp-paintbrush")
;(if (defined? 'gimp-context-enable-dynamics) (gimp-context-enable-dynamics TRUE))
;(cond ((defined? 'gimp-context-set-dynamics) (gimp-context-set-dynamics "Pressure Opacity")))
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
(if (= alpha FALSE) (gimp-layer-add-alpha drawable))
;;;;check that a selection was made if not make one
(if (= no-sel TRUE) (begin
(cond ((= ver 2.8) (gimp-image-select-item image 2 drawable))
(else (gimp-selection-layer-alpha drawable))
) ;endcond
)
)
; samj Old code -> (gimp-image-set-active-layer image drawable)
; samj New code for gimp-2.99.12
; (gimp-image-set-selected-layers image 1 (vector drawable))
(cond ((defined? 'gimp-image-set-selected-layers) (gimp-image-set-selected-layers image (vector drawable)))
(else (gimp-image-set-active-layer image drawable))
)
;;;;begin the script
(include-layer image bkg-layer drawable 0) ;stack 0=above 1=below
(gimp-layer-set-offsets bkg-layer offx offy)
(gimp-drawable-fill bkg-layer FILL-FOREGROUND)
(gimp-drawable-edit-fill bkg-layer FILL-BACKGROUND)
(gimp-selection-none image)
(apply-gauss image bkg-layer 5 5)
;(gimp-image-select-color image 2 bkg-layer '(0 0 0) )
(gimp-image-select-item image 2 drawable)
; (gimp-selection-invert image)
(set! x1 (cadr (gimp-drawable-mask-bounds drawable))) ;x co-ord of upper left corner of selection of the specified drawable.
(set! y1 (caddr (gimp-drawable-mask-bounds drawable))) ;y co-ord of upper left corner of selection of the specified drawable.
(set! x2 (cadddr (gimp-drawable-mask-bounds drawable))) ;x co-ord of lower right corner of selection of the specified drawable.
(set! y2 (cadr (cdddr (gimp-drawable-mask-bounds drawable)))) ;y co-ord of lower right corner of selection of the specified drawable.
(include-layer image chrome bkg-layer 0) ;stack 0=above 1=below
(gimp-layer-set-offsets chrome offx offy)
(gimp-item-set-visible bkg-layer FALSE)
(gimp-context-set-foreground '(89 89 89))
(gimp-context-set-background '(185 185 185))
(gimp-context-set-gradient-fg-bg-rgb)
;(gimp-image-select-item image 2 drawable)
;(gimp-drawable-edit-gradient-fill chrome GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 3 0.2 TRUE (+ offx x1) (+ offy y2) (+ offx x1) (+ offy y1))
(gimp-drawable-edit-gradient-fill chrome GRADIENT-LINEAR 0 0 1 0 0 (+ offx x1) (+ offy y2) (+ offx x1) (+ offy y1))
(gimp-selection-none image)
(plug-in-bump-map RUN-NONINTERACTIVE image chrome bkg-layer 135 45 3 0 0 0 0 TRUE FALSE 0) ;{LINEAR(0),SPHERICAL(1),SINUSOIDAL(2)}
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(gimp-drawable-curves-spline chrome 0 12 #(0 0.34902 0.266667 0.882353 0.494118 0.376471 0.65098 0.886275 0.87451 0.152941 1 1))
(gimp-drawable-curves-spline chrome HISTOGRAM-VALUE #(0 0.34902 0.266667 0.882353 0.494118 0.376471 0.65098 0.886275 0.87451 0.152941 1 1) ) )
;(plug-in-alienmap2 1 image chrome 1 0 1 0 1 0 0 TRUE TRUE TRUE)
(gimp-drawable-levels-stretch chrome)
(gimp-image-remove-layer image bkg-layer)
(set! chrome-copy (car (gimp-layer-copy chrome TRUE)))
(include-layer image chrome-copy chrome 0) ;stack 0=above 1=below
(gimp-item-set-name chrome-copy "Chrome-Copy")
;(gimp-context-set-gradient "Sunrise")
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(gimp-context-set-gradient "Sunrise")
(gimp-context-set-gradient (car (gimp-gradient-get-by-name "Sunrise")))
)
;(plug-in-gradmap 1 image chrome-copy)
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(plug-in-gradmap 1 image chrome-copy)
(plug-in-gradmap 1 image (vector chrome-copy)) )
(gimp-layer-set-mode chrome-copy LAYER-MODE-BURN-LEGACY)
(set! chrome (car (gimp-image-merge-down image chrome-copy EXPAND-AS-NECESSARY)))
(if (= shadow TRUE) (apply-drop-shadow image chrome 3 3 10 '(0 0 0) 80 FALSE))
;;;;create the background layer
(let* (
(x1 0)
(y1 0)
(x2 0)
(y2 0)
)
(cond ((not (= bkg-type 0))
(set! bkg-layer (car (gimp-layer-new image width height RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL-LEGACY)))
(include-layer image bkg-layer drawable 1) ;stack 0=above 1=below
(gimp-layer-set-offsets bkg-layer offx offy)
)
) ;endcond
(gimp-context-set-pattern pattern)
(gimp-context-set-background bkg-color)
(gimp-context-set-gradient gradient)
(if (or (= bkg-type 3) (= bkg-type 4)) (begin
(gimp-context-set-foreground active-fg)
(gimp-context-set-background active-bg)))
(if (= bkg-type 4) (gimp-context-set-gradient active-gradient))
(if (= bkg-type 2) (gimp-drawable-fill bkg-layer FILL-PATTERN))
(if (= bkg-type 1) (gimp-drawable-fill bkg-layer FILL-BACKGROUND))
(if (or (= bkg-type 3) (= bkg-type 4))
(begin
(gimp-selection-none image)
(gimp-drawable-fill bkg-layer FILL-BACKGROUND)
(if (= blendir 0) (set! x2 width))
(if (= blendir 1) (set! y2 height))
(if (= blendir 2) (begin
(set! x2 (/ width 2))
(set! y2 (/ height 2))))
(if (= blendir 3) (begin
(set! x1 (/ width 2))
(set! y1 (/ height 2))))
;(gimp-drawable-edit-gradient-fill bkg-layer gradient-type 100 0 REPEAT-NONE reverse FALSE 3 0.2 TRUE x1 y1 x2 y2)
(gimp-context-set-gradient-reverse reverse)
(gimp-drawable-edit-gradient-fill bkg-layer gradient-type 0 0 1 0 0 x1 y1 x2 y2)
)
) ;endif
) ;endlet
(gimp-displays-flush)
(gimp-image-undo-group-end image)
(gimp-context-pop)
)
)
(script-fu-register "script-fu-shiny-chrome-300"
"Shiny Chrome 300 Alpha"
"Instructions"
"Graechan"
"Graechan - http://gimpchat.com"
"March 2015"
"RGB*"
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
SF-TOGGLE "Shadow" TRUE
SF-OPTION "Background Type" '("None" "Color" "Pattern" "Gradient" "Active Gradient")
SF-PATTERN "Pattern" "Pink Marble"
SF-COLOR "Background color" "Blue"
SF-GRADIENT "Background Gradient" "Abstract 3"
SF-ENUM "Gradient Fill Mode" '("GradientType" "gradient-linear")
SF-TOGGLE "Reverse the Gradient" FALSE
SF-OPTION "Blend Direction" list-blend-dir
)
(script-fu-menu-register "script-fu-shiny-chrome-300" "<Image>/Script-Fu/Alpha-to-Logo/")