This file is indexed.

/usr/share/gimp/2.0/scripts/iccii-layer-effects.scm is in gimp-plugin-registry 7.20140602ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
;-------------------------------------------------------------------------
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; Layer Effects script for GIMP 2.4
; Copyright (C) 2001 Iccii
;
; Tags: layer, effects
;
; --------------------------------------------------------------------
; Distributed by Gimp FX Foundry project
; --------------------------------------------------------------------
; version 0.1 by Iccii 2001/08/06
; - Initial relase
; version 0.2 by Iccii 2001/08/07
; - Divide each function into depending function and common function
; version 0.3 by Iccii 2001/08/09
; - Add the Stain script
; version 0.4 by Iccii 2001/08/10
; - Add the Color/Gradient/Pattern Overlay scripts
; version 0.5 by Iccii 2001/08/14
; - Add the Border script (not better)
; version 0.5a by Iccii 2003/05/29
; - Add "Antialias" option in Add Border script
;
; --------------------------------------------------------------------
;
; 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.
;
; corrections made by Michael Hoelzen begin
; 2005-11-12 replaced some deprecated procedures (not all of them)
; 2005-11-12 error corrected in gradient overlay script:
; "do adaptive supersampling" and "supersampling threshold"
; weren't set
; corrections made by Michael Hoelzen end
;
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Layer Effect common function ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (layer-effects-common1
            img ;
            layer ;
            color ;
            angle ;
            offset-radius ;
            effect-radius ;
            blur-radius ;
            opacity ;
            layer-mode ;
            layer-name ;
            color-side ; (Outer(0) Inner(1) Inner-Inverse(2))
         )

    (let* (
        (width (car (gimp-drawable-width layer)))
        (height (car (gimp-drawable-height layer)))
        (radians (/ (* 2 *pi* angle) 360))
        (x-offset (* offset-radius (sin radians)))
        (y-offset (* offset-radius (cos radians)))
        (target-layer (car (gimp-layer-copy layer TRUE)))
        (effect-layer (car (gimp-layer-new img width height RGBA-IMAGE
        layer-name opacity layer-mode)))
        (effect-mask (car (gimp-layer-create-mask effect-layer WHITE-MASK)))
        (effect-mask2 0)
      )

        ;;
        (gimp-image-add-layer img effect-layer -1)

        (gimp-layer-add-mask effect-layer effect-mask)
        (if (= color-side 0)
        (gimp-invert effect-mask))
        (if (< 0 (car (gimp-layer-get-mask target-layer)))
        ;replaced 2005-11-13
        ; (gimp-image-remove-layer-mask img target-layer APPLY))
        (gimp-layer-remove-mask target-layer APPLY))

        ;;
        (gimp-context-set-background color)
        (gimp-drawable-fill effect-layer BG-IMAGE-FILL)
        (gimp-selection-layer-alpha target-layer)
        (if (= color-side 0)
            (gimp-selection-grow img effect-radius)
            (begin
                (gimp-selection-invert img)
                (gimp-selection-grow img effect-radius)
                (gimp-selection-invert img) ))
        (if (= color-side 0)
            (gimp-context-set-background '(255 255 255))
            (gimp-context-set-background '(0 0 0)))
            (gimp-edit-fill effect-mask BG-IMAGE-FILL)
            (gimp-selection-none img)
            ;;
            (gimp-context-set-background '(0 0 0))
        (if (< 0 offset-radius)
            (gimp-drawable-offset effect-mask FALSE OFFSET-BACKGROUND x-offset y-offset))
        (if (< 0 blur-radius)
            (plug-in-gauss-iir2 1 img effect-mask blur-radius blur-radius))
        (if (= color-side 2)
            (gimp-invert effect-mask))

        (gimp-layer-remove-mask effect-layer APPLY)
        (set! effect-mask2 (car (gimp-layer-create-mask effect-layer BLACK-MASK)))

        (gimp-layer-add-mask effect-layer effect-mask2)
        (if (= color-side 0)
            (gimp-invert effect-mask2))
        (gimp-selection-layer-alpha target-layer)
        (if (= color-side 0)
            (gimp-context-set-background '(0 0 0))
            (gimp-context-set-background '(255 255 255)))
        (gimp-edit-fill effect-mask2 BG-IMAGE-FILL)
        (gimp-selection-none img)

        ;;
        (if (= color-side 0)
            (gimp-image-lower-layer img effect-layer))
        (gimp-image-set-active-layer img layer)
        (list effect-layer)
    )
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Drop Shadow Script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-layer-effects-drop-shadow
            img ;
            layer ;
            color ;
            angle ;
            offset-radius ;
            radius ;
            blur-radius ;
            opacity ;
            layer-mode ;
        )

   (let* (
        (old-bg (car (gimp-context-get-background)))
        (layer-mode (cond ((= layer-mode 0) 3)
        ((= layer-mode 2) 0)
        (layer-mode)))
      )
    (gimp-image-undo-group-start img)
    (layer-effects-common1 img layer color angle offset-radius radius blur-radius
    opacity layer-mode _"Drop Shadow" 0)
    (gimp-context-set-background old-bg)
    (gimp-image-undo-group-end img)
    (gimp-displays-flush)
   )
)

(script-fu-register
    "script-fu-layer-effects-drop-shadow"
    _"Drop Shadow..."
    _"Create the Drop Shadow on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-COLOR _"Shadow Color" '(0 0 0)
    SF-ADJUSTMENT _"Lighting (degrees)" '(30 0 360 1 15 0 0)
    SF-ADJUSTMENT _"Offset Radius" '(10 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Shadow Radius" '(0 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Shadow Blur Radius" '(5 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Drop Shadow Opacity" '(75 0 100 1 10 0 0)
    SF-OPTION _"Shadow Layer Mode" '(_"Default (Multiply)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
)

(script-fu-menu-register "script-fu-layer-effects-drop-shadow"
                         "<Image>/FX-Foundry/Layer Effects/")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Inner Shadow script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-layer-effects-inner-shadow
            img ;
            layer ;
            color ;
            angle ;
            offset-radius ;
            radius ;
            blur-radius ;
            opacity ;
            layer-mode ;
        )

    (let* (
            (old-bg (car (gimp-context-get-background)))
            (layer-mode (cond ((= layer-mode 0) 3)
            ((= layer-mode 2) 0)
            (layer-mode)))
        )
        (gimp-image-undo-group-start img)
        (layer-effects-common1 img layer color angle offset-radius radius blur-radius
        opacity layer-mode _"Inner Shadow" 1)
        (gimp-context-set-background old-bg)
        (gimp-image-undo-group-end img)
        (gimp-displays-flush)
    )
)
(script-fu-register
    "script-fu-layer-effects-inner-shadow"
    _"Inner Shadow..."
    _"Create the Inner Shadow on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-COLOR _"Shadow Color" '(0 0 0)
    SF-ADJUSTMENT _"Lighting (degrees)" '(30 0 360 1 15 0 0)
    SF-ADJUSTMENT _"Offset Radius" '(5 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Shadow Radius" '(0 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Shadow Blur Radius" '(5 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Drop Shadow Opacity" '(75 0 100 1 10 0 0)
    SF-OPTION _"Shadow Layer Mode" '(_"Default (Multiply)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
)

(script-fu-menu-register "script-fu-layer-effects-inner-shadow"
                         "<Image>/FX-Foundry/Layer Effects/")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Outer Glow script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-layer-effects-outer-glow
            img ;
            layer ;
            color ;
            radius ;
            blur-radius ;
            opacity ;
            layer-mode ;
        )

  (let* (
        (old-bg (car (gimp-context-get-background)))
        (layer-mode (cond ((= layer-mode 0) 4)
        ((= layer-mode 2) 0)
        (layer-mode)))
      )

    (gimp-image-undo-group-start img)
    (layer-effects-common1 img layer color 0 0 radius blur-radius
    opacity layer-mode _"Outer Glow" 0)
    (gimp-image-undo-group-end img)
    (gimp-displays-flush)
  )
)

(script-fu-register
    "script-fu-layer-effects-outer-glow"
    _"Outer Glow..."
    _"Create the Outer Glow on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-COLOR _"Glow Color" '(255 255 191)
    SF-ADJUSTMENT _"Glow Radius" '(2 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Blur Radius" '(10 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Opacity" '(75 0 100 1 10 0 0)
    SF-OPTION _"Glow Layer Mode" '(_"Default (Screen)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
)

(script-fu-menu-register "script-fu-layer-effects-outer-glow"
                         "<Image>/FX-Foundry/Layer Effects/")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Inner Glow script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-layer-effects-inner-glow
            img ;
            layer ;
            color ;
            radius ;
            blur-radius ;
            opacity ;
            layer-mode ;
            glow-type ; Edge(0) or Inside(1)
        )

  (let* (
        (old-bg (car (gimp-context-get-background)))
        (layer-mode (cond ((= layer-mode 0) 4)
        ((= layer-mode 2) 0)
        (layer-mode)))
        (glow-type (+ glow-type 1))
      )

    (gimp-image-undo-group-start img)
    (layer-effects-common1 img layer color 0 0 radius blur-radius
    opacity layer-mode _"Inner Glow" glow-type)
    (gimp-image-undo-group-end img)
    (gimp-displays-flush)
  )
)

(script-fu-register
    "script-fu-layer-effects-inner-glow"
    _"Inner Glow..."
    _"Create the Inner Glow on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-COLOR _"Glow Color" '(255 255 191)
    SF-ADJUSTMENT _"Glow Radius" '(2 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Blur Radius" '(10 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Opacity" '(75 0 100 1 10 0 0)
    SF-OPTION _"Glow Layer Mode" '(_"Default (Screen)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
    SF-OPTION _"Glow Type" '(_"Edge" _"Inner")
)

(script-fu-menu-register "script-fu-layer-effects-inner-glow"
                         "<Image>/FX-Foundry/Layer Effects")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Bevel and Emboss script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-layer-effects-bevel-and-emboss
            img ;
            layer ;
            effect-style ; Outer Bevel(0) Inner Bevel(1)
            ; Emboss(2) Pillow Emboss(3)
            angle ;
            depth ;
            blur-radius ;
            light-color ;
            light-opacity ;
            light-mode ;
            shadow-color ;
            shadow-opacity;
            shadow-mode ;
        )

(let* (
        (old-bg (car (gimp-context-get-background)))
        (light-mode (cond ((= light-mode 0) 4)
        ((= light-mode 2) 0)
        (light-mode)))
        (shadow-mode (cond ((= shadow-mode 0) 3)
        ((= shadow-mode 2) 0)
        (shadow-mode)))
      )

        (gimp-image-undo-group-start img)
        (cond
        ((= effect-style 0) ; Inner Bevel
            (layer-effects-common1 img layer shadow-color angle depth 0 blur-radius
            shadow-opacity shadow-mode _"Bevel Shadow" 0)
            (layer-effects-common1 img layer light-color (+ angle 180) depth 0 blur-radius
            light-opacity light-mode _"Bevel Light" 0)
        )
            ((= effect-style 1) ; Outer Bevel
            (layer-effects-common1 img layer shadow-color (+ angle 180) depth 0 blur-radius
            shadow-opacity shadow-mode _"Bevel Shadow" 1)
            (layer-effects-common1 img layer light-color angle depth 0 blur-radius
            light-opacity light-mode _"Bevel Light" 1)
        )
        ((= effect-style 2) ; Emboss
            (layer-effects-common1 img layer shadow-color angle depth 0 blur-radius
            shadow-opacity shadow-mode _"Emboss Outer Shadow" 0)
            (layer-effects-common1 img layer light-color (+ angle 180) depth 0 blur-radius
            light-opacity light-mode _"Emboss Outer Light" 0)
            (layer-effects-common1 img layer shadow-color (+ angle 180) depth 0 blur-radius
            shadow-opacity shadow-mode _"Emboss Inner Shadow" 1)
            (layer-effects-common1 img layer light-color angle depth 0 blur-radius
            light-opacity light-mode _"Emboss Inner Light" 1)
        )
        ((= effect-style 3) ; Pillow Emboss
            (layer-effects-common1 img layer shadow-color (+ angle 180) depth 0 blur-radius
            shadow-opacity shadow-mode _"Emboss Outer Shadow" 0)
            (layer-effects-common1 img layer light-color angle depth 0 blur-radius
            light-opacity light-mode _"Emboss Outer Light" 0)
            (layer-effects-common1 img layer shadow-color (+ angle 180) depth 0 blur-radius
            shadow-opacity shadow-mode _"Emboss Inner Shadow" 1)
            (layer-effects-common1 img layer light-color angle depth 0 blur-radius
            light-opacity light-mode _"Emboss Inner Light" 1)
        )
        ) ; end of cond
        (gimp-image-undo-group-end img)
        (gimp-displays-flush)
    )
)

(script-fu-register
    "script-fu-layer-effects-bevel-and-emboss"
    _"Bevel and Emboss..."
    _"Create the Bevel and Emboss effects on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-OPTION _"Effect Style" '(_"Outer Bevel" _"Inner Bevel"
    _"Emboss" _"Pillow Emboss")
    SF-ADJUSTMENT _"Lighting (degrees)" '(30 0 360 1 15 0 0)
    SF-ADJUSTMENT _"Depth" '(5 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Blur Radius" '(5 0 100 1 10 0 1)
    SF-COLOR _"Highlight Color" '(255 255 255)
    SF-ADJUSTMENT _"Highlight Opacity" '(75 0 100 1 10 0 0)
    SF-OPTION _"Highlight Layer Mode" '(_"Default (Screen)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
    SF-COLOR _"Shadow Color" '(0 0 0)
    SF-ADJUSTMENT _"Shadow Opacity" '(75 0 100 1 10 0 0)
    SF-OPTION _"Shadow Layer Mode" '(_"Default (Multiply)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
)

(script-fu-menu-register "script-fu-layer-effects-bevel-and-emboss"
                         "<Image>/FX-Foundry/Layer Effects")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Satin Effect script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (script-fu-layer-effects-satin
            img ;
            layer ;
            color ;
            angle ;
            offset-radius ;
            blur-radius ;
            opacity ;
            layer-mode ;
            invert? ;
        )

(let* (
        (old-bg (car (gimp-context-get-background)))
        (width (car (gimp-drawable-width layer)))
        (height (car (gimp-drawable-height layer)))
        (radians (/ (* 2 *pi* angle) 360))
        (x-offset (* offset-radius (sin radians)))
        (y-offset (* offset-radius (cos radians)))
        (layer-mode (cond ((= layer-mode 0) 3)
        ((= layer-mode 2) 0)
        (layer-mode)))
        (satin-layer1 (car (gimp-layer-new img width height RGBA-IMAGE
        _"Satin Effect" 100 NORMAL-MODE)))
        (satin-layer2 (car (gimp-layer-new img width height RGBA-IMAGE
        _"Satin Effect" 100 DIFFERENCE-MODE)))
        (satin-layer)
        (satin-mask1)
        (satin-mask2)
        (satin-mask3)
      )

        (gimp-image-undo-group-start img)
        (gimp-image-add-layer img satin-layer1 -1)
        (gimp-image-add-layer img satin-layer2 -1)
        (gimp-drawable-fill satin-layer1 WHITE-IMAGE-FILL)
        (gimp-drawable-fill satin-layer2 WHITE-IMAGE-FILL)
        (gimp-selection-layer-alpha layer)
        (gimp-context-set-background '(0 0 0))
        (gimp-edit-fill satin-layer1 BG-IMAGE-FILL)
        (gimp-edit-fill satin-layer2 BG-IMAGE-FILL)
        (gimp-drawable-offset satin-layer1 FALSE OFFSET-BACKGROUND x-offset y-offset)
        (gimp-drawable-offset satin-layer2 FALSE OFFSET-BACKGROUND (- x-offset) (- y-offset))

        (set! satin-layer (car (gimp-image-merge-down img satin-layer2 EXPAND-AS-NECESSARY)))
        (set! satin-mask1 (car (gimp-layer-create-mask satin-layer BLACK-MASK)))

        (gimp-layer-add-mask satin-layer satin-mask1)
        (gimp-edit-fill satin-mask1 WHITE-IMAGE-FILL)
        (gimp-selection-none img)
        ;(plug-in-colortoalpha 1 img satin-layer '(255 255 255))
        (if (eqv? invert? TRUE)
        (gimp-invert satin-layer))
        (gimp-edit-copy satin-layer)
        (set! satin-mask2 (car (gimp-floating-sel-anchor
        (car (gimp-edit-paste satin-mask1 0)))))
        ;replaced 2005-11-13
        ; (gimp-image-remove-layer-mask img satin-layer APPLY)
        (gimp-layer-remove-mask satin-layer APPLY)
        (set! satin-mask3 (car (gimp-layer-create-mask satin-layer BLACK-MASK)))

        (gimp-layer-add-mask satin-layer satin-mask3)
        (gimp-selection-layer-alpha layer)
        (gimp-edit-fill satin-mask3 WHITE-IMAGE-FILL)

        (gimp-selection-layer-alpha satin-layer)
        (gimp-context-set-background color)
        (gimp-edit-fill satin-layer BG-IMAGE-FILL)
        (gimp-selection-none img)
        (if (< 0 blur-radius)
        (plug-in-gauss-iir2 1 img satin-layer blur-radius blur-radius))
        (gimp-layer-set-opacity satin-layer opacity)
        (gimp-layer-set-mode satin-layer layer-mode)

        (gimp-image-set-active-layer img layer)
        (gimp-context-set-background old-bg)
        (gimp-image-undo-group-end img)
        (gimp-displays-flush)
        (list satin-layer)
    )
)

(script-fu-register
    "script-fu-layer-effects-satin"
    _"Satin..."
    _"Create the Satin effect on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-COLOR _"Satin Color" '(0 0 0)
    SF-ADJUSTMENT _"Angle" '(30 0 360 1 15 0 0)
    SF-ADJUSTMENT _"Satin Radius" '(10 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Blur Radius" '(10 0 100 1 10 0 1)
    SF-ADJUSTMENT _"Opacity" '(50 0 100 1 10 0 0)
    SF-OPTION _"Satin Layer Mode" '(_"Default (Multiply)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
    SF-TOGGLE _"Invert" TRUE
)

(script-fu-menu-register "script-fu-layer-effects-satin"
                         "<Image>/FX-Foundry/Layer Effects/")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Color Overlay script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (script-fu-layer-effects-color-overlay
    img ;
    layer ;
    color ;
    opacity ;
    layer-mode ;
)

(let* (
        (old-bg (car (gimp-context-get-background)))
        (width (car (gimp-drawable-width layer)))
        (height (car (gimp-drawable-height layer)))
        (layer-mode (cond ((= layer-mode 0) 0)
        ((= layer-mode 2) 0)
        (layer-mode)))
        (color-layer (car (gimp-layer-new img width height RGBA-IMAGE
        _"Color Fill Layer" opacity layer-mode)))
        )

        (gimp-image-undo-group-start img)
        (gimp-image-add-layer img color-layer -1)
        (gimp-drawable-fill color-layer TRANS-IMAGE-FILL)
        (gimp-selection-layer-alpha layer)
        (gimp-context-set-background color)
        (gimp-edit-fill color-layer BG-IMAGE-FILL)
        (gimp-selection-none img)

        (gimp-image-set-active-layer img layer)
        (gimp-context-set-background old-bg)
        (gimp-image-undo-group-end img)
        (gimp-displays-flush)
        (list color-layer)
      )
)

(script-fu-register
    "script-fu-layer-effects-color-overlay"
    _"Color Overlay..."
    _"Create the Color overlay effect on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-COLOR "_Color" '(0 0 0)
    SF-ADJUSTMENT _"Opacity" '(100 0 100 1 10 0 0)
    SF-OPTION _"Color Fill Mode" '(_"Default (Normal)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
)

(script-fu-menu-register "script-fu-layer-effects-color-overlay"
                         "<Image>/FX-Foundry/Layer Effects")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Gradient Overlay script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (script-fu-layer-effects-gradient-overlay
            img ;
            layer ;
            fg-color ;
            bg-color ;
            blend-mode ;
            gradient ;
            angle ;
            scale ;
            opacity ;
            layer-mode ;
            style ;
            repeat ;
         )

  (let* (
        (old-fg (car (gimp-context-get-foreground)))
        (old-bg (car (gimp-context-get-background)))
        (old-gradient (car (gimp-context-get-gradient)))
        (width (car (gimp-drawable-width layer)))
        (height (car (gimp-drawable-height layer)))
        (layer-mode (cond ((= layer-mode 0) 0)
        ((= layer-mode 2) 0)
        (layer-mode)))
        (radians (/ (* 2 *pi* angle) 360))
        (x-distance (* 0.5 scale width (sin radians)))
        (y-distance (* 0.5 scale height (cos radians)))
        (x-center (/ width 2))
        (y-center (/ height 2))
        (x1 (- x-center x-distance))
        (y1 (- y-center y-distance))
        (x2 (+ x-center x-distance))
        (y2 (+ y-center y-distance))
        (gradient-layer (car (gimp-layer-new img width height RGBA-IMAGE
        _"Gradient Fill Layer" opacity layer-mode)))
      )

        (gimp-image-undo-group-start img)
        (gimp-image-add-layer img gradient-layer -1)
        (gimp-drawable-fill gradient-layer TRANS-IMAGE-FILL)
        (gimp-selection-layer-alpha layer)
        (gimp-context-set-foreground fg-color)
        (gimp-context-set-background bg-color)
        (gimp-context-set-gradient gradient)
        ;
        ;hier werden 14 Parameter übergeben, 16 sind aber gefordert
        ;da der Programmierer wie es scheint supersampling nicht beachtet hat,
        ;setze ich das auf FALSE und den fehlenden supersamling threshold auf 0
        ;(sollte durch das FALSE egal sein, welchen Wert das hat)
        ;ausserdem hab' ich auch hier die deprecated procedure ersetzt
        ;
        ; (gimp-edit-blend gradient-layer blend-mode NORMAL-MODE style 100 0 repeat
        ; FALSE 0 0 x1 y1 x2 y2)
        ;
        (gimp-edit-blend gradient-layer blend-mode NORMAL-MODE style 100 0 repeat
        FALSE FALSE 0 0 0 x1 y1 x2 y2)
        (gimp-selection-none img)

        (gimp-image-set-active-layer img layer)
        (gimp-context-set-foreground old-fg)
        (gimp-context-set-background old-bg)
        (gimp-context-set-gradient old-gradient)
        (gimp-image-undo-group-end img)
        (gimp-displays-flush)
        (list gradient-layer)
  )
)

(script-fu-register
    "script-fu-layer-effects-gradient-overlay"
    _"Gradient Overlay..."
    _"Create the Gradient overlay effect on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-COLOR _"Foreground Color" '(127 255 255)
    SF-COLOR _"Background Color" '(127 255 127)
    SF-OPTION _"Blend Mode" '(_"FG-BG RGB" _"FG-BG HSV" _"FG-Trans" _"Custom")
    SF-GRADIENT _"Gradient" _"Sunrise"
    SF-ADJUSTMENT _"Angle" '(30 0 360 1 15 0 0)
    SF-ADJUSTMENT _"Scale" '(1.00 0.05 5 0.05 0.1 2 0)
    SF-ADJUSTMENT _"Opacity" '(100 0 100 1 10 0 0)
    SF-OPTION _"Gradient Fill Mode" '(_"Default (Normal)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
    SF-OPTION _"Gradient Style" '(_"Linear" _"Biliner" _"Radial" _"Square"
    _"Conical Symmetric" _"Conical Asymmetric"
    _"Shapeburst Angular" _"Shapeburst Spherical"
    _"Shapeburst Dimpled" _"Spiral Clockwise"
    _"Spiral Anticlockwise")
    SF-OPTION _"Repeat" '(_"None" _"Sawtooth Wave" _"Triangular Wave")
)

(script-fu-menu-register "script-fu-layer-effects-gradient-overlay"
                         "<Image>/FX-Foundry/Layer Effects")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Pattern Overlay script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (script-fu-layer-effects-pattern-overlay
    img ;
    layer ;
    pattern ;
    opacity ;
    layer-mode ;
)

    (let* (
            (old-pattern (car (gimp-context-get-pattern)))
            (width (car (gimp-drawable-width layer)))
            (height (car (gimp-drawable-height layer)))
            (layer-mode (cond ((= layer-mode 0) 0)
            ((= layer-mode 2) 0)
            (layer-mode)))
            (pattern-layer (car (gimp-layer-new img width height RGBA-IMAGE
            _"Pattern Fill Layer" opacity layer-mode)))
          )

        (gimp-image-undo-group-start img)
        (gimp-image-add-layer img pattern-layer -1)
        (gimp-drawable-fill pattern-layer TRANS-IMAGE-FILL)
        (gimp-selection-layer-alpha layer)
        (gimp-context-set-pattern pattern)
        (gimp-edit-bucket-fill pattern-layer PATTERN-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
        (gimp-selection-none img)

        (gimp-image-set-active-layer img layer)
        (gimp-context-set-pattern old-pattern)
        (gimp-image-undo-group-end img)
        (gimp-displays-flush)
        (list pattern-layer)
    )
)

(script-fu-register
    "script-fu-layer-effects-pattern-overlay"
    _"Pattern Overlay..."
    _"Create the Pattern overlay effect on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-PATTERN _"Pattern" _"Pine?"
    SF-ADJUSTMENT _"Opacity" '(100 0 100 1 10 0 0)
    SF-OPTION _"Pattern Fill Mode" '(_"Default (Normal)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
)

(script-fu-menu-register "script-fu-layer-effects-pattern-overlay"
                         "<Image>/FX-Foundry/Layer Effects")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Add Border script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;FIXME: Outside and center result in filled layer for no alpha image.
(define (script-fu-layer-effects-add-border
            img ;
            layer ;
            type ; Color(0) Gradient(1) Pattern(2)
            size ;
            position ;
            opacity ;
            layer-mode ;
            color ;
            fg-color ;
            bg-color ;
            blend-mode ;
            gradient ;
            angle ;
            scale ;
            style ;
            repeat ;
            pattern ;
            antialias? ;
        )

    (let* (
            (width (car (gimp-drawable-width layer)))
            (height (car (gimp-drawable-height layer)))
            (border-layer (car (gimp-layer-new img width height RGBA-IMAGE
            _"Boder Line" opacity layer-mode)))
            (result-layer)
          )

        (gimp-image-undo-group-start img)
        (gimp-image-add-layer img border-layer -1)
        (gimp-drawable-fill border-layer TRANS-IMAGE-FILL)
        (gimp-selection-layer-alpha layer)
        (cond
            ((= position 0)
            (gimp-selection-shrink img (- size 3)))
            ((= position 1)
            (gimp-selection-grow img (- size 2)))
        ) ; end of cond
        (if (< (car (gimp-selection-is-empty img)) 0)
        (gimp-message _"The selection is empty. Abort.")
            (begin
                (gimp-selection-border img size)
                (gimp-selection-sharpen img)
                (gimp-edit-fill border-layer WHITE-IMAGE-FILL)
                (if (= antialias? TRUE)
                    (begin
                    (gimp-layer-scale border-layer (* 2 width) (* 2 height) 0)
                    (gimp-layer-scale border-layer width height 0)))
                (set! result-layer (car
                (cond
                    ((= type 0)
                    (script-fu-layer-effects-color-overlay
                    img border-layer color opacity layer-mode))
                    ((= type 1)
                    (script-fu-layer-effects-gradient-overlay
                    img border-layer fg-color bg-color blend-mode gradient
                    angle scale opacity layer-mode style repeat))
                    ((= type 2)
                    (script-fu-layer-effects-pattern-overlay
                    img border-layer pattern opacity layer-mode))
                ) ; end of cond
                )) ; end of set! and car
                (gimp-drawable-fill border-layer TRANS-IMAGE-FILL)
                (set! border-layer (car (gimp-image-merge-down
                img result-layer EXPAND-AS-NECESSARY)))
            ) ; end of begin
        ) ; end of if

        (gimp-image-set-active-layer img layer)
        (gimp-image-undo-group-end img)
        (gimp-displays-flush)
        (list border-layer)
    )
)

(script-fu-register
    "script-fu-layer-effects-add-border"
    _"Add Border..."
    _"Create the Add Border effect on the layer with alpha"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-OPTION _"Border Fill Type" '("Color" "Gradient" "Pattern")
    SF-ADJUSTMENT _"Border Size" '(5 3 100 1 10 0 1)
    SF-OPTION _"Border Position" '("Inner Border" "Outer Border" "Center Border")
    SF-ADJUSTMENT _"Opacity" '(100 0 100 1 10 0 0)
    SF-OPTION _"Border Fill Mode" '(_"Default (Normal)" _"Dissolve" _"Normal"
    _"Multiply" _"Screen" _"Overlay" _"Difference"
    _"Addition" _"Subtract" _"Darken" _"Lighten"
    _"Hue" _"Saturation" _"Color" _"Value" _"Divide")
    SF-COLOR _"Color" '(0 0 0)
    SF-COLOR _"Foreground Color" '(127 255 255)
    SF-COLOR _"Background Color" '(127 255 127)
    SF-OPTION _"Blend Mode" '(_"FG-BG RGB" _"FG-BG HSV" _"FG-Trans" _"Custom")
    SF-GRADIENT _"Gradient" _"Sunrise"
    SF-ADJUSTMENT _"Angle" '(30 0 360 1 15 0 0)
    SF-ADJUSTMENT _"Scale" '(1.00 0.05 5 0.05 0.1 2 0)
    SF-OPTION _"Gradient Style" '(_"Linear" _"Biliner" _"Radial" _"Square"
    _"Conical Symmetric" _"Conical Asymmetric"
    _"Shapeburst Angular" _"Shapeburst Spherical"
    _"Shapeburst Dimpled" _"Spiral Clockwise"
    _"Spiral Anticlockwise")
    SF-OPTION _"Repeat" '(_"None" _"Sawtooth Wave" _"Triangular Wave")
    SF-PATTERN _"Pattern" _"Pine?"
    SF-TOGGLE _"Antialias" TRUE
)

(script-fu-menu-register "script-fu-layer-effects-add-border"
                         "<Image>/FX-Foundry/Layer Effects")

;; Version de abcdugimp.free.fr

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Layer Style sample script ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-layer-effects-styles-sample
    img ;
    layer ;
    angle ;
    pattern ;
)

    (let* (
            (old-bg (car (gimp-context-get-background)))
          )

            (gimp-image-undo-group-start img)
            (script-fu-layer-effects-bevel-and-emboss img layer 2 angle 10 10
            '(255 255 255) 75 4
            '( 0 0 0) 75 3)
            (script-fu-layer-effects-gradient-overlay img layer '(255 255 255) '(214 214 214)
            0 _"Default" angle 1.0 25 4 0 0)
            (script-fu-layer-effects-pattern-overlay img layer pattern 100 0)
            (gimp-image-undo-group-end img)
            (gimp-displays-flush)
    )
)
(script-fu-register
    "script-fu-layer-effects-styles-sample"
    _"Style Sample..."
    _"Layer Style sample script"
    "Iccii "
    "Iccii"
    "Aug, 2001"
    "RGBA"
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-ADJUSTMENT _"Angle (Degree)" '(30 0 360 1 10 0 0)
    SF-PATTERN _"Pattern" _"Pine?"
)

(script-fu-menu-register "script-fu-layer-effects-styles-sample"
                         "<Image>/FX-Foundry/Layer Effects")