~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/gradients.pdb

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# The GIMP -- an image manipulation program
 
1
# GIMP - The GNU Image Manipulation Program
2
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
19
19
 
20
 
sub federico_misc {
21
 
    $author = $copyright = 'Federico Mena Quintero';
22
 
    $date = '1997';
23
 
}
24
 
 
25
 
 
26
 
# The defs
27
 
 
28
20
sub gradients_refresh {
29
21
    $blurb = 'Refresh current gradients. This function always succeeds.';
30
22
 
33
25
and updates the gradient dialogs accordingly.
34
26
HELP
35
27
 
36
 
    $author = $copyright = 'Michael Natterer';
37
 
    $date = '2002';
 
28
    &mitch_pdb_misc('2002');
38
29
 
39
30
    %invoke = (
40
 
        code => <<'CODE'
 
31
        code => <<'CODE'
41
32
{
42
 
  gimp_data_factory_data_save (gimp->gradient_factory);
43
 
  gimp_data_factory_data_init (gimp->gradient_factory, FALSE);
 
33
  gimp_data_factory_data_refresh (gimp->gradient_factory);
44
34
}
45
35
CODE
46
36
    );
51
41
 
52
42
    $help = <<'HELP';
53
43
This procedure returns a list of the gradients that are currently loaded.
54
 
You can later use the 'gimp_context_set_gradient' function to
 
44
You can later use the gimp_context_set_gradient() function to
55
45
set the active gradient.
56
46
HELP
57
47
 
58
 
    &federico_misc;
 
48
    &federico_pdb_misc('1997');
59
49
 
60
50
    @inargs = (
61
51
        { name => 'filter', type => 'string', null_ok => 1,
66
56
        { name => 'gradient_list', type => 'stringarray',
67
57
          desc => 'The list of gradient names',
68
58
          array => { name => 'num_gradients',
69
 
                     desc => 'The number of loaded gradients' },
70
 
          init => 1 }
 
59
                     desc => 'The number of loaded gradients' } }
71
60
    );
72
61
 
73
62
    %invoke = (
74
63
        headers => [ qw("core/gimpcontainer-filter.h") ],
75
 
        code => 'gradient_list = gimp_container_get_filtered_name_array (gimp->gradient_factory->container, filter, &num_gradients);'
76
 
    );
77
 
}
78
 
 
79
 
sub sample_num_arg {
80
 
    { name => 'num_samples', type => $_[0] . 'int32',
81
 
      desc => 'The number of samples to take', alias => 'i' }
82
 
}
83
 
 
84
 
sub reverse_arg {
85
 
    { name => 'reverse', type => 'boolean',
86
 
      desc => 'Use the reverse gradient (%%desc%%)' }
87
 
}
88
 
 
89
 
sub sample_outargs {
90
 
    @outargs = (
91
 
        { name => 'color_samples', type => 'floatarray', init => 1,
92
 
          desc => 'Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }',
93
 
          array => { name => 'array_length', no_lib => 1, init => 1,
94
 
                     desc => 'Length of the color_samples array (4 *
95
 
                              num_samples)' } }
 
64
        code => <<'CODE'
 
65
{
 
66
  gradient_list = gimp_container_get_filtered_name_array (gimp->gradient_factory->container,
 
67
                                                          filter, &num_gradients);
 
68
}
 
69
CODE
96
70
    );
97
71
}
98
72
 
99
73
sub gradients_sample_uniform {
100
 
    &std_pdb_deprecated ('gimp_gradient_get_uniform_samples');
 
74
    &std_pdb_deprecated ('gimp-gradient-get-uniform-samples');
101
75
 
102
76
    @inargs = (
103
 
         &sample_num_arg('2 <= '),
104
 
         &reverse_arg
105
 
    );
106
 
    &sample_outargs;
 
77
        { name => 'num_samples', type => '2 <= int32',
 
78
          desc => 'The number of samples to take' },
 
79
        { name => 'reverse', type => 'boolean',
 
80
          desc => 'Use the reverse gradient' }
 
81
    );
 
82
 
 
83
    @outargs = (
 
84
        { name => 'color_samples', type => 'floatarray',
 
85
          desc => 'Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }',
 
86
          array => { name => 'array_length', no_lib => 1,
 
87
                     desc => 'Length of the color_samples array (4 *
 
88
                              num_samples)' } }
 
89
    );
107
90
 
108
91
    %invoke = (
109
 
        vars => [ 'GimpGradient *gradient', 'gdouble pos, delta',
110
 
                  'GimpRGB color', 'gdouble *pv' ],
111
92
        code => <<'CODE'
112
93
{
 
94
  GimpGradient        *gradient;
 
95
  GimpGradientSegment *seg = NULL;
 
96
  gdouble              pos, delta;
 
97
  GimpRGB              color;
 
98
  gdouble             *pv;
 
99
 
113
100
  pos   = 0.0;
114
 
  delta = 1.0 / (i - 1);
 
101
  delta = 1.0 / (num_samples - 1);
115
102
 
116
 
  array_length = i * 4;
 
103
  array_length = num_samples * 4;
117
104
 
118
105
  pv = color_samples = g_new (gdouble, array_length);
119
106
 
120
107
  gradient = gimp_context_get_gradient (context);
121
108
 
122
 
  while (i--)
 
109
  while (num_samples--)
123
110
    {
124
 
      gimp_gradient_get_color_at (gradient, pos, reverse, &color);
 
111
      seg = gimp_gradient_get_color_at (gradient, context, seg,
 
112
                                        pos, reverse, &color);
125
113
 
126
114
      *pv++ = color.r;
127
115
      *pv++ = color.g;
136
124
}
137
125
 
138
126
sub gradients_sample_custom {
139
 
    &std_pdb_deprecated ('gimp_gradient_get_custom_samples');
 
127
    &std_pdb_deprecated ('gimp-gradient-get-custom-samples');
140
128
 
141
129
    @inargs = (
142
 
        { name  => 'positions',
143
 
          type  => 'floatarray',
 
130
        { name  => 'positions', type  => 'floatarray',
144
131
          desc  => 'The list of positions to sample along the gradient',
145
 
          alias => 'pos',
146
 
          array => &sample_num_arg("") },
147
 
        &reverse_arg
 
132
          array => { name => 'num_samples', type => 'int32',
 
133
                     desc => 'The number of samples to take' } },
 
134
        { name => 'reverse', type => 'boolean',
 
135
          desc => 'Use the reverse gradient' }
148
136
    );
149
137
 
150
 
    &sample_outargs;
 
138
    @outargs = (
 
139
        { name => 'color_samples', type => 'floatarray',
 
140
          desc => 'Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }',
 
141
          array => { name => 'array_length', no_lib => 1,
 
142
                     desc => 'Length of the color_samples array (4 *
 
143
                              num_samples)' } }
 
144
    );
151
145
 
152
146
    %invoke = (
153
 
        vars => [ 'GimpGradient *gradient', 'GimpRGB color', 'gdouble *pv' ],
154
147
        code => <<'CODE'
155
148
{
156
 
  array_length = i * 4;
 
149
  GimpGradient        *gradient;
 
150
  GimpGradientSegment *seg = NULL;
 
151
  GimpRGB              color;
 
152
  gdouble             *pv;
 
153
 
 
154
  array_length = num_samples * 4;
157
155
 
158
156
  pv = color_samples = g_new (gdouble, array_length);
159
157
 
160
158
  gradient = gimp_context_get_gradient (context);
161
159
 
162
 
  while (i--)
 
160
  while (num_samples--)
163
161
    {
164
 
      gimp_gradient_get_color_at (gradient, *pos, reverse, &color);
 
162
      seg = gimp_gradient_get_color_at (gradient, context, seg,
 
163
                                        *positions, reverse, &color);
165
164
 
166
165
      *pv++ = color.r;
167
166
      *pv++ = color.g;
168
167
      *pv++ = color.b;
169
168
      *pv++ = color.a;
170
169
 
171
 
      pos++;
 
170
      positions++;
172
171
    }
173
172
}
174
173
CODE
175
174
    );
176
175
}
177
176
 
178
 
sub sample_size_arg {
179
 
    { name => 'sample_size',
180
 
      type => '0 < int32 <= 10000',
181
 
      desc => 'Size of the sample to return when the gradient is changed
182
 
              (%%desc%%)',
183
 
      on_fail => 'sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;',
184
 
      no_success => 1 }
185
 
}
186
 
 
187
177
sub gradients_get_gradient_data {
188
 
    &std_pdb_deprecated ('gimp_gradient_get_uniform_samples');
 
178
    &std_pdb_deprecated ('gimp-gradient-get-uniform-samples');
189
179
 
190
180
    @inargs = (
191
181
        { name => 'name', type => 'string',
192
182
          desc => 'The gradient name ("" means current active gradient)',
193
183
          null_ok => '1' },
194
 
        &sample_size_arg,
195
 
        &reverse_arg
 
184
        { name => 'sample_size', type => '1 <= int32 <= 10000',
 
185
          desc => 'Size of the sample to return when the gradient is changed',
 
186
          no_success => 1 },
 
187
        { name => 'reverse', type => 'boolean',
 
188
          desc => 'Use the reverse gradient' }
196
189
    );
197
190
 
198
191
    @outargs = (
199
 
        { name => 'name', type => 'string',
200
 
          desc => 'The gradient name',
201
 
          alias => 'g_strdup (GIMP_OBJECT (gradient)->name)', no_declare => 1 },
202
 
        { name => 'grad_data', type => 'floatarray', alias => 'values',
203
 
          desc => 'The gradient sample data', init => 1,
 
192
        { name => 'actual_name', type => 'string',
 
193
          desc => 'The gradient name' },
 
194
        { name => 'grad_data', type => 'floatarray',
 
195
          desc => 'The gradient sample data',
204
196
          array => { name => 'width',
205
 
                     desc => 'The gradient sample width (r,g,b,a)',
206
 
                     alias => 'sample_size * 4', no_declare => 1 } }
 
197
                     desc => 'The gradient sample width (r,g,b,a)' } }
207
198
    );
208
199
 
209
200
    %invoke = (
210
 
        vars => [ 'GimpGradient *gradient = NULL' ],
211
201
        code => <<"CODE"
212
202
{
 
203
  GimpGradient *gradient;
 
204
 
 
205
  if (sample_size < 1 || sample_size > 10000)
 
206
    sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;
 
207
 
213
208
  if (name && strlen (name))
214
209
    {
215
210
      gradient = (GimpGradient *)
223
218
 
224
219
  if (gradient)
225
220
    {
226
 
      gdouble *pv;
227
 
      gdouble  pos, delta;
228
 
      GimpRGB  color;
229
 
      gint     i;
 
221
      GimpGradientSegment *seg = NULL;
 
222
      gdouble             *pv;
 
223
      gdouble              pos, delta;
 
224
      GimpRGB              color;
230
225
 
231
 
      i     = sample_size;
232
226
      pos   = 0.0;
233
 
      delta = 1.0 / (i - 1);
234
 
 
235
 
      pv = values = g_new (gdouble, i * 4);
236
 
 
237
 
      while (i--)
 
227
      delta = 1.0 / (sample_size - 1);
 
228
 
 
229
      actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (gradient)));
 
230
      grad_data   = g_new (gdouble, sample_size * 4);
 
231
      width       = sample_size * 4;
 
232
 
 
233
      pv = grad_data;
 
234
 
 
235
      while (sample_size)
238
236
        {
239
 
          gimp_gradient_get_color_at (gradient, pos, reverse, &color);
 
237
          seg = gimp_gradient_get_color_at (gradient, context, seg,
 
238
                                            pos, reverse, &color);
240
239
 
241
240
          *pv++ = color.r;
242
241
          *pv++ = color.g;
254
253
}
255
254
 
256
255
 
257
 
@headers = qw(<string.h> "core/gimp.h" "core/gimpcontext.h" "core/gimplist.h"
258
 
              "core/gimpdatafactory.h" "core/gimpgradient.h");
 
256
@headers = qw(<string.h>
 
257
              "core/gimp.h"
 
258
              "core/gimpcontext.h"
 
259
              "core/gimpdatafactory.h"
 
260
              "core/gimpgradient.h"
 
261
              "core/gimplist.h");
259
262
 
260
263
@procs = qw(gradients_refresh gradients_get_list
261
264
            gradients_sample_uniform gradients_sample_custom
262
265
            gradients_get_gradient_data);
 
266
 
263
267
%exports = (app => [@procs], lib => [@procs]);
264
268
 
265
269
$desc = 'Gradients';