-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDIEGO_Glass-frame-effect_02c.scm
715 lines (660 loc) · 27.8 KB
/
DIEGO_Glass-frame-effect_02c.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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
; This script takes origin from the Gimp-chat topic KDE4/Aero Blur Effect.
; The main and simple purpose of this script is:
; - let the user perform his/her selection(s) (if not, a default selection is applied by the script)
; - create on the remaining part of the image a glass effect, with different glass aspects
; - leave selection(s) untouched, so that they look like through "holes" in the glass
;
; Flow implemented to get the final result:
;
; 1. check whether the user did a selection: if not make one (a rounded rectangle)
; 2. duplicate the input layer
; 3. apply the chosen effect on the non-selected part of the image
; 4. duplicate again the original layer
; 5. apply on the non-selected part of the image a colour derived from the average (RobA script)
; 6. apply a bevelling effect (if so chosen by the user)
; 7. flatten the image (if so chosen by the user)
; ------------------------------------------------------------------
; current version: 1.1 no more dependency on Layer-fx python plug-in
; thanks to Graechan - October 5, 2014
; ------------------------------------------------------------------
;
; 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.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, you can view the GNU General Public
; License version 3 at the web site http://www.gnu.org/licenses/gpl-3.0.html
; Alternatively you can write to the Free Software Foundation, Inc., 675 Mass
; Ave, Cambridge, MA 02139, USA.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; edited to remove dependancy on python-layerfx-bevel-emboss 3-10-2014 by Graechan
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (script-fu-glass-frame-effect
theOldImage
theOldLayer
GlassEffect
doBevelEmboss
doFlatten
)
; Initialize an undo, so the process can be undone with a single undo
(gimp-image-undo-group-start theOldImage)
; Variable init
(let* (
(imageWidth (car (gimp-image-width theOldImage)))
(imageHeight (car (gimp-image-height theOldImage)))
(theDuplicatedLayer 0)
(theNewLayer 0)
(theTopLayer 0)
(theMergedLayer 0)
(theConteLayer 0)
(theConteOut 0)
(OldLayerPosition 0)
(selectionWidth 0)
(selectionHeight 0)
(cornerRadiusX 0)
(cornerRadiusY 0)
(no-sel 0) ;selection Flag
(sel-x1 0)
(sel-y1 0)
(sel-x2 0)
(sel-y2 0)
(selectionWidth 0)
(selectionHeight 0)
(avg-colour 0)
(bevelDepth 0)
(bevelSize 0)
)
(gimp-message-set-handler 2)
; check whether there is a selection, if not a selection is forced (the central part)
(gimp-message "check selection")
(set! no-sel (car (gimp-selection-is-empty theOldImage)))
(if (= no-sel TRUE)
(begin
(set! selectionWidth (/ (* imageWidth 8) 10))
(set! selectionHeight (/ (* imageHeight 8) 10))
(set! cornerRadiusX (/ imageWidth 20))
(set! cornerRadiusY (/ imageHeight 20))
(gimp-image-select-round-rectangle theOldImage CHANNEL-OP-REPLACE
(/ (- imageWidth selectionWidth) 2)
(/ (- imageHeight selectionHeight) 2)
selectionWidth selectionHeight
cornerRadiusX cornerRadiusY)
)
(begin ; there is a selection
; save dimensions and position of the selecion
(set! sel-x1 (cadr (gimp-selection-bounds theOldImage)))
(set! sel-y1 (caddr (gimp-selection-bounds theOldImage)))
(set! sel-x2 (cadddr (gimp-selection-bounds theOldImage)))
(set! sel-y2 (car (cddddr (gimp-selection-bounds theOldImage))))
(set! selectionWidth (- sel-x2 sel-x1))
(set! selectionHeight (- sel-y2 sel-y1))
)
)
(gimp-selection-invert theOldImage)
(set! theDuplicatedLayer (car (gimp-layer-new-from-drawable theOldLayer theOldImage )))
(gimp-image-insert-layer theOldImage theDuplicatedLayer 0 0)
(gimp-item-set-name theDuplicatedLayer "Frame Layer")
(gimp-layer-add-alpha theDuplicatedLayer)
(gimp-message "choosen effect: ")
(gimp-message (number->string GlassEffect))
(if (= GlassEffect 0) ; GlassTile+Blur
(begin
(plug-in-glasstile 1 theOldImage theDuplicatedLayer 50 50)
(plug-in-gauss 1 theOldImage theDuplicatedLayer
(/ imageWidth 200) (/ imageHeight 200) 0 )
)
)
(if (= GlassEffect 1) ; Cartoons+Luce
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-cartoon 3,100,20"
)
)
)
)
(if (= GlassEffect 2) ; Textured Glass (G'MIC)
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-fx_textured_glass 40,40,1,1,0,2,0"
)
)
)
)
(if (= GlassEffect 3) ; Fractalize
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-fractalize "
)
)
)
)
(if (= GlassEffect 4) ; Gradient Flare
(begin
(plug-in-gflare 1 theOldImage theDuplicatedLayer "Distant_Sun"
(+ (/ selectionWidth 2) sel-x1) (+ (/ selectionHeight 2) sel-y1) (/ imageWidth 2)
0 0 30 1000 0 3 0.20)
(plug-in-nova 1 theOldImage theDuplicatedLayer
(+ (/ selectionWidth 2) sel-x1) (+ (/ selectionHeight 2) sel-y1)
'(200 200 0)100 1024 360)
)
)
(if (= GlassEffect 5) ; Polygonize
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-polygonize 300,10,10,10,10"
)
)
)
)
(if (= GlassEffect 6) ; Stained Glass
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-fx_stained_glass 35.5,0.10,1,0,1.20,0,1.25,25" ; was 100,0.10,1,0,1.20,0,1.25,25
)
)
)
)
(if (= GlassEffect 7) ; Psychedelic Glass
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-fx_psyglass 0,90,0.10,1,0,3,0.9,1,1,0,1,0,0,0,0,0"
)
)
)
)
(if (= GlassEffect 8) ; Etching
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-fx_gcd_etch 125,153,171,185,0.1,50,80,50,10,15,12,20,0,1,0.3,1,0"
)
)
)
)
(if (= GlassEffect 9) ; Charcoal
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-fx_charcoal 145,70,170,1,1,1,128,128,255,255,255,0,0,0,0"
)
)
)
)
(if (= GlassEffect 10) ; Colored Pencil
(begin
(plug-in-gmic-qt 1 theOldImage theDuplicatedLayer 1 0 ; 1=input only active layer
(string-append
"-v - " ; silent output. Remove it to display errors from the G'MIC interpreter on stderr.
"-fx_cpencil 0.30,10,24,0,0,0.80"
)
)
)
)
(gimp-selection-invert theOldImage) ; user selection restored
(set! theNewLayer (car (gimp-layer-new-from-drawable theOldLayer theOldImage )))
(gimp-image-insert-layer theOldImage theNewLayer 0 0)
(gimp-item-set-name theNewLayer "Glass Layer")
(gimp-layer-add-alpha theNewLayer)
(gimp-edit-cut theNewLayer) ; keep only the outside part of the image
(gimp-selection-invert theOldImage) ; glass only on outside part
;;;; use of average colour -----------------------------------------------------
(gfe_sample_avg_colour theOldImage theNewLayer 0 1)
(set! avg-colour (car (gimp-context-get-foreground)))
(gimp-edit-fill theNewLayer FILL-FOREGROUND)
(gimp-hue-saturation theNewLayer 0 0 0 100)
;;;; end average colour -----------------------------------------------------
(gimp-layer-set-mode theNewLayer LAYER-MODE-OVERLAY)
(gimp-layer-set-opacity theNewLayer 90)
(if (= doBevelEmboss TRUE)
(begin
;(gimp-message "you selected Bevel")
(set! theTopLayer (car (gimp-layer-new-from-drawable theOldLayer theOldImage )))
(set! bevelDepth (/ imageWidth 50))
(if (> bevelDepth 64) ; added check to prevent plug-in error
(set! bevelDepth 64)
)
(set! bevelSize (/ imageWidth 100))
(gimp-image-insert-layer theOldImage theTopLayer 0 0)
(gimp-item-set-name theTopLayer "Emboss Layer")
(gimp-layer-add-alpha theTopLayer)
(gimp-edit-cut theTopLayer)
(gfe-layerfx-bevel-emboss theOldImage theTopLayer
1 ;Style
bevelDepth ;Depth
1 ;Direction
bevelSize ;Size
2 ;Soften
120 ;Angle
30 ;Altitude
0 ;Gloss Contour
'(223 255 239) ;Highlight Color
11 ;Highlight Mode
100 ;Highlight Opacity
'(04 16 8) ;Shadow Color
11 ;Shadow Mode
100 ;Shadow Opacity
0 ;Surface Contour
FALSE ;Invert
FALSE) ;Merge with layer
(gimp-item-set-visible theTopLayer FALSE)
)
(gimp-message "you did not select Bevel")
)
(gimp-message (number->string theDuplicatedLayer))
(gimp-message (number->string theNewLayer))
(gimp-message (number->string selectionWidth))
(gimp-message (number->string selectionHeight))
(gimp-message "near end")
(if (= doFlatten TRUE)
(begin
(gimp-image-flatten theOldImage)
)
) ;endif
(if (= no-sel TRUE)
' (begin
(gimp-selection-none theOldImage)
) ;delete the created selection
(begin
(gimp-selection-invert theOldImage)) ;present the original selection
) ;endif
(gimp-message "Done!")
;Ensure the updated image is displayed now
(gimp-displays-flush)
(gimp-image-undo-group-end theOldImage)
) ; end let*
) ; end define
(script-fu-register "script-fu-glass-frame-effect"
"<Image>/Script-Fu/Frames/Creates a glass frame around an image-v.1.1"
"Creates a frame around an image with a simple or sophisticated glass effect-v.1.1 \nfile:DIEGO_Glass-frame-effect_02c.scm"
"Diego Nassetti"
"Diego Nassetti"
"September 2014"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-OPTION "Effect on Glass Layer"
'(
"GlassTile&Blur"
"Cartoons"
"Textured Glass"
"Fractalize (random)"
"Gradient Flare"
"Polygonize"
"Stained Glass"
"Psychedelic Glass"
"Etching"
"Charcoal"
"Coloured Pencil"
)
SF-TOGGLE "Bevel/Emboss Selections" TRUE
SF-TOGGLE "Flatten Image" FALSE
)
;-----------------------------------------------------------------------------------------Sample average colours from RobA
(define (gfe_sample_avg_colour img inLayer inMerged InMode)
(let*
(
(img (car (gimp-image-duplicate img)))
(inLayer (car (gimp-image-get-active-layer img)))
(savedsel 0)
(handler (car (gimp-message-get-handler)))
(palette (car (gimp-context-get-palette)))
(colour 0)
)
; it begins here
(unless (= inLayer -1)
(gimp-message-set-handler MESSAGE-BOX)
(if (equal? (car (gimp-selection-is-empty img)) TRUE)
(gimp-selection-all img)
)
(set! savedsel (car (gimp-selection-save img)))
(if (equal? (car (gimp-image-base-type img)) INDEXED)
(gimp-image-convert-rgb img)
)
(if (equal? inMerged TRUE)
(set! inLayer (car (gimp-image-merge-visible-layers img EXPAND-AS-NECESSARY)))
)
(gimp-selection-layer-alpha inLayer)
(gimp-channel-combine-masks (car (gimp-image-get-selection img)) savedsel CHANNEL-OP-INTERSECT 0 0)
(set! colour
(if (equal? (car (gimp-image-base-type img)) RGB)
(list (round (car (gimp-histogram inLayer HISTOGRAM-RED 0 255)))
(round (car (gimp-histogram inLayer HISTOGRAM-GREEN 0 255)))
(round (car (gimp-histogram inLayer HISTOGRAM-BLUE 0 255))))
(let ((greyval (round (car (gimp-histogram inLayer HISTOGRAM-VALUE 0 255)))))
(list greyval greyval greyval))
)
)
(cond
((and (equal? InMode 0) (equal? (car (gimp-image-base-type img)) RGB))
(gimp-message (string-append "Average Colour"
" R:" (number->string (car colour))
" G:" (number->string (cadr colour))
" B:" (number->string (caddr colour)))))
((and (equal? InMode 0) (equal? (car (gimp-image-base-type img)) GRAY))
(gimp-message (string-append "Average Value: " (number->string (caddr colour)))))
((equal? InMode 1)
(gimp-context-set-foreground colour))
((equal? InMode 2)
(gimp-context-set-background colour))
((and (equal? InMode 3) (equal? (car (gimp-palette-is-editable palette)) TRUE))
(gimp-palette-add-entry palette "Untitled" colour)))
(gimp-message-set-handler handler)
)
;done
(gimp-image-delete img)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (get-blending-mode mode)
(let* ((modenumbers #(0 1 3 15 4 5 16 17 18 19 20 21 6 7 8 9 10 11 12 13 14)))
(vector-ref modenumbers mode)
)
)
(define (math-round input)
(floor (+ input 0.5))
)
(define (math-ceil input)
(if (= input (floor input))
input
(+ (floor input) 1)
)
)
(define (get-layer-pos img layer)
(let* ((layerdata (gimp-image-get-layers img))
(numlayers (car layerdata))
(layerarray (cadr layerdata))
(i 0)
(pos -1)
)
(while (< i numlayers)
(if (= layer (vector-ref layerarray i))
(begin
(set! pos i)
(set! i numlayers)
)
(set! i (+ i 1))
)
)
pos
)
)
(define (add-under-layer img newlayer oldlayer)
(gimp-image-add-layer img newlayer (+ (get-layer-pos img oldlayer) 1))
)
(define (add-over-layer img newlayer oldlayer)
(gimp-image-add-layer img newlayer (get-layer-pos img oldlayer))
)
(define (draw-blurshape img drawable size initgrowth sel invert)
(let* (
(k initgrowth)
(currshade 0)
(i 0)
)
(while (< i size)
(if (> k 0)
(gimp-selection-grow img k)
(if (< k 0)
(gimp-selection-shrink img (abs k))
)
)
(if (= invert 1)
(begin
(set! currshade (math-round (* (/ (- size (+ i 1)) size) 255)))
)
(begin
(set! currshade (math-round (* (/ (+ i 1) size) 255)))
)
)
(gimp-context-set-foreground (list currshade currshade currshade))
(if (= (car (gimp-selection-is-empty img)) 0)
(gimp-edit-fill drawable FILL-FOREGROUND)
)
(gimp-selection-load sel)
(set! k (- k 1))
(set! i (+ i 1))
)
)
)
(define (gfe-layerfx-bevel-emboss img
drawable
style
depth
direction
size
soften
angle
altitude
glosscontour
highlightcolor
highlightmode
highlightopacity
shadowcolor
shadowmode
shadowopacity
surfacecontour
invert
merge)
(gimp-image-undo-group-start img)
(let* (
(origfgcolor (car (gimp-palette-get-foreground)))
(origselection (car (gimp-selection-save img)))
(drwwidth (car (gimp-drawable-width drawable)))
(drwheight (car (gimp-drawable-height drawable)))
(drwoffsets (gimp-drawable-offsets drawable))
(layername (car (gimp-drawable-get-name drawable)))
(imgtype (cond ((= (car (gimp-image-base-type img)) 0) 1) ((= (car (gimp-image-base-type img)) 1) 3)))
(lyrgrowamt (math-round (* size 1.2)))
(bumpmaplayer 0)
(highlightlayer 0)
(highlightmask 0)
(shadowlayer 0)
(shadowmask 0)
(layersize 0)
(alphaSel 0)
(halfsizef 0)
(halfsizec 0)
(origmask 0)
(alphamask 0)
)
(cond
((= style 0)
(begin
(set! layersize (list
(+ drwwidth (* lyrgrowamt 2))
(+ drwheight (* lyrgrowamt 2))
(- (car drwoffsets) lyrgrowamt)
(- (cadr drwoffsets) lyrgrowamt)
)
)
)
)
((= style 1)
(begin
(set! layersize (list
drwwidth
drwheight
(car drwoffsets)
(cadr drwoffsets)
)
)
)
)
((= style 2)
(begin
(set! layersize (list
(+ drwwidth lyrgrowamt)
(+ drwheight lyrgrowamt)
(- (car drwoffsets) (floor (/ lyrgrowamt 2)))
(- (cadr drwoffsets) (floor (/ lyrgrowamt 2)))
)
)
)
)
(
(begin
(set! layersize (list
(+ drwwidth lyrgrowamt)
(+ drwheight lyrgrowamt)
(- (car drwoffsets) (floor (/ lyrgrowamt 2)))
(- (cadr drwoffsets) (floor (/ lyrgrowamt 2)))
)
)
)
)
)
(set! bumpmaplayer (car (gimp-layer-new img (car layersize) (cadr layersize) imgtype (string-append layername "-bumpmap") 100 LAYER-MODE-NORMAL)))
(set! highlightlayer (car (gimp-layer-new img (car layersize) (cadr layersize) imgtype (string-append layername "-highlight") highlightopacity (get-blending-mode highlightmode))))
(set! shadowlayer (car (gimp-layer-new img (car layersize) (cadr layersize) imgtype (string-append layername "-shadow") shadowopacity (get-blending-mode shadowmode))))
(add-over-layer img bumpmaplayer drawable)
(add-over-layer img shadowlayer bumpmaplayer)
(add-over-layer img highlightlayer shadowlayer)
(gimp-layer-set-offsets bumpmaplayer (caddr layersize) (cadddr layersize))
(gimp-layer-set-offsets shadowlayer (caddr layersize) (cadddr layersize))
(gimp-layer-set-offsets highlightlayer (caddr layersize) (cadddr layersize))
(gimp-message "reached 588")
(gimp-selection-all img)
;(gimp-image-select-color img CHANNEL-OP-REPLACE drawable '(254 254 254))
(gimp-context-set-foreground highlightcolor)
(gimp-edit-fill highlightlayer FILL-FOREGROUND)
(gimp-context-set-foreground shadowcolor)
(gimp-edit-fill shadowlayer FILL-FOREGROUND)
(gimp-context-set-foreground '(0 0 0))
(gimp-edit-fill bumpmaplayer FILL-FOREGROUND)
(set! highlightmask (car (gimp-layer-create-mask highlightlayer ADD-MASK-COPY))) ; was 1=black
(set! shadowmask (car (gimp-layer-create-mask shadowlayer ADD-MASK-BLACK)))
(gimp-layer-add-mask highlightlayer highlightmask)
(gimp-layer-add-mask shadowlayer shadowmask)
(gimp-selection-layer-alpha drawable)
;(gimp-image-select-item img drawable CHANNEL-OP-REPLACE)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-selection-combine (car (gimp-layer-get-mask drawable)) 3)
;(gimp-image-select-item img drawable CHANNEL-OP-INTERSECT))
)
(gimp-message "reached 608")
(set! alphaSel (car (gimp-selection-save img)))
(cond
((= style 0)
(draw-blurshape img bumpmaplayer size size alphaSel 0)
)
((= style 1)
(draw-blurshape img bumpmaplayer size 0 alphaSel 0)
)
((= style 2)
(begin
(set! halfsizec (math-ceil (/ size 2)))
(draw-blurshape img bumpmaplayer size halfsizec alphaSel 0)
)
)
(
(begin
(set! halfsizef (floor (/ size 2)))
(set! halfsizec (- size halfsizef))
(gimp-selection-all img)
(gimp-context-set-foreground '(255 255 255))
(gimp-edit-fill bumpmaplayer FILL-FOREGROUND)
(draw-blurshape img bumpmaplayer halfsizec halfsizec alphaSel 1)
(draw-blurshape img bumpmaplayer halfsizef 0 alphaSel 0)
)
)
)
(gimp-selection-all img)
(gimp-context-set-foreground '(127 127 127))
(gimp-edit-fill highlightmask FILL-FOREGROUND)
(gimp-selection-none img)
(if (> surfacecontour 0)
;(apply-contour bumpmaplayer 0 surfacecontour)
(python-fu-colorcontour 1 img bumpmaplayer surfacecontour)
)
(if (< angle 0)
(set! angle (+ angle 360))
)
(plug-in-bump-map 1 img highlightmask bumpmaplayer angle altitude depth 0 0 0 0 1 direction 0)
(if (> glosscontour 0)
;(apply-contour highlightmask 0 glosscontour)
(python-fu-colorcontour 1 img highlightmask glosscontour)
)
(if (> soften 0)
(plug-in-gauss-rle 1 img highlightmask soften 1 1)
)
(if (> invert 0)
(gimp-drawable-invert highlightmask FALSE)
)
(gimp-channel-combine-masks shadowmask highlightmask 2 0 0)
(gimp-levels highlightmask 0 127 255 1.0 0 255)
;(gimp-levels shadowmask 0 0 127 1.0 255 0)
(gimp-drawable-levels shadowmask HISTOGRAM-VALUE 0.0 0.5 1 1.0 1.0 0.0 1)
(gimp-selection-load alphaSel)
(if (= style 0)
(gimp-selection-grow img size)
(if (or (= style 2) (= style 3))
(gimp-selection-grow img halfsizec)
)
)
(gimp-selection-invert img)
(gimp-context-set-foreground '(0 0 0))
(gimp-edit-fill shadowmask 0)
(gimp-selection-none img)
(gimp-image-remove-layer img bumpmaplayer)
(if (= merge 1)
(if (= style 1)
(begin
(set! origmask (car (gimp-layer-get-mask drawable)))
(if (> origmask -1)
(begin
(set! origmask (car (gimp-channel-copy origmask)))
(gimp-layer-remove-mask drawable 1)
)
)
(set! alphamask (car (gimp-layer-create-mask drawable 3)))
(set! shadowlayer (car (gimp-image-merge-down img shadowlayer 0)))
(set! highlightlayer (car (gimp-image-merge-down img highlightlayer 0)))
(gimp-drawable-set-name highlightlayer layername)
(gimp-layer-add-mask highlightlayer alphamask)
(gimp-layer-remove-mask highlightlayer 0)
(if (> origmask -1)
(gimp-layer-add-mask highlightlayer origmask)
)
)
(begin
(set! origmask (car (gimp-layer-get-mask drawable)))
(if (> origmask -1)
(gimp-layer-remove-mask drawable 0)
)
(set! shadowlayer (car (gimp-image-merge-down img shadowlayer 0)))
(set! highlightlayer (car (gimp-image-merge-down img highlightlayer 0)))
(gimp-drawable-set-name highlightlayer layername)
)
)
)
(gimp-context-set-foreground origfgcolor)
(gimp-selection-load origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)
;end of script