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' },
59
desc => 'The number of loaded gradients' } }
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);'
80
{ name => 'num_samples', type => $_[0] . 'int32',
81
desc => 'The number of samples to take', alias => 'i' }
85
{ name => 'reverse', type => 'boolean',
86
desc => 'Use the reverse gradient (%%desc%%)' }
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 *
66
gradient_list = gimp_container_get_filtered_name_array (gimp->gradient_factory->container,
67
filter, &num_gradients);
99
73
sub gradients_sample_uniform {
100
&std_pdb_deprecated ('gimp_gradient_get_uniform_samples');
74
&std_pdb_deprecated ('gimp-gradient-get-uniform-samples');
103
&sample_num_arg('2 <= '),
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' }
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 *
109
vars => [ 'GimpGradient *gradient', 'gdouble pos, delta',
110
'GimpRGB color', 'gdouble *pv' ],
94
GimpGradient *gradient;
95
GimpGradientSegment *seg = NULL;
114
delta = 1.0 / (i - 1);
101
delta = 1.0 / (num_samples - 1);
116
array_length = i * 4;
103
array_length = num_samples * 4;
118
105
pv = color_samples = g_new (gdouble, array_length);
120
107
gradient = gimp_context_get_gradient (context);
109
while (num_samples--)
124
gimp_gradient_get_color_at (gradient, pos, reverse, &color);
111
seg = gimp_gradient_get_color_at (gradient, context, seg,
112
pos, reverse, &color);
138
126
sub gradients_sample_custom {
139
&std_pdb_deprecated ('gimp_gradient_get_custom_samples');
127
&std_pdb_deprecated ('gimp-gradient-get-custom-samples');
142
{ name => 'positions',
143
type => 'floatarray',
130
{ name => 'positions', type => 'floatarray',
144
131
desc => 'The list of positions to sample along the gradient',
146
array => &sample_num_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' }
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 *
153
vars => [ 'GimpGradient *gradient', 'GimpRGB color', 'gdouble *pv' ],
156
array_length = i * 4;
149
GimpGradient *gradient;
150
GimpGradientSegment *seg = NULL;
154
array_length = num_samples * 4;
158
156
pv = color_samples = g_new (gdouble, array_length);
160
158
gradient = gimp_context_get_gradient (context);
160
while (num_samples--)
164
gimp_gradient_get_color_at (gradient, *pos, reverse, &color);
162
seg = gimp_gradient_get_color_at (gradient, context, seg,
163
*positions, reverse, &color);
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
183
on_fail => 'sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;',
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');
191
181
{ name => 'name', type => 'string',
192
182
desc => 'The gradient name ("" means current active gradient)',
193
183
null_ok => '1' },
184
{ name => 'sample_size', type => '1 <= int32 <= 10000',
185
desc => 'Size of the sample to return when the gradient is changed',
187
{ name => 'reverse', type => 'boolean',
188
desc => 'Use the reverse gradient' }
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)' } }
210
vars => [ 'GimpGradient *gradient = NULL' ],
203
GimpGradient *gradient;
205
if (sample_size < 1 || sample_size > 10000)
206
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;
213
208
if (name && strlen (name))
215
210
gradient = (GimpGradient *)