~ubuntu-branches/ubuntu/breezy/gimp/breezy

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-10-04 19:04:46 UTC
  • Revision ID: james.westby@ubuntu.com-20051004190446-ukh32kwk56s4sjhu
Tags: upstream-2.2.8
ImportĀ upstreamĀ versionĀ 2.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# The GIMP -- an image manipulation program
 
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
 
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
 
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 
 
18
# "Perlized" from C source by Andy Thomas <alt@gimp.org>
 
19
 
 
20
sub pdb_misc {
 
21
    $author = $copyright = 'Andy Thomas';
 
22
    $date = '1999';
 
23
}
 
24
 
 
25
# The defs
 
26
 
 
27
sub path_list {
 
28
    $blurb = 'List the paths associated with the passed image.';
 
29
 
 
30
    $help = <<'HELP';
 
31
List the paths associated with the passed image.
 
32
HELP
 
33
 
 
34
    &pdb_misc;
 
35
 
 
36
    @inargs = ( &std_image_arg );
 
37
    $inargs[0]->{desc} = 'The ID of the image to list the paths from';
 
38
 
 
39
    @outargs = (
 
40
        { name => 'path_list', type => 'stringarray',
 
41
          desc => 'List of the paths belonging to this image.',
 
42
          array => { name => 'num_paths',
 
43
                     desc => 'The number of paths returned.' },
 
44
          init => 1 }
 
45
    );
 
46
 
 
47
    %invoke = (
 
48
        code => 'path_list = gimp_container_get_name_array (gimage->vectors, &num_paths);'
 
49
    );
 
50
}
 
51
 
 
52
sub path_get_points {
 
53
    $blurb = 'List the points associated with the named path.';
 
54
 
 
55
    $help = <<'HELP';
 
56
List the points associated with the named path.
 
57
HELP
 
58
 
 
59
    &pdb_misc;
 
60
 
 
61
    @inargs = (
 
62
        &std_image_arg,
 
63
        { name => 'name', type => 'string',
 
64
          desc => 'The name of the path whose points should be listed.' }
 
65
    );
 
66
    $inargs[0]->{desc} = 'The ID of the image to list the paths from.';
 
67
 
 
68
    @outargs = (
 
69
        { name => 'path_type', type => 'int32', init => 1,
 
70
          desc => 'The type of the path. Currently only one type (1 = Bezier)
 
71
                   is supported' },
 
72
        { name => 'path_closed', type => 'int32', init => 1,
 
73
          desc => 'Return if the path is closed. (0 = path open, 1 = path
 
74
                   closed)' },
 
75
        { name => 'points_pairs', type => 'floatarray',
 
76
          desc => 'The points in the path represented as 3 floats. The first is
 
77
                   the x pos, next is the y pos, last is the type of the pnt.
 
78
                   The type field is dependant on the path type. For beziers
 
79
                   (type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR,
 
80
                   2.0 = BEZIER_CONTROL, 3.0 = BEZIER_MOVE). Note all points
 
81
                   are returned in pixel resolution.',
 
82
          init => 1,
 
83
          array => { name => 'num_path_point_details',
 
84
                     desc => 'The number of points returned. Each point is
 
85
                              made up of (x, y, pnt_type) of floats.',
 
86
                     alias => 'num_point_details', init => 1 } }
 
87
    );
 
88
 
 
89
    %invoke = (
 
90
        vars => [ 'GimpVectors *vectors' ],
 
91
        code => <<'CODE'
 
92
{
 
93
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
94
 
 
95
  if (vectors)
 
96
    {
 
97
      GimpVectorsCompatPoint *points;
 
98
      gint num_points;
 
99
 
 
100
      path_type = 1; /* BEZIER (1.2 compat) */
 
101
 
 
102
      points = gimp_vectors_compat_get_points (vectors, &num_points,
 
103
                                               &path_closed);
 
104
 
 
105
      num_point_details = num_points * 3;
 
106
 
 
107
      if (points)
 
108
        {
 
109
          gdouble *curr_point;
 
110
          gint     i;
 
111
 
 
112
          points_pairs = g_new0 (gdouble, num_point_details);
 
113
 
 
114
          for (i = 0, curr_point = points_pairs;
 
115
               i < num_points;
 
116
               i++, curr_point += 3)
 
117
            {
 
118
              curr_point[0] = points[i].x;
 
119
              curr_point[1] = points[i].y;
 
120
              curr_point[2] = points[i].type;
 
121
            }
 
122
 
 
123
          g_free (points);
 
124
        }
 
125
      else
 
126
        success = FALSE;
 
127
    }
 
128
  else
 
129
    success = FALSE;
 
130
}
 
131
CODE
 
132
    );
 
133
}
 
134
 
 
135
sub path_get_current {
 
136
    $blurb = 'The name of the current path. Error if no paths.';
 
137
 
 
138
    $help = <<'HELP';
 
139
The name of the current path. Error if no paths.
 
140
HELP
 
141
 
 
142
    &pdb_misc;
 
143
 
 
144
    @inargs = ( &std_image_arg );
 
145
    $inargs[0]->{desc} = 'The ID of the image to get the current path from.';
 
146
 
 
147
    @outargs = (
 
148
        { name => 'name', type => 'string',
 
149
          desc => 'The name of the current path.',
 
150
          init => 1 }
 
151
    );
 
152
 
 
153
    %invoke = (
 
154
        vars => [ 'GimpVectors *vectors' ],
 
155
        code => <<'CODE'
 
156
{
 
157
  vectors = gimp_image_get_active_vectors (gimage);
 
158
 
 
159
  if (vectors)
 
160
    name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
 
161
  else
 
162
    success = FALSE;
 
163
}
 
164
CODE
 
165
    );
 
166
}
 
167
 
 
168
sub path_set_current {
 
169
    $blurb = 'Sets the current path associated with the passed image.';
 
170
 
 
171
    $help = <<'HELP';
 
172
Sets a named path as the current path.
 
173
HELP
 
174
 
 
175
    &pdb_misc;
 
176
 
 
177
    @inargs = (
 
178
        &std_image_arg,
 
179
        { name => 'name', type => 'string',
 
180
          desc => 'The name of the path to make current.' }
 
181
    );
 
182
    $inargs[0]->{desc} = 'The ID of the image in which a path will become current.';
 
183
 
 
184
    %invoke = (
 
185
        vars => [ 'GimpVectors *vectors' ],
 
186
        code => <<'CODE'
 
187
{
 
188
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
189
 
 
190
  if (vectors)
 
191
    gimp_image_set_active_vectors (gimage, vectors);
 
192
  else
 
193
    success = FALSE;
 
194
}
 
195
CODE
 
196
    );
 
197
}
 
198
 
 
199
sub path_set_points {
 
200
    $blurb = 'Set the points associated with the named path.';
 
201
 
 
202
    $help = <<'HELP';
 
203
Set the points associated with the named path.
 
204
HELP
 
205
 
 
206
    &pdb_misc;
 
207
 
 
208
    @inargs = (
 
209
        &std_image_arg,
 
210
        { name => 'name', type => 'string',
 
211
          desc => 'The name of the path to create. If it exists then a unique
 
212
                   name will be created - query the list of paths if you want
 
213
                   to make sure that the name of the path you create is 
 
214
                   unique. This will be set as the current path.',
 
215
          init => 1 },
 
216
        { name => 'ptype', type => 'int32',
 
217
          desc => 'The type of the path. Currently only one type (1 = Bezier)
 
218
                   is supported.' },
 
219
        { name => 'points_pairs', type => 'floatarray',
 
220
          desc => 'The points in the path represented as 3 floats. The first is
 
221
                   the x pos, next is the y pos, last is the type of the pnt.
 
222
                   The type field is dependant on the path type. For beziers
 
223
                   (type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR,
 
224
                   2.0 = BEZIER_CONTROL, 3.0= BEZIER_MOVE). Note all points are
 
225
                   returned in pixel resolution.',
 
226
          array => { name => 'num_path_points',
 
227
                     desc => 'The number of elements in the array, i.e. the number
 
228
                              of points in the path * 3. Each point is
 
229
                              made up of (x, y, type) of floats. Currently only
 
230
                              the creation of bezier curves is allowed. The type
 
231
                              parameter must be set to (1) to indicate a BEZIER
 
232
                              type curve. Note that for BEZIER curves, points
 
233
                              must be given in the following order: ACCACCAC...
 
234
                              If the path is not closed the last control
 
235
                              point is missed off. Points consist of three
 
236
                              control points (control/anchor/control) so for a
 
237
                              curve that is not closed there must be at least
 
238
                              two points passed (2 x,y pairs). If
 
239
                              (num_path_points/3) % 3 = 0 then the path is
 
240
                              assumed to be closed and the points are
 
241
                              ACCACCACCACC.',
 
242
                     init => 1 } }
 
243
    );
 
244
    $inargs[0]->{desc} = 'The ID of the image to set the paths in.';
 
245
 
 
246
    %invoke = (
 
247
        vars => [ 'gboolean closed = FALSE' ],
 
248
        code  => <<'CODE'
 
249
{
 
250
  if ((num_path_points / 3) % 3 == 0)
 
251
    closed = TRUE;
 
252
  else if ((num_path_points / 3) % 3 != 2)
 
253
    success = FALSE;
 
254
 
 
255
  if (success)
 
256
    {
 
257
      GimpVectors            *vectors;
 
258
      gdouble                *curr_point_pair;
 
259
      GimpVectorsCompatPoint *points;
 
260
      gint                    n_points;
 
261
      gint                    i;
 
262
 
 
263
      n_points = num_path_points / 3;
 
264
 
 
265
      points = g_new0 (GimpVectorsCompatPoint, n_points);
 
266
 
 
267
      for (i = 0, curr_point_pair = points_pairs;
 
268
           i < n_points;
 
269
           i++, curr_point_pair += 3)
 
270
        {
 
271
          points[i].x    = curr_point_pair[0];
 
272
          points[i].y    = curr_point_pair[1];
 
273
          points[i].type = curr_point_pair[2];
 
274
        }
 
275
 
 
276
      vectors = gimp_vectors_compat_new (gimage, name, points, n_points,
 
277
                                         closed);
 
278
 
 
279
      g_free (points);
 
280
 
 
281
      if (vectors)
 
282
        gimp_image_add_vectors (gimage, vectors, 0);
 
283
      else
 
284
        success = FALSE;
 
285
    }
 
286
}
 
287
CODE
 
288
    );
 
289
}
 
290
 
 
291
sub path_stroke_current {
 
292
    $blurb = 'Stroke the current path in the passed image.';
 
293
 
 
294
    $help = <<'HELP';
 
295
Stroke the current path in the passed image.
 
296
HELP
 
297
 
 
298
    &pdb_misc;
 
299
 
 
300
    @inargs = ( &std_image_arg );
 
301
    $inargs[0]->{desc} = 'The ID of the image which contains the path to
 
302
                          stroke.';
 
303
 
 
304
    %invoke = (
 
305
        headers => [ qw("core/gimpstrokedesc.h") ],
 
306
        code => <<'CODE'
 
307
{
 
308
  GimpVectors  *vectors  = gimp_image_get_active_vectors (gimage);
 
309
  GimpDrawable *drawable = gimp_image_active_drawable (gimage);
 
310
 
 
311
  if (vectors && drawable)
 
312
    {
 
313
      GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
 
314
 
 
315
      g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
 
316
 
 
317
      success = gimp_item_stroke (GIMP_ITEM (vectors),
 
318
                                  drawable, context, desc, TRUE);
 
319
 
 
320
      g_object_unref (desc);
 
321
    }
 
322
  else
 
323
    success = FALSE;
 
324
}
 
325
CODE
 
326
    );
 
327
}
 
328
 
 
329
sub  path_get_point_at_dist {
 
330
    $blurb = 'Get point on a path at a specified distance along the path.';
 
331
 
 
332
    $help = <<'HELP';
 
333
This will return the x,y position of a point at a given distance along the
 
334
bezier curve. The distance will be obtained by first digitizing the 
 
335
curve internally and then walking along the curve. For a closed curve the
 
336
start of the path is the first point on the path that was created. This might
 
337
not be obvious. Note the current path is used.
 
338
HELP
 
339
 
 
340
    &pdb_misc;
 
341
 
 
342
    @inargs = (
 
343
        &std_image_arg,
 
344
        { name => 'distance', type => 'float',
 
345
          desc => 'The distance along the path.' }
 
346
    );
 
347
    $inargs[0]->{desc} = 'The ID of the image the paths belongs to';
 
348
 
 
349
    @outargs = (
 
350
        { name => 'x_point', type => 'int32',
 
351
          desc => 'The x position of the point.', init => 1 },
 
352
        { name => 'y_point', type => 'int32',
 
353
          desc => 'The y position of the point.', init => 1 },
 
354
        { name => 'slope', type => 'float',
 
355
          desc => 'The slope (dy / dx) at the specified point.', init => 1 }
 
356
    );
 
357
 
 
358
    %invoke = (
 
359
        vars => [ 'GimpVectors *vectors', 'GimpStroke *stroke',
 
360
                  'gdouble distance_along', 'gdouble stroke_length',
 
361
                  'gdouble stroke_distance', 'GimpCoords position' ],
 
362
        code => <<'CODE'
 
363
{
 
364
  vectors = gimp_image_get_active_vectors (gimage);
 
365
 
 
366
  if (vectors)
 
367
    {
 
368
      distance_along = 0.0;
 
369
      stroke = gimp_vectors_stroke_get_next (vectors, NULL);
 
370
 
 
371
      while (stroke != NULL ) 
 
372
        {
 
373
          stroke_length = gimp_stroke_get_length (stroke, 0.5);
 
374
 
 
375
          if (distance_along + stroke_length < distance) 
 
376
            {
 
377
              distance_along += stroke_length;
 
378
            }
 
379
          else
 
380
            {
 
381
              stroke_distance = distance - distance_along;
 
382
              stroke_distance = stroke_distance < 0 ? 0: stroke_distance;
 
383
 
 
384
              if (!gimp_stroke_get_point_at_dist (stroke, stroke_distance, 0.5,
 
385
                                                  &position, &slope))
 
386
                {
 
387
                  success = FALSE;
 
388
                  break;
 
389
                }
 
390
              else
 
391
                {
 
392
                  success = TRUE;
 
393
                  x_point = ROUND (position.x);
 
394
                  y_point = ROUND (position.y);
 
395
                  break;
 
396
                }
 
397
            }
 
398
 
 
399
          stroke = gimp_vectors_stroke_get_next (vectors, stroke);
 
400
        }
 
401
    }
 
402
  else
 
403
    {
 
404
      success = FALSE;
 
405
    }
 
406
}
 
407
CODE
 
408
    );
 
409
}
 
410
 
 
411
sub path_get_tattoo {
 
412
    $blurb = 'Returns the tattoo associated with the name path.';
 
413
 
 
414
    $help = <<'HELP';
 
415
This procedure returns the tattoo associated with the specified path.  A
 
416
tattoo is a unique and permanent identifier attached to a path that can
 
417
be used to uniquely identify a path within an image even between sessions.
 
418
HELP
 
419
 
 
420
    &pdb_misc;
 
421
 
 
422
    @inargs = (
 
423
        &std_image_arg,
 
424
        { name => 'name', type => 'string',
 
425
          desc => 'The name of the path whose tattoo should be obtained.' }
 
426
    );
 
427
 
 
428
    @outargs = (
 
429
        { name => 'tattoo', type => 'int32',
 
430
          desc => 'The tattoo associated with the named path.', init => 1  }
 
431
    );
 
432
 
 
433
    %invoke = (
 
434
        vars => [ 'GimpVectors *vectors' ],
 
435
        code => <<'CODE'
 
436
{
 
437
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
438
 
 
439
  if (vectors)
 
440
    tattoo = gimp_item_get_tattoo (GIMP_ITEM (vectors));
 
441
  else
 
442
    success = FALSE;
 
443
}
 
444
CODE
 
445
    );
 
446
}
 
447
 
 
448
sub path_set_tattoo {
 
449
    $blurb = 'Sets the tattoo associated with the named path.';
 
450
 
 
451
    $help = <<'HELP';
 
452
This procedure sets the tattoo associated with the specified path.  A
 
453
tattoo is a unique and permenant identifier attached to a path that
 
454
can be used to uniquely identify a path within an image even between
 
455
sessions. Note that the value passed to this function must have been
 
456
obtained from a previous call to path_get_tattoo.
 
457
HELP
 
458
 
 
459
    &pdb_misc;
 
460
 
 
461
    @inargs = (
 
462
        &std_image_arg,
 
463
        { name => 'name', type => 'string',
 
464
          desc => 'the name of the path whose tattoo should be set' },
 
465
        { name => 'tattovalue', type => 'int32',
 
466
          desc => "The tattoo associated with the name path. Only values
 
467
                   returned from 'path_get_tattoo' should be used here",
 
468
                   init => 1  }
 
469
    );
 
470
 
 
471
    %invoke = (
 
472
        vars => [ 'GimpVectors *vectors' ],
 
473
        code => <<'CODE'
 
474
{
 
475
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
476
 
 
477
  if (vectors)
 
478
    gimp_item_set_tattoo (GIMP_ITEM (vectors), tattovalue);
 
479
  else
 
480
    success = FALSE;
 
481
}
 
482
CODE
 
483
    );
 
484
}
 
485
 
 
486
 
 
487
sub get_path_by_tattoo {
 
488
    $blurb = 'Return the name of the path with the given tattoo.';
 
489
 
 
490
    $help = <<'HELP';
 
491
The procedure returns the name of the path in the specified image
 
492
which has the passed tattoo. The tattoos are unique within the image
 
493
and will be preserved across sessions and through renaming of the path.
 
494
An error is returned if no path with the specified tattoo can be found.
 
495
HELP
 
496
 
 
497
    &pdb_misc;
 
498
 
 
499
    @inargs = (
 
500
        &std_image_arg,
 
501
        { name => 'tattoo', type => 'int32',
 
502
          desc => 'The tattoo of the required path.' }
 
503
    );
 
504
 
 
505
    @outargs = (
 
506
        { name => 'name', type => 'string', init => 1,
 
507
          desc => 'The name of the path with the specified tattoo.' }
 
508
    );
 
509
 
 
510
    %invoke = (
 
511
        vars => [ 'GimpVectors *vectors' ],
 
512
        code => <<'CODE'
 
513
{
 
514
  vectors = gimp_image_get_vectors_by_tattoo (gimage, tattoo);
 
515
 
 
516
  if (vectors)
 
517
    name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
 
518
  else
 
519
    success = FALSE;
 
520
}
 
521
CODE
 
522
    );
 
523
}
 
524
 
 
525
sub path_delete {
 
526
    $blurb = 'Delete the named path associated with the passed image.';
 
527
 
 
528
    $help = <<'HELP';
 
529
Delete the named path.
 
530
HELP
 
531
 
 
532
    &pdb_misc;
 
533
 
 
534
    @inargs = (
 
535
        &std_image_arg,
 
536
        { name => 'name', type => 'string',
 
537
          desc => 'The name of the path to delete.' }
 
538
    );
 
539
    $inargs[0]->{desc} = 'The ID of the image to delete the path from.';
 
540
 
 
541
    %invoke = (
 
542
        vars => [ 'GimpVectors *vectors' ],
 
543
        code => <<'CODE'
 
544
{
 
545
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
546
 
 
547
  if (vectors)
 
548
    gimp_image_remove_vectors (gimage, vectors);
 
549
  else
 
550
    success = FALSE;
 
551
}
 
552
CODE
 
553
    );
 
554
}
 
555
 
 
556
sub path_get_locked {
 
557
    $blurb = 'Returns the locked status associated with the named path.';
 
558
 
 
559
    $help = <<'HELP';
 
560
This procedure returns the lock status associated with the specified
 
561
path.  A path can be "locked" which means that the transformation
 
562
tool operations will also apply to the path.
 
563
HELP
 
564
 
 
565
    &pdb_misc;
 
566
 
 
567
    @inargs = (
 
568
        &std_image_arg,
 
569
        { name => 'name', type => 'string',
 
570
          desc => 'The name of the path whose locked status should be
 
571
                   obtained.' }
 
572
    );
 
573
 
 
574
    @outargs = (
 
575
        { name => 'lockstatus', type => 'int32',
 
576
          desc => 'The lock status associated with the name path. 0 is
 
577
                   returned if the path is not locked. 1 is returned if the
 
578
                   path is locked.', init => 1  }
 
579
    );
 
580
 
 
581
    %invoke = (
 
582
        vars => [ 'GimpVectors *vectors' ],
 
583
        code => <<'CODE'
 
584
{
 
585
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
586
 
 
587
  if (vectors)
 
588
    lockstatus = gimp_item_get_linked (GIMP_ITEM (vectors));
 
589
  else
 
590
    success = FALSE;
 
591
}
 
592
CODE
 
593
    );
 
594
}
 
595
 
 
596
sub path_set_locked {
 
597
    $blurb = 'Set the locked status associated with the named path.';
 
598
 
 
599
    $help = <<'HELP';
 
600
This procedure sets the lock status associated with the specified path.  A
 
601
path can be "locked" which means that the transformation tool operations
 
602
will also apply to the path.
 
603
HELP
 
604
 
 
605
    &pdb_misc;
 
606
 
 
607
    @inargs = (
 
608
        &std_image_arg,
 
609
        { name => 'name', type => 'string',
 
610
          desc => 'the name of the path whose locked status should be set' },
 
611
        { name => 'lockstatus', type => 'int32',
 
612
          desc => 'The lock status associated with the name path. 0 if the
 
613
                   path is not locked. 1 if the path is to be locked',
 
614
          init => 1 }
 
615
    );
 
616
 
 
617
    %invoke = (
 
618
        vars => [ 'GimpVectors *vectors' ],
 
619
        code => <<'CODE'
 
620
{
 
621
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
622
 
 
623
  if (vectors)
 
624
    gimp_item_set_linked (GIMP_ITEM (vectors), lockstatus, TRUE);
 
625
  else
 
626
    success = FALSE;
 
627
}
 
628
CODE
 
629
    );
 
630
}
 
631
 
 
632
sub path_to_selection {
 
633
    $blurb = 'Transforms the active path into a selection';
 
634
 
 
635
    $help = <<'HELP';
 
636
This procedure renders the desired path into the current selection.
 
637
HELP
 
638
 
 
639
 
 
640
    $author = $copyright = 'Joao S. O. Bueno';
 
641
    $date = '2003';
 
642
 
 
643
    @inargs = (
 
644
        &std_image_arg,
 
645
        { name => 'name', type => 'string',
 
646
          desc => 'The name of the path which should be made into selection.' },
 
647
        { name => 'op', type => 'enum GimpChannelOps',
 
648
          desc => 'The desired operation with current selection.' },
 
649
        { name => 'antialias', type => 'boolean',
 
650
          desc => 'Antialias selection.' },
 
651
        { name => 'feather', type => 'boolean',
 
652
          desc => 'Feather selection.' },
 
653
        { name => 'feather_radius_x', type => 'float',
 
654
          desc => 'Feather radius x.'  },
 
655
        { name => 'feather_radius_y', type => 'float',
 
656
          desc => 'Feather radius y.'  }
 
657
    );
 
658
 
 
659
    %invoke = (
 
660
        vars => [ 'GimpVectors *vectors' ],
 
661
        code => <<'CODE'
 
662
{
 
663
  vectors = gimp_image_get_vectors_by_name (gimage, name);
 
664
 
 
665
  if (vectors)
 
666
    gimp_channel_select_vectors (gimp_image_get_mask (gimage),
 
667
                                 _("Path to Selection"),
 
668
                                 vectors,
 
669
                                 op,
 
670
                                 antialias,
 
671
                                 feather,
 
672
                                 feather_radius_x,
 
673
                                 feather_radius_y);
 
674
  else
 
675
    success = FALSE;
 
676
}
 
677
CODE
 
678
    );
 
679
}
 
680
 
 
681
sub path_import {
 
682
    $blurb = 'Import paths from an SVG file.';
 
683
 
 
684
    $help = <<'HELP';
 
685
This procedure imports paths from an SVG file. This is a temporary solution
 
686
until the new vectors PDB API is in place. Don't rely on this function
 
687
being available in future GIMP releases.
 
688
HELP
 
689
 
 
690
    $author = $copyright = 'Sven Neumann';
 
691
    $date = '2003';
 
692
 
 
693
    @inargs = (
 
694
        &std_image_arg,
 
695
        { name => 'filename', type => 'string', no_validate => 1,
 
696
          desc => 'The name of the SVG file to import.' },
 
697
        { name => 'merge', type => 'boolean',
 
698
          desc => 'Merge paths into a single vectors object.' },
 
699
        { name => 'scale', type => 'boolean',
 
700
          desc => 'Scale the SVG to image dimensions.' }
 
701
    );
 
702
 
 
703
    %invoke = (
 
704
        headers => [ qw("vectors/gimpvectors-import.h") ],
 
705
        code    => 'success = gimp_vectors_import_file (gimage, filename, merge, scale, -1, NULL);'
 
706
    );
 
707
}
 
708
 
 
709
@headers = qw(<string.h> "core/gimp.h" "core/gimplist.h"
 
710
              "core/gimpchannel-select.h"
 
711
              "vectors/gimpanchor.h" "vectors/gimpbezierstroke.h"
 
712
              "vectors/gimpvectors.h" "vectors/gimpvectors-compat.h"
 
713
              "gimp-intl.h");
 
714
 
 
715
@procs = qw(path_list path_get_current path_set_current path_delete
 
716
            path_get_points path_set_points
 
717
            path_stroke_current path_get_point_at_dist
 
718
            path_get_tattoo path_set_tattoo get_path_by_tattoo
 
719
            path_get_locked path_set_locked path_to_selection
 
720
            path_import);
 
721
%exports = (app => [@procs], lib => [@procs]);
 
722
 
 
723
$desc = 'Paths';
 
724
 
 
725
1;