-
Notifications
You must be signed in to change notification settings - Fork 0
/
210_iccii-raindrop.scm
345 lines (318 loc) · 13.8 KB
/
210_iccii-raindrop.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
;Modernized with ModernizeMatic8 for Gimp 2.10.28 by vitforlinux.wordpress.com - dont remove
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; Raindrop effect script for GIMP 1.2
; Copyright (C) 2001 Iccii <[email protected]>
;
; --------------------------------------------------------------------
; version 0.1 by Iccii 2001/01/30
; - Initial relase
; This is "FIXME" version, which is spaghetti program code
; version 0.2 by Iccii 2001/02/09
; - Add to offset in highlight option
; version 0.2a by Iccii 2001/02/23
; - Sorry, I had some mistakes, now fixed
; version 0.2b by Iccii 2001/02/24
; - Highlight offset is set by persent instead of pixel
; version 0.3 by Iccii 2001/03/27
; - Add the reflect-width setting
; - Use Pattern as background
; - Clean up code and more proofing
; version 0.3a by Iccii 2001/03/30
; - Make better (speed up)
; version 0.3b by Iccii 2001/04/02
; - Make better (cleanup code)
; version 0.3c by Iccii 2001/04/10
; - Fix the layer mask problem (Thanks, Kajiyama)
; version 0.3d by Iccii 2001/05/25
; - A bit better
; version 0.3e by Iccii 2001/06/21
; - Minor fix
; version 0.3f by Iccii 2001/07/01
; - bug fix (if image size doesn't equal to drawable size in alpha-logo)
; version 299 for gimp 2.10 and 2.99.19 - AUG 2024 - vitforlinux
;
; --------------------------------------------------------------------
;
; 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.
;
; 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-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-raindrop-logo-effect20
img ; IMAGE
logo-layer ; DRAWABLE (レイヤー)
text-color ; 水玉の色
light ; 光の方向 (0-360度)
blur ; シャドゥ、ハイライトのぼかし半径
hi-width ; ハイライト幅 (%)
hi-offset ; ハイライトのオフセット (%)
hi-option ; ハイライト作成法オプション
sh-offset ; シャドゥのオフセット
reflect-width ; 表面反射のバンド幅
antialias ; アンチエイリアスの有効/無効
)
(let* (
(layer-color 0) ;2.4追加
(mask-color 0) ;2.4追加
(logo-selection 0) ;2.4追加
(old-bg 0) ;2.4追加
(logo-layer-blur 0) ;2.4追加
(hilight-width 0) ;2.4追加
(hi-xoffset 0) ;2.4追加
(hi-yoffset 0) ;2.4追加
(mask-hilight2 0) ;2.4追加
)
; 前処理
(set! layer-color (car (gimp-layer-copy logo-layer TRUE)))
(gimp-image-insert-layer img layer-color 0 -1)
(gimp-item-set-name layer-color "Color adjust")
(set! mask-color (car (gimp-layer-create-mask layer-color 5)))
(gimp-layer-add-mask layer-color mask-color)
(gimp-layer-set-lock-alpha logo-layer FALSE)
(gimp-image-select-item img 2 logo-layer)
(gimp-selection-grow img reflect-width)
(gimp-drawable-edit-fill logo-layer FILL-WHITE)
(if (eqv? antialias TRUE)
(gimp-selection-feather img (/ blur 5)))
(set! logo-selection (car (gimp-selection-save img)))
(gimp-selection-invert img)
(set! old-bg (car (gimp-context-get-background)))
(gimp-context-set-background '(0 0 0))
(gimp-drawable-edit-fill logo-layer FILL-BACKGROUND)
(gimp-context-set-background old-bg)
(gimp-selection-none img)
(set! logo-layer-blur (car (gimp-layer-copy logo-layer TRUE)))
(gimp-image-insert-layer img logo-layer-blur 0 -1)
(plug-in-gauss-iir2 1 img logo-layer-blur blur blur)
; 処理の本体部分
(let* ((old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background)))
(radians (/ (* 2 *pi* light) 360))
(sh-xoffset (* sh-offset (cos radians)))
(sh-yoffset (* sh-offset (sin radians)))
(layer-value (car (gimp-layer-copy logo-layer TRUE)))
(layer-hilight (car (gimp-layer-copy logo-layer TRUE)))
(layer-hilight-inn (car (gimp-layer-copy logo-layer-blur TRUE)))
(layer-shadow (car (gimp-layer-copy logo-layer-blur TRUE)))
(layer-shadow-inn (car (gimp-layer-copy logo-layer-blur TRUE)))
(mask-hilight (car (gimp-layer-create-mask layer-hilight 5)))
(mask-hilight-inn (car (gimp-layer-create-mask layer-hilight-inn ADD-MASK-BLACK)))
(mask-shadow (car (gimp-layer-create-mask layer-shadow ADD-MASK-BLACK)))
(mask-shadow-inn (car (gimp-layer-create-mask layer-shadow-inn ADD-MASK-BLACK))))
; 各レイヤーの準備
(gimp-item-set-name layer-value "Value layer")
(gimp-item-set-name layer-hilight "Highlight layer")
(gimp-item-set-name layer-hilight-inn "Highlight inner")
(gimp-item-set-name layer-shadow "Drop shadow")
(gimp-item-set-name layer-shadow-inn "Inner shadow")
(gimp-image-insert-layer img layer-shadow-inn 0 -1)
(gimp-image-insert-layer img layer-shadow 0 -1)
(gimp-image-insert-layer img layer-hilight-inn 0 -1)
(gimp-image-insert-layer img layer-hilight 0 -1)
(gimp-image-insert-layer img layer-value 0 -1)
; レイヤーマスクを追加する
(gimp-layer-add-mask layer-hilight mask-hilight)
(gimp-layer-add-mask layer-hilight-inn mask-hilight-inn)
(gimp-layer-add-mask layer-shadow mask-shadow)
(gimp-layer-add-mask layer-shadow-inn mask-shadow-inn)
(gimp-image-select-item img 2 logo-selection)
(gimp-drawable-edit-fill mask-hilight-inn FILL-WHITE)
(gimp-drawable-edit-fill mask-shadow FILL-WHITE)
(gimp-drawable-edit-fill mask-shadow-inn FILL-WHITE)
(gimp-selection-none img)
; 色反転、色付け、レイヤーモードの変更、ずらしを行う
(gimp-drawable-invert layer-hilight-inn TRUE)
(gimp-drawable-invert mask-shadow TRUE)
(gimp-context-set-foreground text-color)
(gimp-drawable-fill layer-color FILL-FOREGROUND)
(gimp-layer-set-mode layer-value LAYER-MODE-ADDITION-LEGACY)
(gimp-layer-set-mode layer-hilight LAYER-MODE-SCREEN-LEGACY)
(gimp-layer-set-mode layer-hilight-inn LAYER-MODE-SCREEN-LEGACY)
(gimp-layer-set-mode layer-shadow LAYER-MODE-SUBTRACT-LEGACY)
(gimp-layer-set-mode layer-shadow-inn LAYER-MODE-MULTIPLY-LEGACY)
(gimp-layer-set-mode layer-color LAYER-MODE-NORMAL-LEGACY)
(gimp-drawable-offset layer-hilight-inn FALSE OFFSET-BACKGROUND (- sh-xoffset) (- sh-yoffset))
(gimp-drawable-offset layer-shadow FALSE OFFSET-TRANSPARENT sh-xoffset sh-yoffset)
(gimp-drawable-offset layer-shadow-inn FALSE OFFSET-BACKGROUND sh-xoffset sh-yoffset)
; ハイライトレイヤーの処理
(gimp-image-select-item img 2 mask-hilight)
(gimp-selection-sharpen img)
(set! hilight-width 0)
(while (eqv? (car (gimp-selection-is-empty img)) FALSE)
(gimp-selection-shrink img 1)
(set! hilight-width (+ hilight-width 1)))
(gimp-selection-none img)
(set! hi-xoffset (- (/ (* (* hi-offset (cos radians)) hilight-width) 100)))
(set! hi-yoffset (- (/ (* (* hi-offset (sin radians)) hilight-width) 100)))
(gimp-drawable-offset layer-hilight FALSE OFFSET-BACKGROUND hi-xoffset hi-yoffset)
(gimp-drawable-offset mask-hilight FALSE OFFSET-BACKGROUND hi-xoffset hi-yoffset)
(cond
((eqv? hi-option 0) ; 縮めるとき
(begin
(gimp-image-select-item img 2 mask-hilight)
(gimp-selection-invert img)
(gimp-selection-grow img (/ (* hilight-width (- 100 hi-width)) 100))
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill layer-hilight FILL-FOREGROUND)
(gimp-selection-none img)
(plug-in-gauss-iir2 1 img layer-hilight (* 0.8 blur) (* 0.8 blur))
(gimp-layer-remove-mask layer-hilight MASK-APPLY)))
((eqv? hi-option 1) ; オフセットのとき...さらなる改良が必要
(begin
(gimp-drawable-offset layer-hilight FALSE OFFSET-BACKGROUND
(* (/ (* hilight-width (- 100 hi-width)) 100) (- (cos radians)))
(* (/ (* hilight-width (- 100 hi-width)) 100) (- (sin radians))))
(gimp-drawable-offset mask-hilight FALSE OFFSET-BACKGROUND
(* (/ (* hilight-width (- 100 hi-width)) 100) (cos radians))
(* (/ (* hilight-width (- 100 hi-width)) 100) (sin radians)))
(gimp-layer-remove-mask layer-hilight MASK-APPLY)
(plug-in-gauss-iir2 1 img layer-hilight (* 0.8 blur) (* 0.8 blur)))))
(set! mask-hilight2 (car (gimp-layer-create-mask logo-layer ADD-MASK-BLACK)))
(gimp-layer-add-mask layer-hilight mask-hilight2)
(gimp-image-select-item img 2 logo-selection)
(gimp-drawable-edit-fill mask-hilight2 FILL-WHITE)
(gimp-selection-none img)
; 最後の調整
(gimp-selection-none img)
(gimp-layer-set-opacity layer-value 15)
(gimp-layer-set-opacity layer-hilight 90)
(gimp-layer-set-opacity layer-hilight-inn 90)
(gimp-layer-set-opacity layer-shadow 80)
(gimp-layer-set-opacity layer-shadow-inn 80)
; 終わり
(gimp-image-remove-layer img logo-layer)
(gimp-image-remove-layer img logo-layer-blur)
(gimp-image-remove-channel img logo-selection)
(gimp-image-set-active-layer img layer-value)
(gimp-context-set-background old-bg)
(gimp-context-set-foreground old-fg)
) ;2.4追加
))
; 透明度をロゴに
(define (script-fu-raindrop-logo-alpha
img
text-layer
text-color
light
blur
hi-width
hi-offset
hi-option
sh-offset
reflect-width
antialias)
(let* ((width (car (gimp-drawable-get-width text-layer)))
(height (car (gimp-drawable-get-height text-layer)))
(bg-layer (car (gimp-layer-new img (+ width (* 4 sh-offset)) (+ height (* 4 sh-offset)) RGBA-IMAGE "BG layer" 100 LAYER-MODE-NORMAL-LEGACY))))
(gimp-image-undo-group-start img)
(gimp-image-resize img (+ width (* 4 sh-offset)) (+ height (* 4 sh-offset)) (* sh-offset 2) (* sh-offset 2)) ;changed
(gimp-layer-resize text-layer (+ width (* 4 sh-offset)) (+ height (* 4 sh-offset)) (* sh-offset 2) (* sh-offset 2)) ;add
(if (< 0 (car (gimp-layer-get-mask text-layer)))
(begin
(gimp-layer-remove-mask text-layer MASK-APPLY)
(gimp-displays-flush) )) ; why I need this call?
(gimp-layer-set-lock-alpha text-layer TRUE)
(gimp-selection-none img)
(gimp-drawable-edit-fill text-layer 2)
(apply-raindrop-logo-effect20 img text-layer
text-color light blur hi-width hi-offset hi-option sh-offset reflect-width antialias)
(gimp-image-undo-group-end img)
(gimp-displays-flush)))
(script-fu-register
"script-fu-raindrop-logo-alpha"
_"/Rain drop ALPHA..."
"Creates a logo like a raindrop"
"Iccii <[email protected]>"
"Iccii"
"Mar, 2001"
"RGBA"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-COLOR _"Base Color" '(0 63 255)
SF-ADJUSTMENT "lighting angle" '(45 0 360 1 10 0 0)
SF-ADJUSTMENT "blur radius" '(10 1 50 1 5 0 0)
SF-ADJUSTMENT "higlight width (%)" '(30 0 100 1 5 0 0)
SF-ADJUSTMENT "higlight offset (%)" '(40 0 100 1 5 0 0)
SF-OPTION "higlight option" '(_"shrink" _"staggering")
SF-ADJUSTMENT "shadow offset" '(5 0 50 1 5 0 1)
SF-ADJUSTMENT _"reflections width" '(5 0 50 1 5 0 1)
SF-TOGGLE _"antialias" FALSE)
(script-fu-menu-register "script-fu-raindrop-logo-alpha"
"<Image>/Script-Fu/AlphaToLogo")
; ロゴ作成
(define (script-fu-raindrop-logo
text
font-size
fontname
text-color
pattern
light
blur
hi-width
hi-offset
hi-option
sh-offset
reflect-width
antialias)
(let* ((img (car (gimp-image-new 256 256 RGB)))
(text-layer (car (gimp-text-fontname img -1 0 0
text (+ 20 reflect-width) TRUE font-size PIXELS fontname)))
(width (car (gimp-drawable-get-width text-layer)))
(height (car (gimp-drawable-get-height text-layer)))
(bg-layer (car (gimp-layer-new img (+ width sh-offset) (+ height sh-offset) RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL-LEGACY)))
(old-pattern (car (gimp-context-get-pattern))))
(gimp-image-undo-disable img)
(gimp-image-resize img (+ width sh-offset) (+ height sh-offset) 0 0) ;changed
(gimp-layer-resize text-layer (+ width sh-offset) (+ height sh-offset) 0 0) ;add
(gimp-layer-set-lock-alpha text-layer TRUE)
(gimp-drawable-edit-fill text-layer FILL-WHITE)
(gimp-image-insert-layer img bg-layer 0 -1)
(gimp-selection-all img)
(gimp-context-set-pattern pattern)
(gimp-drawable-edit-fill bg-layer FILL-PATTERN)
(gimp-selection-none img)
(apply-raindrop-logo-effect20 img text-layer
text-color light blur hi-width hi-offset hi-option sh-offset reflect-width antialias)
(gimp-context-set-pattern old-pattern)
(gimp-image-undo-enable img)
(gimp-display-new img)
(gimp-displays-flush)))
(script-fu-register
"script-fu-raindrop-logo"
_"Rain drop TEXT..."
"Create a raindrop like logo"
"Iccii <[email protected]>"
"Iccii"
"Jun, 2001"
""
SF-TEXT _"Text" "Rain Drop"
SF-ADJUSTMENT _"Font size (px)" '(150 2 1000 1 10 0 1)
SF-FONT _"Font" "Slogan"
SF-COLOR _"Font Color" '(0 127 255)
SF-PATTERN _"Background Pattern" "Pine?"
SF-ADJUSTMENT _"Lighting angle" '(45 0 360 1 10 0 0)
SF-ADJUSTMENT _"Blur radius" '(10 1 50 1 5 0 0)
SF-ADJUSTMENT _"Higlight width (%)" '(30 0 100 1 5 0 0)
SF-ADJUSTMENT _"Higlight offset (%)" '(40 0 100 1 5 0 0)
SF-OPTION "Higlight option" '(_"reduction" _"displace")
SF-ADJUSTMENT _"Shadow offset" '(5 0 50 1 5 0 1)
SF-ADJUSTMENT _"Reflections width" '(5 0 50 1 5 0 1)
SF-TOGGLE _"Antialias" FALSE)
(script-fu-menu-register "script-fu-raindrop-logo"
"<Image>/File/Create/Logos")