-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayerfx-Jon-Stipe-299.scm
1444 lines (1407 loc) · 61.2 KB
/
layerfx-Jon-Stipe-299.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
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;Modernized with ModernizeMatic7 for Gimp 2.10.22 by vitforlinux.wordpress.com - dont remove
; GIMP Layer Effects
; Copyright (c) 2008 Jonathan Stipe
; JonStipe@prodigy.net
; ---------------------------------------------------------------------
; 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, see <http://www.gnu.org/licenses/>.
; 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-base-type)) (define gimp-image-get-base-type gimp-image-base-type)))
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(define sfgrad "Full saturation spectrum CCW")
(define sfgrad "Full Saturation Spectrum CCW") )
(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-fix-round input)
(floor (+ input 0.5))
)
(define (math-fix-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-insert-layer img newlayer (+ (get-layer-pos img oldlayer 0) 1))
(gimp-image-insert-layer img newlayer 0 (+ (get-layer-pos img oldlayer) 1))
)
(define (add-over-layer img newlayer oldlayer)
;(gimp-image-insert-layer img newlayer (get-layer-pos img oldlayer 0))
(gimp-image-insert-layer img newlayer 0 (get-layer-pos img oldlayer))
)
(define (draw-fix-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)
(set! currshade (math-fix-round (* (/ (- size (+ i 1)) size) 255)))
(set! currshade (math-fix-round (* (/ (+ i 1) size) 255)))
)
(gimp-context-set-foreground (list currshade currshade currshade))
(if (= (car (gimp-selection-is-empty img)) 0)
(gimp-drawable-edit-fill drawable 0)
)
(gimp-image-select-item img 2 sel)
(set! k (- k 1))
(set! i (+ i 1))
)
)
)
(define (apply-contour drawable channel contour)
(let* ((contourtypes #(0 0 0 0 0 0 0 0 0 1 1))
(contourlengths #(6 6 10 14 18 10 18 18 10 256 256))
(contours #(#(0 0 0.5 1 1 0)
#(0 1 0.498039 0 1 1)
#(0 0.25098 0.368627 0.290196 0.588235 0.45098 0.701961 0.701961 0.74902 1)
#(0 0 0.0196078 0.490196 0.0235294 0.490196 0.188235 0.580392 0.309804 0.701961 0.419608 0.85098 0.509804 1)
#(0 0 0.129412 0.0313725 0.25098 0.14902 0.380392 0.4 0.501961 0.65098 0.619608 0.819608 0.74902 0.921569 0.870588 0.968627 1 1)
#(0 0 0.109804 0.278431 0.341176 0.65098 0.760784 0.941176 1 1)
#(0 0 0.129412 0.431373 0.25098 0.929412 0.380392 0.941176 0.501961 0.541176 0.619608 0.129412 0.74902 0.0196078 0.870588 0.388235 1 1)
#(0 0 0.129412 0.290196 0.25098 0.858824 0.380392 0.729412 0.501961 0 0.619608 0.690196 0.74902 0.788235 0.870588 0.0117647 1 1)
#(0 1 0.211765 0.388235 0.380392 0.419608 0.701961 0.6 0.988235 0)
#(0 0.0196078 0.0352941 0.0509804 0.0627451 0.0745098 0.0862745 0.0980392 0.105882 0.113725 0.117647 0.12549 0.129412 0.133333 0.137255 0.141176 0.14902 0.152941 0.156863 0.160784 0.168627 0.172549 0.180392 0.184314 0.188235 0.192157 0.196078 0.2 0.203922 0.207843 0.211765 0.215686 0.215686 0.219608 0.219608 0.223529 0.223529 0.227451 0.227451 0.231373 0.231373 0.231373 0.235294 0.235294 0.235294 0.239216 0.239216 0.239216 0.239216 0.243137 0.243137 0.243137 0.243137 0.243137 0.247059 0.247059 0.247059 0.247059 0.247059 0.247059 0.25098 0.25098 0.25098 0.25098 0.25098 0.278431 0.294118 0.305882 0.317647 0.329412 0.337255 0.34902 0.356863 0.364706 0.372549 0.376471 0.384314 0.388235 0.396078 0.4 0.403922 0.407843 0.411765 0.419608 0.419608 0.423529 0.431373 0.435294 0.439216 0.443137 0.447059 0.45098 0.454902 0.458824 0.462745 0.466667 0.466667 0.470588 0.47451 0.47451 0.478431 0.482353 0.482353 0.482353 0.486275 0.486275 0.486275 0.490196 0.490196 0.490196 0.490196 0.490196 0.490196 0.490196 0.494118 0.494118 0.494118 0.494118 0.494118 0.494118 0.494118 0.490196 0.490196 0.490196 0.490196 0.490196 0.490196 0.490196 0.490196 0.509804 0.52549 0.537255 0.552941 0.568627 0.580392 0.592157 0.6 0.611765 0.619608 0.627451 0.635294 0.639216 0.647059 0.65098 0.654902 0.658824 0.666667 0.670588 0.670588 0.67451 0.678431 0.682353 0.686275 0.690196 0.694118 0.698039 0.698039 0.701961 0.705882 0.709804 0.709804 0.713725 0.717647 0.717647 0.721569 0.721569 0.72549 0.72549 0.729412 0.729412 0.733333 0.733333 0.737255 0.737255 0.741176 0.741176 0.741176 0.741176 0.745098 0.745098 0.745098 0.745098 0.74902 0.74902 0.74902 0.74902 0.74902 0.74902 0.74902 0.74902 0.74902 0.74902 0.756863 0.760784 0.768627 0.772549 0.776471 0.784314 0.788235 0.796078 0.8 0.803922 0.811765 0.815686 0.819608 0.827451 0.831373 0.835294 0.839216 0.843137 0.85098 0.854902 0.858824 0.862745 0.862745 0.866667 0.870588 0.870588 0.87451 0.87451 0.878431 0.878431 0.878431 0.878431 0.878431 0.87451 0.87451 0.870588 0.870588 0.866667 0.866667 0.862745 0.858824 0.854902 0.85098 0.847059 0.843137 0.839216 0.835294 0.831373 0.827451 0.823529 0.819608 0.815686 0.807843 0.803922 0.8 0.796078 0.792157 0.784314 0.780392 0.776471 0.772549 0.768627 0.760784 0.760784)
#(0 0.00784314 0.0156863 0.0235294 0.0313725 0.0392157 0.0470588 0.054902 0.0627451 0.0705882 0.0784314 0.0862745 0.0941176 0.101961 0.109804 0.117647 0.12549 0.133333 0.141176 0.14902 0.156863 0.164706 0.172549 0.180392 0.188235 0.196078 0.203922 0.211765 0.219608 0.227451 0.235294 0.243137 0.25098 0.258824 0.266667 0.27451 0.282353 0.290196 0.298039 0.305882 0.313725 0.321569 0.329412 0.337255 0.345098 0.352941 0.360784 0.368627 0.376471 0.384314 0.392157 0.4 0.407843 0.415686 0.423529 0.431373 0.439216 0.447059 0.454902 0.462745 0.470588 0.478431 0.486275 0.494118 0.498039 0.490196 0.482353 0.47451 0.466667 0.458824 0.45098 0.443137 0.435294 0.427451 0.419608 0.411765 0.403922 0.396078 0.388235 0.380392 0.372549 0.364706 0.356863 0.34902 0.341176 0.333333 0.32549 0.317647 0.309804 0.301961 0.294118 0.286275 0.278431 0.270588 0.262745 0.254902 0.247059 0.239216 0.231373 0.223529 0.215686 0.207843 0.2 0.192157 0.184314 0.176471 0.168627 0.160784 0.152941 0.145098 0.137255 0.129412 0.121569 0.113725 0.105882 0.0980392 0.0901961 0.0823529 0.0745098 0.0666667 0.0588235 0.0509804 0.0431373 0.0352941 0.027451 0.0196078 0.0117647 0.00392157 0.00392157 0.0117647 0.0196078 0.027451 0.0352941 0.0431373 0.0509804 0.0588235 0.0666667 0.0745098 0.0823529 0.0901961 0.0980392 0.105882 0.113725 0.121569 0.129412 0.137255 0.145098 0.152941 0.160784 0.168627 0.176471 0.184314 0.192157 0.2 0.207843 0.215686 0.223529 0.231373 0.239216 0.247059 0.254902 0.262745 0.270588 0.278431 0.286275 0.294118 0.301961 0.309804 0.317647 0.32549 0.333333 0.341176 0.34902 0.356863 0.364706 0.372549 0.380392 0.388235 0.396078 0.403922 0.411765 0.419608 0.427451 0.435294 0.443137 0.45098 0.458824 0.466667 0.47451 0.482353 0.490196 0.498039 0.501961 0.494118 0.486275 0.478431 0.470588 0.462745 0.454902 0.447059 0.439216 0.431373 0.423529 0.415686 0.407843 0.4 0.392157 0.384314 0.376471 0.368627 0.360784 0.352941 0.345098 0.337255 0.329412 0.321569 0.313725 0.305882 0.298039 0.290196 0.282353 0.27451 0.266667 0.258824 0.25098 0.243137 0.235294 0.227451 0.219608 0.211765 0.203922 0.196078 0.188235 0.180392 0.172549 0.164706 0.156863 0.14902 0.141176 0.133333 0.12549 0.117647 0.109804 0.101961 0.0941176 0.0862745 0.0784314 0.0705882 0.0627451 0.054902 0.0470588 0.0392157 0.0313725 0.0235294 0.0156863 0.00784314))))
(if (= (vector-ref contourtypes (- contour 1)) 0)
(gimp-drawable-curves-spline drawable channel (vector-ref contourlengths (- contour 1)) (vector-ref contours (- contour 1)))
(gimp-drawable-curves-explicit drawable channel (vector-ref contourlengths (- contour 1)) (vector-ref contours (- contour 1)))
)
)
)
(define (apply-noise img drawable srclayer noise)
(let* ((drwwidth (car (gimp-drawable-get-width srclayer)))
(drwheight (car (gimp-drawable-get-height srclayer)))
(layername (car (gimp-item-get-name drawable)))
(drwoffsets (gimp-drawable-get-offsets srclayer))
(srcmask (car (gimp-layer-get-mask srclayer)))
(noiselayer (car (gimp-layer-new img drwwidth drwheight (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-noise") 100 0)))
(blanklayer (car (gimp-layer-new img drwwidth drwheight (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-noise") 100 0))))
(add-over-layer img noiselayer srclayer)
(add-over-layer img blanklayer noiselayer)
(gimp-layer-set-offsets noiselayer (car drwoffsets) (cadr drwoffsets))
(gimp-layer-set-offsets blanklayer (car drwoffsets) (cadr drwoffsets))
(gimp-selection-all img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill noiselayer 0)
(gimp-drawable-edit-fill blanklayer 0)
(gimp-context-set-foreground '(255 255 255))
(gimp-image-select-item img 2 srcmask)
(gimp-drawable-edit-fill blanklayer 0)
(plug-in-hsv-noise 1 img noiselayer 1 0 0 255)
(gimp-layer-set-mode blanklayer 5)
(gimp-layer-set-opacity blanklayer noise)
(set! noiselayer (car (gimp-image-merge-down img blanklayer 0)))
(set! blanklayer (car (gimp-layer-create-mask noiselayer 5)))
(gimp-channel-combine-masks srcmask blanklayer 2 0 0)
(gimp-image-remove-layer img noiselayer)
)
)
(define (script-fu-layerfx-drop-shadow img
drawable
color
opacity
contour
noise
mode
spread
size
offsetangle
offsetdist
knockout
merge)
(gimp-image-undo-group-start img)
(let* ((origfgcolor (car (gimp-context-get-foreground)))
(origselection (car (gimp-selection-save img)))
(drwwidth (car (gimp-drawable-get-width drawable)))
(drwheight (car (gimp-drawable-get-height drawable)))
(drwoffsets (gimp-drawable-get-offsets drawable))
(layername (car (gimp-item-get-name drawable)))
(growamt (math-fix-ceil (/ size 2)))
(steps (math-fix-round (- size (* (/ spread 100) size))))
(lyrgrowamt (math-fix-round (* growamt 1.2)))
(shadowlayer (car (gimp-layer-new img (+ drwwidth (* lyrgrowamt 2)) (+ drwheight (* lyrgrowamt 2)) (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-dropshadow") opacity (get-blending-mode mode))))
(shadowmask 0)
(alphaSel 0)
(ang (* (* (+ offsetangle 180) -1) (/ (* 4 (atan 1.0)) 180)))
(offsetX (math-fix-round (* offsetdist (cos ang))))
(offsetY (math-fix-round (* offsetdist (sin ang))))
(origmask 0)
)
(add-under-layer img shadowlayer drawable)
(gimp-layer-set-offsets shadowlayer (- (+ (car drwoffsets) offsetX) lyrgrowamt) (- (+ (cadr drwoffsets) offsetY) lyrgrowamt))
(gimp-selection-all img)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill shadowlayer 0)
(gimp-selection-none img)
(set! shadowmask (car (gimp-layer-create-mask shadowlayer 1)))
(gimp-layer-add-mask shadowlayer shadowmask)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item img 3 (car (gimp-layer-get-mask drawable)))
)
(gimp-selection-translate img offsetX offsetY)
(set! alphaSel (car (gimp-selection-save img)))
(draw-fix-blurshape img shadowmask steps growamt alphaSel 0)
(gimp-selection-none img)
(if (> contour 0)
(begin
(apply-contour shadowmask 0 contour)
(gimp-image-select-item img 2 alphaSel)
(gimp-selection-grow img growamt)
(gimp-selection-invert img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill shadowmask 0)
(gimp-selection-none img)
)
)
(if (> noise 0)
(apply-noise img drawable shadowlayer noise)
)
(if (= knockout 1)
(begin
(gimp-context-set-foreground '(0 0 0))
(gimp-image-select-item img 2 drawable)
(gimp-drawable-edit-fill shadowmask 0)
)
)
(gimp-layer-remove-mask shadowlayer 0)
(gimp-selection-none img)
(if (= merge 1)
(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 drawable 0)))
(gimp-item-set-name shadowlayer layername)
)
)
(gimp-context-set-foreground origfgcolor)
(gimp-image-select-item img 2 origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)
(define (script-fu-layerfx-inner-shadow img
drawable
color
opacity
contour
noise
mode
source
choke
size
offsetangle
offsetdist
merge)
(gimp-image-undo-group-start img)
(let* ((origfgcolor (car (gimp-context-get-foreground)))
(origselection (car (gimp-selection-save img)))
(drwwidth (car (gimp-drawable-get-width drawable)))
(drwheight (car (gimp-drawable-get-height drawable)))
(layername (car (gimp-item-get-name drawable)))
(drwoffsets (gimp-drawable-get-offsets drawable))
(shadowlayer (car (gimp-layer-new img drwwidth drwheight (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-innershadow") opacity (get-blending-mode mode))))
(shadowmask 0)
(alphaSel 0)
(growamt (math-fix-ceil (/ size 2)))
(chokeamt (* (/ choke 100) size))
(steps (math-fix-round (- size chokeamt)))
(ang (* (* (+ offsetangle 180) -1) (/ (* 4 (atan 1.0)) 180)))
(offsetX (math-fix-round (* offsetdist (cos ang))))
(offsetY (math-fix-round (* offsetdist (sin ang))))
(origmask 0)
(alphamask 0)
)
(add-over-layer img shadowlayer drawable)
(gimp-layer-set-offsets shadowlayer (car drwoffsets) (cadr drwoffsets))
(gimp-selection-all img)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill shadowlayer 0)
(gimp-selection-none img)
(set! shadowmask (car (gimp-layer-create-mask shadowlayer 1)))
(gimp-layer-add-mask shadowlayer shadowmask)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item img 3 (car (gimp-layer-get-mask drawable)))
)
(gimp-selection-translate img offsetX offsetY)
(set! alphaSel (car (gimp-selection-save img)))
(if (= source 0)
(begin
(gimp-selection-all img)
(gimp-context-set-foreground '(255 255 255))
(gimp-drawable-edit-fill shadowmask 0)
(gimp-image-select-item img 2 alphaSel)
(draw-fix-blurshape img shadowmask steps (- growamt chokeamt) alphaSel 1)
)
(draw-fix-blurshape img shadowmask steps (- growamt chokeamt) alphaSel 0)
)
(gimp-selection-none img)
(if (> contour 0)
(apply-contour shadowmask 0 contour)
)
(if (= merge 0)
(begin
(gimp-image-select-item img 2 drawable)
(gimp-selection-invert img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill shadowmask 0)
)
)
(if (> noise 0)
(apply-noise img drawable shadowlayer noise)
)
(gimp-layer-remove-mask shadowlayer 0)
(if (= merge 1)
(if (= source 0)
(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)))
(gimp-item-set-name shadowlayer layername)
(gimp-layer-add-mask shadowlayer alphamask)
(gimp-layer-remove-mask shadowlayer 0)
(if (> origmask -1)
(gimp-layer-add-mask shadowlayer origmask)
)
)
(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! shadowlayer (car (gimp-image-merge-down img shadowlayer 0)))
(gimp-item-set-name shadowlayer layername)
(if (> origmask -1)
(gimp-layer-add-mask shadowlayer origmask)
)
)
)
)
(gimp-selection-none img)
(gimp-context-set-foreground origfgcolor)
(gimp-image-select-item img 2 origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)
(define (script-fu-layerfx-outer-glow img
drawable
color
opacity
contour
noise
mode
spread
size
knockout
merge)
(gimp-image-undo-group-start img)
(let* ((origfgcolor (car (gimp-context-get-foreground)))
(origselection (car (gimp-selection-save img)))
(drwwidth (car (gimp-drawable-get-width drawable)))
(drwheight (car (gimp-drawable-get-height drawable)))
(drwoffsets (gimp-drawable-get-offsets drawable))
(layername (car (gimp-item-get-name drawable)))
(lyrgrowamt (math-fix-round (* size 1.2)))
(glowlayer (car (gimp-layer-new img (+ drwwidth (* lyrgrowamt 2)) (+ drwheight (* lyrgrowamt 2)) (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-outerglow") opacity (get-blending-mode mode))))
(glowmask 0)
(alphaSel 0)
(growamt (* (/ spread 100) size))
(steps (- size growamt))
(origmask 0)
)
(add-under-layer img glowlayer drawable)
(gimp-layer-set-offsets glowlayer (- (car drwoffsets) lyrgrowamt) (- (cadr drwoffsets) lyrgrowamt))
(gimp-selection-all img)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill glowlayer 0)
(gimp-selection-none img)
(set! glowmask (car (gimp-layer-create-mask glowlayer 1)))
(gimp-layer-add-mask glowlayer glowmask)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item img 3 (car (gimp-layer-get-mask drawable)))
)
(set! alphaSel (car (gimp-selection-save img)))
(draw-fix-blurshape img glowmask steps size alphaSel 0)
(gimp-selection-none img)
(if (> contour 0)
(begin
(apply-contour glowmask 0 contour)
(gimp-image-select-item img 2 alphaSel)
(gimp-selection-grow img size)
(gimp-selection-invert img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill glowmask 0)
(gimp-selection-none img)
)
)
(if (> noise 0)
(apply-noise img drawable glowlayer noise)
)
(if (= knockout 1)
(begin
(gimp-context-set-foreground '(0 0 0))
(gimp-image-select-item img 2 drawable)
(gimp-drawable-edit-fill glowmask 0)
)
)
(gimp-layer-remove-mask glowlayer 0)
(gimp-selection-none img)
(if (= merge 1)
(begin
(set! origmask (car (gimp-layer-get-mask drawable)))
(if (> origmask -1)
(gimp-layer-remove-mask drawable 0)
)
(set! glowlayer (car (gimp-image-merge-down img drawable 0)))
(gimp-item-set-name glowlayer layername)
)
)
(gimp-context-set-foreground origfgcolor)
(gimp-image-select-item img 2 origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)
(define (script-fu-layerfx-inner-glow img
drawable
color
opacity
contour
noise
mode
source
choke
size
merge)
(gimp-image-undo-group-start img)
(let* ((origfgcolor (car (gimp-context-get-foreground)))
(origselection (car (gimp-selection-save img)))
(drwwidth (car (gimp-drawable-get-width drawable)))
(drwheight (car (gimp-drawable-get-height drawable)))
(layername (car (gimp-item-get-name drawable)))
(drwoffsets (gimp-drawable-get-offsets drawable))
(glowlayer (car (gimp-layer-new img drwwidth drwheight (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-innerglow") opacity (get-blending-mode mode))))
(glowmask 0)
(alphaSel 0)
(shrinkamt (* (/ choke 100) size))
(steps (- size shrinkamt))
(i 0)
(currshade 0)
(origmask 0)
(alphamask 0)
)
(add-over-layer img glowlayer drawable)
(gimp-layer-set-offsets glowlayer (car drwoffsets) (cadr drwoffsets))
(gimp-selection-all img)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill glowlayer 0)
(gimp-selection-none img)
(set! glowmask (car (gimp-layer-create-mask glowlayer 1)))
(gimp-layer-add-mask glowlayer glowmask)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item img 3 (car (gimp-layer-get-mask drawable)))
)
(set! alphaSel (car (gimp-selection-save img)))
(if (= source 0)
(begin
(gimp-selection-all img)
(gimp-context-set-foreground '(255 255 255))
(gimp-drawable-edit-fill glowmask 0)
(gimp-image-select-item img 2 alphaSel)
(draw-fix-blurshape img glowmask steps (- (* shrinkamt -1) 1) alphaSel 1)
)
(draw-fix-blurshape img glowmask steps (* shrinkamt -1) alphaSel 0)
)
(gimp-selection-none img)
(if (> contour 0)
(apply-contour glowmask 0 contour)
)
(if (and (= source 0) (= merge 0))
(begin
(gimp-image-select-item img 2 alphaSel)
(gimp-selection-invert img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill glowmask 0)
)
)
(if (> noise 0)
(apply-noise img drawable glowlayer noise)
)
(gimp-layer-remove-mask glowlayer 0)
(if (= merge 1)
(if (= source 0)
(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! glowlayer (car (gimp-image-merge-down img glowlayer 0)))
(gimp-item-set-name glowlayer layername)
(gimp-layer-add-mask glowlayer alphamask)
(gimp-layer-remove-mask glowlayer 0)
(if (> origmask -1)
(gimp-layer-add-mask glowlayer origmask)
)
)
(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! glowlayer (car (gimp-image-merge-down img glowlayer 0)))
(gimp-item-set-name glowlayer layername)
(if (> origmask -1)
(gimp-layer-add-mask glowlayer origmask)
)
)
)
)
(gimp-selection-none img)
(gimp-context-set-foreground origfgcolor)
(gimp-image-select-item img 2 origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)
(define (script-fu-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-context-get-foreground)))
(origselection (car (gimp-selection-save img)))
(drwwidth (car (gimp-drawable-get-width drawable)))
(drwheight (car (gimp-drawable-get-height drawable)))
(drwoffsets (gimp-drawable-get-offsets drawable))
(layername (car (gimp-item-get-name drawable)))
(imgtype (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)))
(lyrgrowamt (math-fix-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 0)))
(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-selection-all img)
(gimp-context-set-foreground highlightcolor)
(gimp-drawable-edit-fill highlightlayer 0)
(gimp-context-set-foreground shadowcolor)
(gimp-drawable-edit-fill shadowlayer 0)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill bumpmaplayer 0)
(set! highlightmask (car (gimp-layer-create-mask highlightlayer 1)))
(set! shadowmask (car (gimp-layer-create-mask shadowlayer 1)))
(gimp-layer-add-mask highlightlayer highlightmask)
(gimp-layer-add-mask shadowlayer shadowmask)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item img 3 (car (gimp-layer-get-mask drawable)))
)
(set! alphaSel (car (gimp-selection-save img)))
(cond
((= style 0)
(draw-fix-blurshape img bumpmaplayer size size alphaSel 0)
)
((= style 1)
(draw-fix-blurshape img bumpmaplayer size 0 alphaSel 0)
)
((= style 2)
(begin
(set! halfsizec (math-fix-ceil (/ size 2)))
(draw-fix-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-drawable-edit-fill bumpmaplayer 0)
(draw-fix-blurshape img bumpmaplayer halfsizec halfsizec alphaSel 1)
(draw-fix-blurshape img bumpmaplayer halfsizef 0 alphaSel 0)
)
)
)
(gimp-selection-all img)
(gimp-context-set-foreground '(127 127 127))
(gimp-drawable-edit-fill highlightmask 0)
(gimp-selection-none img)
(if (> surfacecontour 0)
(apply-contour bumpmaplayer 0 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)
)
(if (> soften 0)
(plug-in-gauss-rle 1 img highlightmask soften 1 1)
)
(if (> invert 0)
(gimp-drawable-invert highlightmask TRUE)
)
(gimp-channel-combine-masks shadowmask highlightmask 2 0 0)
(gimp-drawable-levels highlightmask 0 0.5 1 FALSE 1.0 0 1 FALSE)
(gimp-drawable-levels shadowmask 0 0 0.5 FALSE 1.0 1 0 FALSE)
(gimp-image-select-item img 2 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-drawable-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-item-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-item-set-name highlightlayer layername)
)
)
)
(gimp-context-set-foreground origfgcolor)
(gimp-image-select-item img 2 origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)
(define (script-fu-layerfx-satin img
drawable
color
opacity
mode
offsetangle
offsetdist
size
contour
invert
merge)
(gimp-image-undo-group-start img)
(let* ((origfgcolor (car (gimp-context-get-foreground)))
(origselection (car (gimp-selection-save img)))
(layername (car (gimp-item-get-name drawable)))
(growamt (math-fix-ceil (/ size 2)))
(lyrgrowamt (math-fix-round (* growamt 1.2)))
(satinlayer (car (gimp-layer-new img (+ (car (gimp-drawable-get-width drawable)) (* lyrgrowamt 2)) (+ (car (gimp-drawable-get-height drawable)) (* lyrgrowamt 2)) (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-satin") 100 0)))
(satinmask 0)
(blacklayer 0)
(drwoffsets (gimp-drawable-get-offsets drawable))
(ang (* (* (+ offsetangle 180) -1) (/ (* 4 (atan 1.0)) 180)))
(offsetX (math-fix-round (* offsetdist (cos ang))))
(offsetY (math-fix-round (* offsetdist (sin ang))))
(alphaSel 0)
(layeraoffsets 0)
(layerboffsets 0)
(dx 0)
(dy 0)
(origmask 0)
(alphamask 0)
)
(add-over-layer img satinlayer drawable)
(gimp-layer-set-offsets satinlayer (- (car drwoffsets) lyrgrowamt) (- (cadr drwoffsets) lyrgrowamt))
(gimp-selection-all img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill satinlayer 0)
(gimp-selection-none img)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item img 3 (car (gimp-layer-get-mask drawable)))
)
(set! alphaSel (car (gimp-selection-save img)))
(draw-fix-blurshape img satinlayer size growamt alphaSel 0)
;(plug-in-autocrop-layer 1 img satinlayer)
(set! satinmask (car (gimp-layer-copy satinlayer 0)))
(add-over-layer img satinmask satinlayer)
(gimp-item-transform-translate satinlayer offsetX offsetY)
(gimp-item-transform-translate satinmask (* offsetX -1) (* offsetY -1))
(set! layeraoffsets (gimp-drawable-get-offsets satinlayer))
(set! layerboffsets (gimp-drawable-get-offsets satinmask))
(set! dx (- (max (car layeraoffsets) (car layerboffsets)) (min (car layeraoffsets) (car layerboffsets))))
(set! dy (- (max (cadr layeraoffsets) (cadr layerboffsets)) (min (cadr layeraoffsets) (cadr layerboffsets))))
(set! blacklayer (car (gimp-layer-new img (+ (car (gimp-drawable-get-width satinlayer)) dx) (+ (car (gimp-drawable-get-height satinlayer)) dy) (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-satinblank") 100 0)))
(add-under-layer img blacklayer satinlayer)
(gimp-layer-set-offsets blacklayer (min (car layeraoffsets) (car layerboffsets)) (min (cadr layeraoffsets) (cadr layerboffsets)))
(gimp-selection-all img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill blacklayer 0)
(gimp-selection-none img)
(gimp-layer-set-mode satinmask 6)
(set! satinlayer (car (gimp-image-merge-down img satinlayer 0)))
(set! satinlayer (car (gimp-image-merge-down img satinmask 0)))
(gimp-item-set-name satinlayer (string-append layername "-satin"))
(if (> contour 0)
(begin
(apply-contour satinlayer 0 contour)
(gimp-image-select-item img 2 alphaSel)
(gimp-selection-grow img size)
(gimp-selection-invert img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill satinlayer 0)
(gimp-selection-none img)
)
)
(if (= invert 1)
(gimp-drawable-invert satinlayer TRUE)
)
(set! satinmask (car (gimp-layer-create-mask satinlayer 5)))
(gimp-layer-add-mask satinlayer satinmask)
(gimp-selection-all img)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill satinlayer 0)
(gimp-selection-none img)
(gimp-layer-set-opacity satinlayer opacity)
(gimp-layer-set-mode satinlayer (get-blending-mode mode))
(gimp-layer-resize satinlayer (car (gimp-drawable-get-width drawable)) (car (gimp-drawable-get-height drawable)) (- (car (gimp-drawable-get-offsets satinlayer)) (car drwoffsets)) (- (cadr (gimp-drawable-get-offsets satinlayer)) (cadr drwoffsets)))
(if (= merge 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! satinlayer (car (gimp-image-merge-down img satinlayer 0)))
(gimp-item-set-name satinlayer layername)
(gimp-layer-add-mask satinlayer alphamask)
(gimp-layer-remove-mask satinlayer 0)
(if (> origmask -1)
(gimp-layer-add-mask satinlayer origmask)
)
)
(begin
(gimp-image-select-item img 2 alphaSel)
(gimp-selection-invert img)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-edit-fill satinmask 0)
)
)
(gimp-context-set-foreground origfgcolor)
(gimp-image-select-item img 2 origselection)
(gimp-image-remove-channel img alphaSel)
(gimp-image-remove-channel img origselection)
(gimp-displays-flush)
)
(gimp-image-undo-group-end img)
)
(define (script-fu-layerfx-stroke img
drawable
color
opacity
mode
size
position
merge)
(gimp-image-undo-group-start img)
(let* ((origfgcolor (car (gimp-context-get-foreground)))
(origselection (car (gimp-selection-save img)))
(drwwidth (car (gimp-drawable-get-width drawable)))
(drwheight (car (gimp-drawable-get-height drawable)))
(drwoffsets (gimp-drawable-get-offsets drawable))
(layername (car (gimp-item-get-name drawable)))
(strokelayer 0)
(drwoffsets (gimp-drawable-get-offsets drawable))
(alphaselection 0)
(outerselection 0)
(innerselection 0)
(origmask 0)
(alphamask 0)
(outerwidth 0)
(innerwidth 0)
(growamt 0)
)
(if (= position 0)
(begin
(set! strokelayer (car (gimp-layer-new img drwwidth drwheight (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-stroke") opacity (get-blending-mode mode))))
(add-over-layer img strokelayer drawable)
(gimp-layer-set-offsets strokelayer (car drwoffsets) (cadr drwoffsets))
(gimp-selection-all img)
(gimp-drawable-edit-clear strokelayer)
(gimp-selection-none img)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item 3 img (car (gimp-layer-get-mask drawable)))
)
(set! alphaselection (car (gimp-selection-save img)))
(gimp-selection-shrink img size)
(set! innerselection (car (gimp-selection-save img)))
(if (= merge 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)))
(gimp-selection-none img)
(gimp-drawable-threshold alphaselection 0,00392156862745 1)
(gimp-image-select-item img 2 alphaselection)
(gimp-image-select-item img 1 innerselection)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill strokelayer 0)
(set! strokelayer (car (gimp-image-merge-down img strokelayer 0)))
(gimp-item-set-name strokelayer layername)
(gimp-layer-add-mask strokelayer alphamask)
(gimp-layer-remove-mask strokelayer 0)
(if (> origmask -1)
(gimp-layer-add-mask strokelayer origmask)
)
)
(begin
(gimp-image-select-item img 2 alphaselection)
(gimp-image-select-item img 1 innerselection)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill strokelayer 0)
)
)
)
(if (= position 100)
(begin
(set! growamt (math-fix-round (* size 1.2)))
(set! strokelayer (car (gimp-layer-new img (+ drwwidth (* growamt 2)) (+ drwheight (* growamt 2)) (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-stroke") opacity (get-blending-mode mode))))
(add-under-layer img strokelayer drawable)
(gimp-layer-set-offsets strokelayer (- (car drwoffsets) growamt) (- (cadr drwoffsets) growamt))
(gimp-selection-all img)
(gimp-drawable-edit-clear strokelayer)
(gimp-selection-none img)
(gimp-image-select-item img 2 drawable)
(if (> (car (gimp-layer-get-mask drawable)) -1)
(gimp-image-select-item img 3 (car (gimp-layer-get-mask drawable)))
)
(set! alphaselection (car (gimp-selection-save img)))
(set! innerselection (car (gimp-selection-save img)))
(gimp-selection-none img)
(gimp-drawable-threshold innerselection 1 1)
(gimp-image-select-item img 2 alphaselection)
(gimp-selection-grow img size)
(gimp-image-select-item img 1 innerselection)
(gimp-context-set-foreground color)
(gimp-drawable-edit-fill strokelayer 0)
(if (= merge 1)
(begin
(set! origmask (car (gimp-layer-get-mask drawable)))
(if (> origmask -1)
(gimp-layer-remove-mask drawable 0)
)
(set! strokelayer (car (gimp-image-merge-down img drawable 0)))
(gimp-item-set-name strokelayer layername)
)
)
)
(begin
(set! outerwidth (math-fix-round (* (/ position 100) size)))
(set! innerwidth (- size outerwidth))
(set! growamt (math-fix-round (* outerwidth 1.2)))
(set! strokelayer (car (gimp-layer-new img (+ drwwidth (* growamt 2)) (+ drwheight (* growamt 2)) (cond ((= (car (gimp-image-get-base-type img)) 0) 1) ((= (car (gimp-image-get-base-type img)) 1) 3)) (string-append layername "-stroke") opacity (get-blending-mode mode))))
(add-over-layer img strokelayer drawable)
(gimp-layer-set-offsets strokelayer (- (car drwoffsets) growamt) (- (cadr drwoffsets) growamt))
(gimp-selection-all img)
(gimp-drawable-edit-clear strokelayer)
(gimp-selection-none img)