File: gradient.pdb

package info (click to toggle)
gimp 2.2.13-1etch4
  • links: PTS
  • area: main
  • in suites: etch
  • size: 94,832 kB
  • ctags: 47,113
  • sloc: ansic: 524,858; xml: 36,798; lisp: 9,870; sh: 9,409; makefile: 7,923; python: 2,674; perl: 2,589; yacc: 520; lex: 334
file content (980 lines) | stat: -rw-r--r-- 26,581 bytes parent folder | download | duplicates (3)
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
# The GIMP -- an image manipulation program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis

# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

sub shlomi_misc {
    $author = $copyright = 'Shlomi Fish';
    $date   = '2003';
    $since  = '2.2';
}

sub federico_misc {
    $author = $copyright = 'Federico Mena Quintero';
    $date   = '1997';
    $since  = '2.2';
}

sub gradient_arg () {{
    name => 'name',
    type => 'string',
    desc => 'The gradient name'
}}

sub _gen_gradient_search_for_segment_code
{
    my $action_on_success = shift;

    chomp $action_on_success;

    $action_on_success =~ /^(\s*)/;
    my $indent = $1;

    $action_on_success =~ s/^$indent/' ' x 10/meg;

    return <<"CODE";
{
  gradient = (GimpGradient *)
    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);

  if (gradient)
    {
      GimpGradientSegment *seg;

      seg = gimp_gradient_segment_get_nth (gradient->segments, segment);

      if (seg)
        {
$action_on_success
        }
      else
        success = FALSE;
    }
  else
    success = FALSE;
}

CODE
}

sub other_side
{
    my $side = shift;

    return ($side eq "left") ? "right" : "left";
}

sub _grad_and_seg_params
{
    return
        ( &gradient_arg,
          { name => 'segment', type => '0 <= int32',
            desc => 'The index of the segment within the gradient' }
        );
}

sub _gen_gradient_set_side_color
{
    my $side = shift;

    my $other_side = other_side($side);

    $blurb = "Retrieves the $side endpoint color of the specified gradient and segment";

    $help = <<"HELP";
This procedure retrieves the $side endpoint color of the specified segment of
the specified gradient.
HELP

    &shlomi_misc;

    @inargs = (
        &_grad_and_seg_params,
        { name => 'color', type => 'color',
          desc => "The color to set" },
        { name => "opacity", type => '0 <= float <= 100.0',
          desc => "The opacity to set for the endpoint" }
    );

    @outargs = (
    );

    my @blend_params = ("&color","&(seg->${other_side}_color)");

    if ($side eq "right") {
        @blend_params = reverse(@blend_params);
    }

    %invoke = (
        vars => [ 'GimpGradient *gradient = NULL' ],
        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
color.a = opacity / 100.0;
gimp_gradient_segment_set_${side}_color (gradient, seg, &color);
CODE
    );
}

sub _gen_gradient_get_side_color
{
    my $side = shift;

    $blurb = "Retrieves the $side endpoint color of the specified gradient and segment";

    $help = <<"HELP";
This procedure retrieves the $side endpoint color of the specified segment of
the specified gradient.
HELP

    &shlomi_misc;

    @inargs = (
        &_grad_and_seg_params,
    );

    @outargs = (
        { name => 'color', type => 'color',
          desc => "The return color", void_ret => 1, init => 1 },
        { name => "opacity", type => 'float', init => 1,
          desc => "The opacity of the endpoint" }
    );

    %invoke = (
        vars => [ 'GimpGradient *gradient = NULL' ],
        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
gimp_gradient_segment_get_${side}_color (gradient, seg, &color);
opacity = color.a * 100.0;
CODE
    );
}

sub _gen_gradient_get_pos
{
    my $side = shift;

    my $side_endpoint =
        (($side eq "middle") ?
            "middle point" :
            "$side endpoint"
        );

    $blurb = "Retrieves the $side_endpoint position of the specified gradient and segment";

    $help = <<"HELP";
This procedure retrieves the $side_endpoint position of the specified segment of
the specified gradient.
HELP

    &shlomi_misc;

    @inargs = &_grad_and_seg_params;

    @outargs = (
        { name => 'pos', type => 'float',
          desc => "The return position", void_ret => 1, init => 1 }
    );

    %invoke = (
        vars => [ 'GimpGradient *gradient = NULL' ],
        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
pos = gimp_gradient_segment_get_${side}_pos (gradient, seg);
CODE
    );
}

sub _gen_gradient_set_pos
{
    my $side = shift;

    my $side_endpoint =
        (($side eq "middle") ?
            "middle point" :
            "$side endpoint"
        );

    $blurb = "Sets the $side_endpoint position of the specified gradient and segment";

    my %betweens =
    (
        'left' =>  ("the position of the middle point to the left to " .
                   "the middle point of the current segement"),
        'right' => ("the position of the middle point of the current " .
                    "segment and the middle point of the segment to " .
                    "the right"),
        'middle' => ("the two endpoints of the segment"),
    );

    $help = <<"HELP";
This procedure sets the $side_endpoint position of the specified segment of
the specified gradient. The final position will be between $betweens{$side}.

This procedure returns the final position.
HELP

    &shlomi_misc;

    @inargs = (
        &_grad_and_seg_params,
        { name => 'pos', type => "0.0 <= float <= 1.0",
          desc => "The position to set the guidepoint in." }
    );

    @outargs = (
        { name => 'final_pos', type => 'float',
          desc => "The return position", void_ret => 1, init => 1 }
    );

    %invoke = (
        vars => [ 'GimpGradient *gradient = NULL' ],
        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
final_pos =
  gimp_gradient_segment_set_${side}_pos (gradient, seg, pos);
CODE
    );
}


# The defs

sub gradient_new {
    $blurb = "Creates a new gradient";
    $help  = "This procedure creates a new, uninitialized gradient";

    &shlomi_misc;

    @inargs = (
	{ name => 'name', type => 'string',
	  desc => 'The requested name of the new gradient' }
    );

    @outargs = (
	{ name => 'name', type => 'string',
	  desc => 'The actual new gradient name',
	  alias => 'g_strdup (GIMP_OBJECT (data)->name)', no_declare => 1 },
    );

    %invoke = (
        vars => [ 'GimpData *data = NULL'],
        code => <<'CODE'
{
  if (strlen (name))
    data = gimp_data_factory_data_new (gimp->gradient_factory, name);

  success = (data != NULL);
}
CODE
    );
}

sub gradient_duplicate {
    $blurb = "Duplicates a gradient";
    $help  = "This procedure creates an identical gradient by a different name";

    &shlomi_misc;

    @inargs = (
        &gradient_arg
    );

    @outargs = (
	{ name => 'name', type => 'string',
	  desc => "The name of the gradient's copy",
	  alias => 'g_strdup (GIMP_OBJECT (gradient_copy)->name)',
          no_declare => 1 }
    );

    %invoke = (
	vars => [ 'GimpGradient *gradient = NULL',
                  'GimpGradient *gradient_copy = NULL' ],
        code => <<"CODE"
{
  gradient = (GimpGradient *)
    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);

  if (gradient)
    {
      gradient_copy = (GimpGradient *)
        gimp_data_factory_data_duplicate (gimp->gradient_factory,
                                          GIMP_DATA (gradient));

      success = (gradient_copy != NULL);
    }
  else
    success = FALSE;
}
CODE
    );
}

sub gradient_rename {
    $blurb = "Rename a gradient";
    $help  = "This procedure renames a gradient";

    &shlomi_misc;

    @inargs = (
        &gradient_arg,
        { name => 'new_name', type => 'string',
          desc => "The new name of the gradient" }
    );

    @outargs = (
	{ name => 'name', type => 'string',
	  desc => "The actual new name of the gradient",
	  alias => 'g_strdup (GIMP_OBJECT (gradient)->name)', no_declare => 1 }
    );

    %invoke = (
	vars => [ 'GimpGradient *gradient = NULL' ],
	code => <<"CODE"
{
  gradient = (GimpGradient *)
    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);

  if (gradient && GIMP_DATA (gradient)->writable)
    gimp_object_set_name (GIMP_OBJECT (gradient), new_name);
  else
    success = FALSE;
}
CODE
    );
}

sub gradient_delete {
    $blurb = "Deletes a gradient";
    $help  = "This procedure deletes a gradient";

    &shlomi_misc;

    @inargs = (
        &gradient_arg
    );

    %invoke = (
	vars => [ 'GimpGradient *gradient = NULL' ],
	code => <<"CODE"
{
  gradient = (GimpGradient *)
    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);

  if (gradient && GIMP_DATA (gradient)->deletable)
    {
      GError *error = NULL;

      success = gimp_data_factory_data_delete (gimp->gradient_factory,
                                               GIMP_DATA (gradient),
                                               TRUE, &error);

      if (! success)
        {
          g_message (error->message);
          g_clear_error (&error);
        }
    }
  else
    success = FALSE;
}
CODE
    );
}

sub sample_num_arg {
    { name => 'num_samples', type => $_[0] . 'int32',
      desc => 'The number of samples to take' }
}

sub reverse_arg {
    { name => 'reverse', type => 'boolean',
      desc => 'Use the reverse gradient (%%desc%%)' }
}

sub sample_outargs {
    @outargs = (
        { name => 'color_samples', type => 'floatarray', init => 1,
          void_ret => 1,
	  desc => 'Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }',
	  array => { init => 1,
                     desc => 'Length of the color_samples array (4 *
			      num_samples)' } }
    );
}

sub gradient_get_uniform_samples {
    $blurb = 'Sample the specified in uniform parts.';

    $help = <<'HELP';
This procedure samples the active gradient in the
specified number of uniform parts. It returns a list of floating-point values
which correspond to the RGBA values for each sample. The minimum number of
samples to take is 2, in which case the returned colors will correspond to the
{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples
is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.
HELP

    &federico_misc;

    @inargs = (
         &gradient_arg,
	 &sample_num_arg('2 <= '),
	 &reverse_arg
    );

    &sample_outargs;

    %invoke = (
	vars => [ 'GimpGradient *gradient' ],
	code => <<'CODE'
{
  gradient = (GimpGradient *)
    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);

  if (gradient)
    {
      gdouble  pos   = 0.0;
      gdouble  delta = 1.0 / (num_samples - 1);
      gdouble *sample;

      num_color_samples = num_samples * 4;

      sample = color_samples = g_new (gdouble, num_color_samples);

      while (num_samples--)
        {
          GimpRGB color;

          gimp_gradient_get_color_at (gradient, pos, reverse, &color);

          *sample++ = color.r;
          *sample++ = color.g;
          *sample++ = color.b;
          *sample++ = color.a;

          pos += delta;
        }
    }
  else
    success = FALSE;
}
CODE
    );
}

sub gradient_get_custom_samples {
    $blurb = 'Sample the spacified gradient in custom positions.';

    $help = <<'HELP';
This procedure samples the active gradient in the specified number of
points. The procedure will sample the gradient in the specified
positions from the list. The left endpoint of the gradient corresponds
to position 0.0, and the right endpoint corresponds to 1.0. The
procedure returns a list of floating-point values which correspond to
the RGBA values for each sample.
HELP

    &federico_misc;

    @inargs = (
         &gradient_arg,
	{ name  => 'positions',
	  type  => 'floatarray',
	  desc  => 'The list of positions to sample along the gradient',
	  alias => 'pos',
	  array => &sample_num_arg("") },
	&reverse_arg
    );

    &sample_outargs;

    %invoke = (
	vars => [ 'GimpGradient *gradient' ],
	code => <<'CODE'
{
  gradient = (GimpGradient *)
    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);

  if (gradient)
    {
      gdouble *sample;

      num_color_samples = num_samples * 4;

      sample = color_samples = g_new (gdouble, num_color_samples);

      while (num_samples--)
        {
          GimpRGB color;

          gimp_gradient_get_color_at (gradient, *pos, reverse, &color);

          *sample++ = color.r;
          *sample++ = color.g;
          *sample++ = color.b;
          *sample++ = color.a;

          pos++;
        }
    }
  else
    success = FALSE;
}
CODE
    );
}

sub gradient_segment_get_left_color
{
    &_gen_gradient_get_side_color("left");
}

sub gradient_segment_get_right_color
{
    &_gen_gradient_get_side_color("right");
}

sub gradient_segment_set_left_color
{
    &_gen_gradient_set_side_color("left");
}

sub gradient_segment_set_right_color
{
    &_gen_gradient_set_side_color("right");
}

sub gradient_segment_get_left_pos
{
    &_gen_gradient_get_pos("left");
}

sub gradient_segment_get_right_pos
{
    &_gen_gradient_get_pos("right");
}

sub gradient_segment_get_middle_pos
{
    &_gen_gradient_get_pos("middle");
}

sub gradient_segment_set_left_pos
{
    &_gen_gradient_set_pos("left");
}

sub gradient_segment_set_right_pos
{
    &_gen_gradient_set_pos("right");
}

sub gradient_segment_set_middle_pos
{
    &_gen_gradient_set_pos("middle");
}

sub gradient_segment_get_blending_function
{
    $blurb = "Retrieves the gradient segment's blending function";

    $help = <<'HELP';
This procedure retrieves the blending function of the segment at the
specified gradient name and segment index.
HELP

    &shlomi_misc;

    @inargs = &_grad_and_seg_params;

    @outargs = (
        { name => 'blend_func', type => 'enum GimpGradientSegmentType',
          desc => "The blending function of the segment: { %%desc%% }",
          void_ret => 1, init => 1 }
    );

    %invoke = (
        vars => [ 'GimpGradient *gradient = NULL' ],
        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
blend_func =
  gimp_gradient_segment_get_blending_function (gradient, seg);
CODE
    );
}

sub gradient_segment_get_coloring_type
{
    $blurb = "Retrieves the gradient segment's coloring type";

    $help = <<'HELP';
This procedure retrieves the coloring type of the segment at the
specified gradient name and segment index.
HELP

    &shlomi_misc;

    @inargs = &_grad_and_seg_params;

    @outargs = (
        { name => 'coloring_type', type => 'enum GimpGradientSegmentColor',
          desc => "The coloring type of the segment: { %%desc%% }",
          void_ret => 1, init => 1 }
    );

    %invoke = (
        vars => [ 'GimpGradient *gradient = NULL' ],
        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
coloring_type =
  gimp_gradient_segment_get_coloring_type (gradient, seg);
CODE
    );
}

sub _gen_gradient_operate_on_segments_range
{
    my %args = (@_);

    $blurb = $args{blurb};

    $help = $args{help};

    &shlomi_misc;

    @inargs = (
        &gradient_arg,
        { name => 'start_segment', type => '0 <= int32',
          desc => 'The index of the first segment to operate on' },
        { name => 'end_segment', type => 'int32',
          desc => 'The index of the last segment to operate on. If negative, the selection will extend to the end of the string.' },
        @{$args{inargs}},
    );

    @outargs = @{$args{outargs}};

    my $action_on_success = $args{action_on_success};
    chomp $action_on_success;

    $action_on_success =~ /^(\s*)/;
    my $indent = $1;

    $action_on_success =~ s/^$indent/' ' x 14/meg;

    %invoke = (
        vars => [ 'GimpGradient *gradient = NULL' ],
        code => <<"CODE",
{
  gradient = (GimpGradient *)
    gimp_container_get_child_by_name (gimp->gradient_factory->container, name);

  if (gradient)
    {
      GimpGradientSegment *start_seg, *end_seg;
      start_seg = gimp_gradient_segment_get_nth (gradient->segments,
                                                 start_segment);
      if (start_seg)
        {
          if ((end_segment < start_segment) && (end_segment >= 0))
            {
              /* Do Nothing */
              success = FALSE;
            }
          else
            {
              if (end_segment < 0)
                {
                  end_seg = NULL;
                }
              else
                {
                  end_seg = gimp_gradient_segment_get_nth (start_seg,
                                                           end_segment -
                                                           start_segment);
                }

              /* Success */
$action_on_success
            }
        }
      else
        {
          success = FALSE;
        }
    }
}
CODE
    );
}

sub gradient_segment_range_set_blending_function
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Change the blending function of a segments range",
        'help' => <<'HELP',
This function changes the blending function of a segment range to the
specified blending function.
HELP
        'inargs' => [
             { name => "blending_function",
               type => 'enum GimpGradientSegmentType',
               desc => "The Blending Function: { %%desc%% }" }
        ],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_set_blending_function (gradient,
                                                   start_seg,
                                                   end_seg,
                                                   blending_function);
CODE
    );
}

sub gradient_segment_range_set_coloring_type
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Change the coloring type of a segments range",
        'help' => <<'HELP',
This function changes the coloring type of a segment range to the
specified coloring type.
HELP
        'inargs' => [
            { name => "coloring_type", type => 'enum GimpGradientSegmentColor',
              desc => "The Coloring Type: { %%desc%% }" }
        ],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_set_coloring_type (gradient,
                                               start_seg,
                                               end_seg,
                                               coloring_type);
CODE
    );
}

sub gradient_segment_range_flip
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Flip the segment range",
        'help' => <<'HELP',
This function flips a segment range.
HELP
        'inargs' => [],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_flip (gradient,
                                  start_seg,
                                  end_seg,
                                  NULL, NULL);
CODE
    );
}

sub gradient_segment_range_replicate
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Replicate the segment range",
        'help' => <<'HELP',
This function replicates a segment range a given number of times. Instead
of the original segment range, several smaller scaled copies of it
will appear in equal widths.
HELP
        'inargs' => [
            { 'name' => "replicate_times", 'type' => "2 <= int32 <= 20",
              'desc' => "The number of times to replicate" }
        ],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_replicate (gradient,
                                       start_seg,
                                       end_seg,
                                       replicate_times,
                                       NULL, NULL);
CODE
    );
}

sub gradient_segment_range_split_midpoint
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Splits each segment in the segment range at midpoint",
        'help' => <<'HELP',
This function splits each segment in the segment range at its midpoint.
HELP
        'inargs' => [],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_split_midpoint (gradient,
                                            start_seg,
                                            end_seg,
                                            NULL, NULL);
CODE
    );
}

sub gradient_segment_range_split_uniform
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Splits each segment in the segment range uniformly",
        'help' => <<'HELP',
This function splits each segment in the segment range uniformly according
to the number of times specified by the parameter.
HELP
        'inargs' => [
            { 'name' => "split_parts", 'type' => "2 <= int32 <= 20",
              'desc' => "The number of uniform divisions to split each segment to" }
        ],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_split_uniform (gradient,
                                           start_seg,
                                           end_seg,
                                           split_parts,
                                           NULL, NULL);
CODE
    );
}

sub gradient_segment_range_delete
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Delete the segment range",
        'help' => <<'HELP',
This function deletes a segment range.
HELP
        'inargs' => [],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_delete (gradient,
                                    start_seg,
                                    end_seg,
                                    NULL, NULL);
CODE
    );
}

sub gradient_segment_range_redistribute_handles
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Uniformly redistribute the segment range's handles",
        'help' => <<'HELP',
This function redistributes the handles of the specified segment range of the
specified gradient, so they'll be evenly spaced.
HELP
        'inargs' => [],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_redistribute_handles (gradient,
                                                  start_seg,
                                                  end_seg);
CODE
    );
}

sub gradient_segment_range_blend_colors
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Blend the colors of the segment range.",
        'help' => <<'HELP',
This function blends the colors (but not the opacity) of the segments'
range of the gradient. Using it, the colors' transition will be uniform
across the range.
HELP
        'inargs' => [],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_blend (gradient,
                                   start_seg, end_seg,
                                   &start_seg->left_color,
                                   &end_seg->right_color,
                                   TRUE, FALSE);
CODE
    );
}

sub gradient_segment_range_blend_opacity
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Blend the opacity of the segment range.",
        'help' => <<'HELP',
This function blends the opacity (but not the colors) of the segments'
range of the gradient. Using it, the opacity's transition will be uniform
across the range.
HELP
        'inargs' => [],
        'outargs' => [],
        'action_on_success' => <<'CODE',
gimp_gradient_segment_range_blend (gradient,
                                   start_seg, end_seg,
                                   &start_seg->left_color,
                                   &end_seg->right_color,
                                   FALSE, TRUE);
CODE
    );
}

sub gradient_segment_range_move
{
    &_gen_gradient_operate_on_segments_range(
        'blurb' => "Move the position of an entire segment range by a delta.",
        'help' => <<'HELP',
This funtions moves the position of an entire segment range by a delta. The
actual delta (which is returned) will be limited by the control points of the
neighboring segments.
HELP
        'inargs' => [
            { 'name' => "delta", 'type' => "-1.0 <= float <= 1.0",
              'desc' => "The delta to move the segment range" },
            { 'name' => "control_compress", 'type' => "boolean",
              'desc' => "Whether or not to compress the neighboring segments" }
        ],
        'outargs' => [
            { 'name' => "final_delta", 'type' => "float", init => 1,
              'desc' => "The final delta by which the range moved" }
        ],
        'action_on_success' => <<'CODE',
final_delta = gimp_gradient_segment_range_move (gradient,
                                                start_seg,
                                                end_seg,
                                                delta,
                                                control_compress);

CODE
    );
}

@headers = qw(<string.h> "core/gimp.h" "core/gimpcontext.h"
              "core/gimpgradient.h" "core/gimpcontainer.h"
              "core/gimpdatafactory.h" "core/gimplist.h");

@procs = qw(gradient_new gradient_duplicate gradient_rename gradient_delete
            gradient_get_uniform_samples gradient_get_custom_samples
            gradient_segment_get_left_color gradient_segment_set_left_color
            gradient_segment_get_right_color gradient_segment_set_right_color
            gradient_segment_get_left_pos gradient_segment_set_left_pos
            gradient_segment_get_middle_pos gradient_segment_set_middle_pos
            gradient_segment_get_right_pos gradient_segment_set_right_pos
            gradient_segment_get_blending_function
            gradient_segment_get_coloring_type
            gradient_segment_range_set_blending_function 
            gradient_segment_range_set_coloring_type
            gradient_segment_range_flip
            gradient_segment_range_replicate
            gradient_segment_range_split_midpoint
            gradient_segment_range_split_uniform
            gradient_segment_range_delete
            gradient_segment_range_redistribute_handles
            gradient_segment_range_blend_colors
            gradient_segment_range_blend_opacity
            gradient_segment_range_move);
%exports = (app => [@procs], lib => [@procs]);

$desc = 'Gradient';

1;