-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathegg-melt.scm
342 lines (302 loc) · 13.7 KB
/
egg-melt.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
;Modernized with ModernizeMatic8 for Gimp 2.10.28 by vitforlinux.wordpress.com - dont remove
; 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)))
(cond ((not (defined? 'gimp-image-set-active-layer)) (define (gimp-image-set-active-layer image drawable) (gimp-image-set-selected-layers image (vector drawable)))))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(define sffont "QTVagaRound Bold")
(define sffont "QTVagaRound-Bold"))
(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) )))
(define (script-fu-egg-shine image drawable
shadow-size
shadow-opacity
keep-selection-in
conserve)
(let* (
;(image-layer (car (gimp-image-get-active-layer image)))
(image-layer (if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(car (gimp-image-get-active-layer image))
(car (list (vector-ref (car (gimp-image-get-selected-layers image)) 0)))))
(width (car (gimp-image-get-width image)))
(height (car (gimp-image-get-height image)))
(sel (car (gimp-selection-is-empty image)))
(alpha (car (gimp-drawable-has-alpha image-layer)))
(keep-selection keep-selection-in)
(layer-name (car (gimp-item-get-name image-layer)))
(img-layer 0)
(img-channel 0)
(bkg-layer 0)
(shadow-layer 0)
(tmp-layer 0)
)
(gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
(if (= alpha FALSE) (gimp-layer-add-alpha image-layer))
(if (= sel TRUE) (set! keep-selection FALSE))
(if (= sel TRUE) (gimp-image-select-item image 2 image-layer))
(set! img-layer (car (gimp-layer-new image width height RGBA-IMAGE "img-layer" 100 LAYER-MODE-NORMAL-LEGACY)))
(gimp-image-insert-layer image img-layer 0 -1)
(gimp-drawable-fill img-layer FILL-BACKGROUND)
(gimp-drawable-edit-fill img-layer FILL-FOREGROUND)
;;;;create channel
(gimp-selection-save image)
; (set! img-channel (car (gimp-image-get-active-drawable image)))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(set! img-channel (car (gimp-image-get-active-drawable image)))
(set! img-channel (vector-ref (car (gimp-image-get-selected-drawables image)) 0)) )
(gimp-channel-set-opacity img-channel 100)
(gimp-item-set-name img-channel "img-channel")
(gimp-image-set-active-layer image img-layer)
(gimp-item-set-name image-layer "Original Image")
;;;;create the background layer
(set! bkg-layer (car (gimp-layer-new image width height RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL-LEGACY)))
(gimp-image-insert-layer image bkg-layer 0 1)
;;;;apply the image effects
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
(apply-gauss image img-layer 12 12)
(plug-in-emboss RUN-NONINTERACTIVE image img-layer 225 84 10 TRUE)
(gimp-selection-invert image)
(gimp-drawable-edit-clear img-layer)
(gimp-selection-invert image)
(plug-in-colortoalpha RUN-NONINTERACTIVE image img-layer '(254 254 254));;fefefe
(apply-gauss image img-channel 15 15)
;(plug-in-blur RUN-NONINTERACTIVE image img-layer)
(apply-gauss image img-layer 2 2)
(gimp-image-set-active-layer image bkg-layer)
(plug-in-displace RUN-NONINTERACTIVE image bkg-layer 8 8 TRUE TRUE img-channel img-channel 1)
(gimp-image-remove-layer image bkg-layer)
;;;;create the shadow
(if (> shadow-size 0)
(begin
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(script-fu-drop-shadow image img-layer shadow-size shadow-size shadow-size '(0 0 0) shadow-opacity FALSE)
(script-fu-drop-shadow image (vector img-layer) shadow-size shadow-size shadow-size '(0 0 0) shadow-opacity FALSE))
(set! tmp-layer (car (gimp-layer-new image width height RGBA-IMAGE "temp" 100 LAYER-MODE-NORMAL-LEGACY)))
(gimp-image-insert-layer image tmp-layer 0 -1)
(gimp-image-raise-item image tmp-layer)
(gimp-image-merge-down image tmp-layer CLIP-TO-IMAGE)
;(set! shadow-layer (car (gimp-image-get-active-drawable image)))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(set! shadow-layer (car (gimp-image-get-active-drawable image)))
(set! shadow-layer (vector-ref (car (gimp-image-get-selected-drawables image)) 0)) )
(gimp-image-lower-item image shadow-layer)
)
)
(if (= conserve FALSE)
(begin
(set! img-layer (car (gimp-image-merge-down image img-layer EXPAND-AS-NECESSARY)))
(if (> shadow-size 0) (set! img-layer (car (gimp-image-merge-down image img-layer EXPAND-AS-NECESSARY))))
(gimp-item-set-name img-layer layer-name)
)
)
(if (= keep-selection FALSE) (gimp-selection-none image))
(gimp-image-remove-channel image img-channel)
(if (and (= conserve FALSE) (= alpha FALSE) (gimp-layer-flatten img-layer)))
(gimp-image-undo-group-end image)
(gimp-context-pop)
;(gimp-display-new image)
(gimp-displays-flush)
)
)
(script-fu-register
"script-fu-egg-melt-text" ;function name
"Egg Melt" ;menu label
"Create an upside down egg effect on a tablecloth" ;description
"Vitforlinux" ;author
"copyright 1997, Michael Terry;\
2009, the GIMP Documentation Team" ;copyright notice
"October 10, 2023" ;date created
"" ;image type that the script works on
SF-TEXT "Text" "Egg\nMelt" ;a string variable
SF-FONT "Font" sffont ;a font variable
SF-ADJUSTMENT "Font size" '(150 1 1000 1 10 0 0)
SF-COLOR "Color" '(255 152 0) ;color variable
SF-COLOR "Color2" '(255 255 255) ;color variable
SF-OPTION _"Text Justification" '("Centered" "Left" "Right" "Fill")
SF-ADJUSTMENT "Letter Spacing" '(0 -100 100 1 5 0 0)
SF-ADJUSTMENT "Line Spacing" '(0 -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)
;a spin-button
SF-TOGGLE "Text deformation" FALSE
SF-COLOR "BG Color" '(255 0 0) ;color variable
SF-COLOR "BG Color 2" '(255 255 255) ;color variable
SF-ADJUSTMENT "Buffer amount" '(35 0 100 1 10 1 0)
;a slider
SF-TOGGLE "Merge Layers" TRUE
)
(script-fu-menu-register "script-fu-egg-melt-text" "<Image>/File/Create/Text")
(define (script-fu-egg-melt-text inText inFont inFontSize inTextColor inTextColor2
justification
letter-spacing
line-spacing
grow-text
outline
deform
bg-color
bg-color2
inBufferAmount
conserve)
(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
"Background"
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-image-insert-layer theImage theLayer 0 0)
(gimp-context-set-background '(255 255 255) )
(gimp-context-set-foreground inTextColor)
(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)
))
)
;(gimp-context-push)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY )
(define bord1Layer (car(gimp-layer-new theImage 10 10 RGBA-IMAGE _"Bord 1 Layer" 100 LAYER-MODE-NORMAL-LEGACY)) )
(gimp-image-insert-layer theImage bord1Layer 0 1)
;; text alignment
(gimp-text-layer-set-justification theText justification) ; Text Justification (Rev Value)
(gimp-text-layer-set-letter-spacing theText letter-spacing) ; Set Letter Spacing
(gimp-text-layer-set-line-spacing theText line-spacing) ; Set Line Spacing
(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-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)
(gimp-layer-resize-to-image-size theText)
;;;; shrink grow text
(cond ((> grow-text 0)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-selection-grow theImage (round grow-text))
(gimp-context-set-foreground inTextColor)
(gimp-drawable-edit-fill theText FILL-FOREGROUND)
)
((< grow-text 0)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-drawable-edit-clear theText)
(gimp-selection-shrink theImage (- grow-text))
(gimp-context-set-foreground inTextColor)
(gimp-drawable-edit-fill theText FILL-FOREGROUND)
))
;;; outline
(cond ((> outline 0)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-selection-shrink theImage (round outline))
(gimp-drawable-edit-clear theText)
(gimp-image-select-item theImage 2 theText)
))
; (gimp-image-resize-to-layers theImage theImage)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
;(gimp-selection-invert theImage)
(gimp-selection-grow theImage (round (/ inFontSize 5)))
(gimp-selection-flood theImage)
;(gimp-image-select-item theImage 1 theText)
(gimp-layer-resize-to-image-size bord1Layer)
(gimp-context-set-foreground inTextColor2 )
(gimp-drawable-edit-fill bord1Layer FILL-FOREGROUND)
;;; background
(gimp-selection-none theImage)
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(gimp-context-set-gradient (list-ref (cadr (gimp-gradients-get-list "")) 1))
(gimp-context-set-gradient (car (gimp-gradient-get-by-name (list-ref (car (gimp-gradients-get-list "")) 4))) ) )
(gimp-context-set-background bg-color2)
(gimp-context-set-foreground bg-color )
(gimp-context-set-gradient-repeat-mode REPEAT-SAWTOOTH)
(gimp-drawable-edit-gradient-fill theLayer 0 0 TRUE 1 0 TRUE 0 0 0 (round (/ inFontSize 3)))
(gimp-context-set-paint-mode LAYER-MODE-GRAIN-MERGE )
(gimp-drawable-edit-gradient-fill theLayer 0 0 TRUE 1 0 TRUE 0 0 (round (/ inFontSize 3)) 0)
;(gimp-context-pop)
; (gimp-display-new theImage)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY )
; (plug-in-ripple 1 theImage theText 75 5 0 0 1 TRUE FALSE)
(if (= deform TRUE) (plug-in-ripple 1 theImage theText 75 5 1 0 1 TRUE FALSE))
(script-fu-egg-shine theImage theText
(round (/ inFontSize 5))
0
FALSE ;keep-selection-in
FALSE) ;conserve
;(script-fu-shine299 1 theImage theText 0 0 7 1)
(gimp-selection-none theImage)
(gimp-context-set-paint-mode LAYER-MODE-NORMAL-LEGACY )
(gimp-image-set-active-layer theImage bord1Layer)
;(plug-in-ripple 1 theImage bord1Layer 100 5 0 0 1 TRUE FALSE)
(if (= deform TRUE) (plug-in-ripple 1 theImage bord1Layer 100 5 1 0 1 TRUE FALSE))
(script-fu-egg-shine theImage bord1Layer
(round (/ inFontSize 30))
20
FALSE ;keep-selection-in
FALSE) ;conserve
;(plug-in-weaves 1 theImage bord1Layer 0.5 0.5 7 100 0 1 FALSE )
;(script-fu-shine299 1 theImage bord1Layer 0 0 7 1)
(if (= conserve TRUE) (gimp-image-flatten theImage))
(gimp-context-pop)
(gimp-display-new theImage)
(list theImage theLayer theText)
)
)