1
# GIMP - The GNU Image Manipulation Program
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
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.
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.
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.
18
sub vectors_is_valid {
19
$blurb = 'Returns TRUE if the vectors object is valid.';
22
This procedure checks if the given vectors ID is valid and refers to an
23
existing vectors object.
26
&neo_pdb_misc('2007', '2.4');
29
{ name => 'vectors', type => 'vectors', no_validate => 1,
30
desc => 'The vectors object to check' }
34
{ name => 'valid', type => 'boolean',
35
desc => 'Whether the vectors ID is valid' }
41
valid = (GIMP_IS_VECTORS (vectors) &&
42
gimp_item_is_attached (GIMP_ITEM (vectors)));
49
$blurb = 'Creates a new empty vectors object.';
52
Creates a new empty vectors object. Needs to be added to an image
53
using gimp_image_add_vectors().
56
&simon_pdb_misc('2005', '2.4');
59
{ name => 'image', type => 'image',
60
desc => 'The image' },
61
{ name => 'name', type => 'string',
62
desc => 'the name of the new vector object.' }
66
{ name => 'vectors', type => 'vectors',
67
desc => 'the current vector object, 0 if no vector exists
74
vectors = gimp_vectors_new (image, name);
80
sub vectors_get_image {
81
$blurb = 'Returns the vectors objects image.';
82
$help = 'Returns the vectors objects image.';
84
&simon_pdb_misc('2005', '2.4');
87
{ name => 'vectors', type => 'vectors',
88
desc => 'The vectors object' }
92
{ name => 'image', type => 'image',
93
desc => 'The vectors image' }
99
image = gimp_item_get_image (GIMP_ITEM (vectors));
105
sub vectors_get_name {
106
$blurb = 'Gets the name of the vectors object.';
107
$help = 'Gets the name of the vectors object.';
109
&simon_pdb_misc('2005', '2.4');
112
{ name => 'vectors', type => 'vectors',
113
desc => 'The vectors object' }
117
{ name => 'name', type => 'string',
118
desc => 'The name of the vectors object' }
124
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
130
sub vectors_set_name {
131
$blurb = 'Sets the name of the vectors object.';
132
$help = 'Sets the name of the vectors object.';
134
&simon_pdb_misc('2005', '2.4');
137
{ name => 'vectors', type => 'vectors',
138
desc => 'The vectors object' },
139
{ name => 'name', type => 'string',
140
desc => 'the new name of the path' }
146
success = gimp_item_rename (GIMP_ITEM (vectors), name);
152
sub vectors_get_visible {
153
$blurb = 'Gets the visibility of the vectors object.';
154
$help = 'Gets the visibility of the vectors object.';
156
&simon_pdb_misc('2005', '2.4');
159
{ name => 'vectors', type => 'vectors',
160
desc => 'The vectors object' }
164
{ name => 'visible', type => 'boolean',
165
desc => 'TRUE if the path is visible, FALSE otherwise' }
171
visible = gimp_item_get_visible (GIMP_ITEM (vectors));
177
sub vectors_set_visible {
178
$blurb = 'Sets the visibility of the vectors object.';
179
$help = 'Sets the visibility of the vectors object.';
181
&simon_pdb_misc('2005', '2.4');
184
{ name => 'vectors', type => 'vectors',
185
desc => 'The vectors object' },
186
{ name => 'visible', type => 'boolean',
187
desc => 'Whether the path is visible' }
193
gimp_item_set_visible (GIMP_ITEM (vectors), visible, TRUE);
199
sub vectors_get_linked {
200
$blurb = 'Gets the linked state of the vectors object.';
201
$help = 'Gets the linked state of the vectors object.';
203
&simon_pdb_misc('2005', '2.4');
206
{ name => 'vectors', type => 'vectors',
207
desc => 'The vectors object' }
211
{ name => 'linked', type => 'boolean',
212
desc => 'TRUE if the path is linked, FALSE otherwise' }
218
linked = gimp_item_get_linked (GIMP_ITEM (vectors));
224
sub vectors_set_linked {
225
$blurb = 'Sets the linked state of the vectors object.';
226
$help = 'Sets the linked state of the vectors object.';
228
&simon_pdb_misc('2005', '2.4');
231
{ name => 'vectors', type => 'vectors',
232
desc => 'The vectors object' },
233
{ name => 'linked', type => 'boolean',
234
desc => 'Whether the path is linked' }
240
gimp_item_set_linked (GIMP_ITEM (vectors), linked, TRUE);
246
sub vectors_get_tattoo {
247
$blurb = 'Get the tattoo of the vectors object.';
248
$help = 'Get the tattoo state of the vectors object.';
250
&simon_pdb_misc('2005', '2.4');
253
{ name => 'vectors', type => 'vectors',
254
desc => 'The vectors object' }
258
{ name => 'tattoo', type => 'int32',
259
desc => 'The vectors tattoo' }
265
tattoo = gimp_item_get_tattoo (GIMP_ITEM (vectors));
271
sub vectors_set_tattoo {
272
$blurb = 'Set the tattoo of the vectors object.';
273
$help = 'Set the tattoo of the vectors object.';
275
&simon_pdb_misc('2005', '2.4');
278
{ name => 'vectors', type => 'vectors',
279
desc => 'The vectors object' },
280
{ name => 'tattoo', type => 'int32',
281
desc => 'the new tattoo' }
287
gimp_item_set_tattoo (GIMP_ITEM (vectors), tattoo);
293
sub vectors_get_strokes {
294
$blurb = 'List the strokes associated with the passed path.';
297
Returns an Array with the stroke-IDs associated with the passed path.
300
&simon_pdb_misc('2005', '2.4');
303
{ name => 'vectors', type => 'vectors',
304
desc => 'The vectors object' }
308
{ name => 'stroke_ids', type => 'int32array',
309
desc => 'List of the strokes belonging to the path.',
310
array => { name => 'num_strokes',
311
desc => 'The number of strokes returned.' } }
317
num_strokes = gimp_vectors_get_n_strokes (vectors);
321
GimpStroke *cur_stroke;
324
stroke_ids = g_new (gint32, num_strokes);
326
for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL);
328
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
330
stroke_ids[i] = gimp_stroke_get_ID (cur_stroke);
339
sub vectors_stroke_get_length {
340
$blurb = 'Measure the length of the given stroke.';
341
$help = 'Measure the length of the given stroke.';
343
&simon_pdb_misc('2005', '2.4');
346
{ name => 'vectors', type => 'vectors',
347
desc => 'The vectors object' },
348
{ name => 'stroke_id', type => 'int32',
349
desc => 'The stroke ID' },
350
{ name => 'precision', type => 'float',
351
desc => 'The precision used for the approximation' }
355
{ name => 'length', type => 'float',
356
desc => 'The length (in pixels) of the given stroke.' }
362
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
365
length = gimp_stroke_get_length (stroke, precision);
373
sub vectors_stroke_get_point_at_dist {
374
$blurb = 'Get point at a specified distance along the stroke.';
377
This will return the x,y position of a point at a given distance along the
378
stroke. The distance will be obtained by first digitizing the
379
curve internally and then walking along the curve. For a closed stroke the
380
start of the path is the first point on the path that was created. This might
381
not be obvious. If the stroke is not long enough, a "valid" flag will be FALSE.
384
&simon_pdb_misc('2005', '2.4');
387
{ name => 'vectors', type => 'vectors',
388
desc => 'The vectors object' },
389
{ name => 'stroke_id', type => 'int32',
390
desc => 'The stroke ID' },
391
{ name => 'dist', type => 'float',
392
desc => 'The given distance.' },
393
{ name => 'precision', type => 'float',
394
desc => 'The precision used for the approximation' }
398
{ name => 'x_point', type => 'float', void_ret => 1,
399
desc => 'The x position of the point.' },
400
{ name => 'y_point', type => 'float',
401
desc => 'The y position of the point.' },
402
{ name => 'slope', type => 'float',
403
desc => 'The slope (dy / dx) at the specified point.' },
404
{ name => 'valid', type => 'boolean',
405
desc => 'Indicator for the validity of the returned data.' }
411
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
417
valid = gimp_stroke_get_point_at_dist (stroke, dist, precision,
419
x_point = valid ? coord.x : 0;
420
y_point = valid ? coord.y : 0;
429
sub vectors_remove_stroke {
430
$blurb = 'remove the stroke from a vectors object.';
433
Remove the stroke from a vectors object.
436
&simon_pdb_misc('2005', '2.4');
439
{ name => 'vectors', type => 'vectors',
440
desc => 'The vectors object' },
441
{ name => 'stroke_id', type => 'int32',
442
desc => 'The stroke ID' }
448
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
451
gimp_vectors_stroke_remove (vectors, stroke);
459
sub vectors_stroke_close {
460
$blurb = 'closes the specified stroke.';
463
Closes the specified stroke.
466
&simon_pdb_misc('2005', '2.4');
469
{ name => 'vectors', type => 'vectors',
470
desc => 'The vectors object' },
471
{ name => 'stroke_id', type => 'int32',
472
desc => 'The stroke ID' }
478
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
481
gimp_stroke_close (stroke);
490
sub vectors_stroke_translate {
491
$blurb = 'translate the given stroke.';
494
Translate the given stroke.
497
&simon_pdb_misc('2005', '2.4');
500
{ name => 'vectors', type => 'vectors',
501
desc => 'The vectors object' },
502
{ name => 'stroke_id', type => 'int32',
503
desc => 'The stroke ID' },
504
{ name => "off_x", type => 'int32',
505
desc => "Offset in x direction" },
506
{ name => "off_y", type => 'int32',
507
desc => "Offset in y direction" }
513
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
516
gimp_stroke_translate (stroke, off_x, off_y);
524
sub vectors_stroke_scale {
525
$blurb = 'scales the given stroke.';
528
Scale the given stroke.
531
&simon_pdb_misc('2005', '2.4');
534
{ name => 'vectors', type => 'vectors',
535
desc => 'The vectors object' },
536
{ name => 'stroke_id', type => 'int32',
537
desc => 'The stroke ID' },
538
{ name => "scale_x", type => 'float',
539
desc => "Scale factor in x direction" },
540
{ name => "scale_y", type => 'float',
541
desc => "Scale factor in y direction" }
547
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
550
gimp_stroke_scale (stroke, scale_x, scale_y);
558
sub vectors_stroke_rotate {
559
$blurb = 'rotates the given stroke.';
562
Rotates the given stroke around given center by angle (in degrees).
565
&joao_pdb_misc('2006', '2.4');
567
{ name => 'vectors', type => 'vectors',
568
desc => 'The vectors object' },
569
{ name => 'stroke_id', type => 'int32',
570
desc => 'The stroke ID' },
571
{ name => "center_x", type => 'float',
572
desc => "X coordinate of the rotation center" },
573
{ name => "center_y", type => 'float',
574
desc => "Y coordinate of the rotation center" },
575
{ name => "angle", type => 'float',
576
desc => "angle to rotate about" }
582
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
585
gimp_stroke_rotate (stroke, center_x, center_y, angle);
593
sub vectors_stroke_flip {
594
$blurb = 'flips the given stroke.';
597
Rotates the given stroke around given center by angle (in degrees).
600
&joao_pdb_misc('2006', '2.4');
602
{ name => 'vectors', type => 'vectors',
603
desc => 'The vectors object' },
604
{ name => 'stroke_id', type => 'int32',
605
desc => 'The stroke ID' },
606
{ name => "flip_type",
607
type => 'enum GimpOrientationType (no GIMP_ORIENTATION_UNKNOWN)',
608
desc => "Flip orientation, either vertical or horizontal" },
609
{ name => "axis", type => 'float',
610
desc => "axis coordinate about which to flip, in pixels" }
616
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
619
gimp_stroke_flip (stroke, flip_type, axis);
627
sub vectors_stroke_flip_free {
628
$blurb = 'flips the given stroke about an arbitrary axis.';
631
Flips the given stroke about an arbitrary axis. Axis is defined by two coordinates
632
in the image (in pixels), through which the flipping axis passes.
635
&joao_pdb_misc('2006', '2.4');
637
{ name => 'vectors', type => 'vectors',
638
desc => 'The vectors object' },
639
{ name => 'stroke_id', type => 'int32',
640
desc => 'The stroke ID' },
641
{ name => "x1", type => 'float',
642
desc => "X coordinate of the first point of the flipping axis" },
643
{ name => "y1", type => 'float',
644
desc => "Y coordinate of the first point of the flipping axis" },
645
{ name => "x2", type => 'float',
646
desc => "X coordinate of the second point of the flipping axis" },
647
{ name => "y2", type => 'float',
648
desc => "Y coordinate of the second point of the flipping axis" },
655
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
658
gimp_stroke_flip_free (stroke, x1, y1, x2, y2);
666
sub vectors_stroke_get_points {
667
$blurb = 'returns the control points of a stroke.';
670
returns the control points of a stroke. The interpretation of the coordinates
671
returned depends on the type of the stroke. For Gimp 2.4 this is always a
672
bezier stroke, where the coordinates are the control points.
675
&simon_pdb_misc('2006', '2.4');
678
{ name => 'vectors', type => 'vectors',
679
desc => 'The vectors object' },
680
{ name => 'stroke_id', type => 'int32',
681
desc => 'The stroke ID' }
685
{ name => 'type', type => 'enum GimpVectorsStrokeType',
686
desc => 'type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now).' },
687
{ name => 'controlpoints', type => 'floatarray',
688
desc => 'List of the control points for the stroke (x0, y0, x1, y1, ...).',
689
array => { name => 'num_points',
690
desc => 'The number of floats returned.' } },
691
{ name => 'closed', type => 'boolean',
692
desc => 'Whether the stroke is closed or not.' }
698
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
700
if (stroke && GIMP_IS_BEZIER_STROKE (stroke))
702
GArray *points_array;
705
points_array = gimp_stroke_control_points_get (stroke, &closed);
709
num_points = points_array->len;
710
controlpoints = g_new (gdouble, num_points * 2);
712
type = GIMP_VECTORS_STROKE_TYPE_BEZIER;
713
for (i = 0; i < num_points; i++)
715
controlpoints[2*i] = g_array_index (points_array,
716
GimpAnchor, i).position.x;
717
controlpoints[2*i+1] = g_array_index (points_array,
718
GimpAnchor, i).position.y;
720
g_array_free (points_array, TRUE);
734
sub vectors_stroke_interpolate {
735
$blurb = 'returns polygonal approximation of the stroke.';
738
returns polygonal approximation of the stroke.
741
&simon_pdb_misc('2005', '2.4');
744
{ name => 'vectors', type => 'vectors',
745
desc => 'The vectors object' },
746
{ name => 'stroke_id', type => 'int32',
747
desc => 'The stroke ID' },
748
{ name => 'precision', type => 'float',
749
desc => 'The precision used for the approximation' }
753
{ name => 'coords', type => 'floatarray',
754
desc => 'List of the coords along the path (x0, y0, x1, y1, ...).',
755
array => { name => 'num_coords',
756
desc => 'The number of floats returned.' } },
757
{ name => 'closed', type => 'boolean',
758
desc => 'Whether the stroke is closed or not.' }
764
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
768
GArray *coords_array;
771
coords_array = gimp_stroke_interpolate (stroke, precision, &closed);
775
num_coords = coords_array->len;
776
coords = g_new (gdouble, num_coords * 2);
778
for (i = 0; i < num_coords; i++)
780
coords[2*i] = g_array_index (coords_array, GimpCoords, i).x;
781
coords[2*i+1] = g_array_index (coords_array, GimpCoords, i).y;
783
g_array_free (coords_array, TRUE);
797
sub vectors_stroke_new_from_points {
798
$blurb = 'Adds a stroke of a given type to the vectors object.';
801
Adds a stroke of a given type to the vectors object. The coordinates of the
802
control points can be specified.
803
For now only strokes of the type GIMP_VECTORS_STROKE_TYPE_BEZIER are supported.
804
The control points are specified as a pair of float values for the x- and
806
The Bezier stroke type needs a multiple of three control points. Each Bezier
807
segment endpoint (anchor, A) has two additional control points (C) associated.
808
They are specified in the order CACCACCAC...
811
&simon_pdb_misc('2006', '2.4');
814
{ name => 'vectors', type => 'vectors',
815
desc => 'The vectors object' },
816
{ name => 'type', type => 'enum GimpVectorsStrokeType',
817
desc => 'type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now).' },
818
{ name => 'controlpoints', type => 'floatarray',
819
desc => 'List of the x- and y-coordinates of the control points.',
820
array => { name => 'num_points',
821
desc => 'The number of elements in the array, i.e. the
822
number of controlpoints in the stroke * 2
823
(x- and y-coordinate).' } },
824
{ name => 'closed', type => 'boolean',
825
desc => 'Whether the stroke is to be closed or not.' }
829
{ name => 'stroke_id', type => 'int32',
830
desc => 'The stroke ID of the newly created stroke.' }
838
GimpCoords default_coords = GIMP_COORDS_DEFAULT_VALUES;
843
if (type == GIMP_VECTORS_STROKE_TYPE_BEZIER &&
846
coords = g_new (GimpCoords, num_points);
847
for (i = 0; i < num_points; i++)
849
coords[i] = default_coords;
850
coords[i].x = controlpoints[i*2];
851
coords[i].y = controlpoints[i*2+1];
854
stroke = gimp_stroke_new_from_coords (type, coords, num_points/2, closed);
857
gimp_vectors_stroke_add (vectors, stroke);
858
stroke_id = gimp_stroke_get_ID (stroke);
870
sub vectors_bezier_stroke_new_moveto {
871
$blurb = 'Adds a bezier stroke with a single moveto to the vectors object.';
874
Adds a bezier stroke with a single moveto to the vectors object.
877
&simon_pdb_misc('2005', '2.4');
880
{ name => 'vectors', type => 'vectors',
881
desc => 'The vectors object' },
882
{ name => 'x0', type => 'float',
883
desc => 'The x-coordinate of the moveto' },
884
{ name => 'y0', type => 'float',
885
desc => 'The y-coordinate of the moveto' }
889
{ name => 'stroke_id', type => 'int32',
890
desc => 'The resulting stroke' }
897
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
902
stroke = gimp_bezier_stroke_new_moveto (&coord0);
903
gimp_vectors_stroke_add (vectors, stroke);
904
stroke_id = gimp_stroke_get_ID (stroke);
910
sub vectors_bezier_stroke_lineto {
911
$blurb = 'Extends a bezier stroke with a lineto.';
914
Extends a bezier stroke with a lineto.
917
&simon_pdb_misc('2005', '2.4');
920
{ name => 'vectors', type => 'vectors',
921
desc => 'The vectors object' },
922
{ name => 'stroke_id', type => 'int32',
923
desc => 'The stroke ID' },
924
{ name => 'x0', type => 'float',
925
desc => 'The x-coordinate of the lineto' },
926
{ name => 'y0', type => 'float',
927
desc => 'The y-coordinate of the lineto' }
933
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
937
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
942
gimp_bezier_stroke_lineto (stroke, &coord0);
951
sub vectors_bezier_stroke_conicto {
952
$blurb = 'Extends a bezier stroke with a conic bezier spline.';
955
Extends a bezier stroke with a conic bezier spline. Actually a
956
cubic bezier spline gets added that realizes the shape of a conic
960
&simon_pdb_misc('2005', '2.4');
963
{ name => 'vectors', type => 'vectors',
964
desc => 'The vectors object' },
965
{ name => 'stroke_id', type => 'int32',
966
desc => 'The stroke ID' },
967
{ name => 'x0', type => 'float',
968
desc => 'The x-coordinate of the control point' },
969
{ name => 'y0', type => 'float',
970
desc => 'The y-coordinate of the control point' },
971
{ name => 'x1', type => 'float',
972
desc => 'The x-coordinate of the end point' },
973
{ name => 'y1', type => 'float',
974
desc => 'The y-coordinate of the end point' }
980
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
984
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
985
GimpCoords coord1 = GIMP_COORDS_DEFAULT_VALUES;
993
gimp_bezier_stroke_conicto (stroke, &coord0, &coord1);
1002
sub vectors_bezier_stroke_cubicto {
1003
$blurb = 'Extends a bezier stroke with a cubic bezier spline.';
1006
Extends a bezier stroke with a cubic bezier spline.
1009
&simon_pdb_misc('2005', '2.4');
1012
{ name => 'vectors', type => 'vectors',
1013
desc => 'The vectors object' },
1014
{ name => 'stroke_id', type => 'int32',
1015
desc => 'The stroke ID' },
1016
{ name => 'x0', type => 'float',
1017
desc => 'The x-coordinate of the first control point' },
1018
{ name => 'y0', type => 'float',
1019
desc => 'The y-coordinate of the first control point' },
1020
{ name => 'x1', type => 'float',
1021
desc => 'The x-coordinate of the second control point' },
1022
{ name => 'y1', type => 'float',
1023
desc => 'The y-coordinate of the second control point' },
1024
{ name => 'x2', type => 'float',
1025
desc => 'The x-coordinate of the end point' },
1026
{ name => 'y2', type => 'float',
1027
desc => 'The y-coordinate of the end point' }
1033
GimpStroke *stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
1037
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
1038
GimpCoords coord1 = GIMP_COORDS_DEFAULT_VALUES;
1039
GimpCoords coord2 = GIMP_COORDS_DEFAULT_VALUES;
1050
gimp_bezier_stroke_cubicto (stroke, &coord0, &coord1, &coord2);
1059
sub vectors_bezier_stroke_new_ellipse {
1060
$blurb = 'Adds a bezier stroke describing an ellipse the vectors object.';
1063
Adds a bezier stroke describing an ellipse the vectors object.
1066
&simon_pdb_misc('2005', '2.4');
1069
{ name => 'vectors', type => 'vectors',
1070
desc => 'The vectors object' },
1071
{ name => 'x0', type => 'float',
1072
desc => 'The x-coordinate of the center' },
1073
{ name => 'y0', type => 'float',
1074
desc => 'The y-coordinate of the center' },
1075
{ name => 'radius_x', type => 'float',
1076
desc => 'The radius in x direction' },
1077
{ name => 'radius_y', type => 'float',
1078
desc => 'The radius in y direction' },
1079
{ name => 'angle', type => 'float',
1080
desc => 'The angle the x-axis of the ellipse
1081
(radians, counterclockwise)' }
1085
{ name => 'stroke_id', type => 'int32',
1086
desc => 'The resulting stroke' }
1093
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
1098
stroke = gimp_bezier_stroke_new_ellipse (&coord0, radius_x, radius_y, angle);
1099
gimp_vectors_stroke_add (vectors, stroke);
1100
stroke_id = gimp_stroke_get_ID (stroke);
1106
sub vectors_to_selection {
1107
$blurb = 'Transforms the specified vectors object into a selection';
1110
This procedure renders the desired vectors object into the current selection
1111
of the image the vectors object belongs to.
1114
&simon_pdb_misc('2006', '2.4');
1117
{ name => 'vectors', type => 'vectors',
1118
desc => 'The vectors object to render to the selection' },
1119
{ name => 'operation', type => 'enum GimpChannelOps',
1120
desc => 'The desired operation with current selection' },
1121
{ name => 'antialias', type => 'boolean',
1122
desc => 'Antialias selection.' },
1123
{ name => 'feather', type => 'boolean',
1124
desc => 'Feather selection.' },
1125
{ name => 'feather_radius_x', type => 'float',
1126
desc => 'Feather radius x.' },
1127
{ name => 'feather_radius_y', type => 'float',
1128
desc => 'Feather radius y.' }
1136
image = gimp_item_get_image (GIMP_ITEM (vectors));
1139
gimp_channel_select_vectors (gimp_image_get_mask (image),
1140
_("Path to Selection"),
1156
sub vectors_import_from_file {
1157
$blurb = 'Import paths from an SVG file.';
1160
This procedure imports paths from an SVG file. SVG elements other than
1161
paths and basic shapes are ignored.
1164
&simon_pdb_misc('2006', '2.4');
1167
{ name => 'image', type => 'image',
1168
desc => 'The image' },
1169
{ name => 'filename', type => 'string', no_validate => 1,
1170
desc => 'The name of the SVG file to import.' },
1171
{ name => 'merge', type => 'boolean',
1172
desc => 'Merge paths into a single vectors object.' },
1173
{ name => 'scale', type => 'boolean',
1174
desc => 'Scale the SVG to image dimensions.' }
1178
{ name => 'vectors_ids', type => 'int32array', void_ret => 1,
1179
desc => 'The list of newly created vectors',
1180
array => { name => 'num_vectors',
1181
desc => 'The number of newly created vectors' } }
1185
headers => [ qw("vectors/gimpvectors-import.h") ],
1188
GList *list, *vectors_list = NULL;
1190
success = gimp_vectors_import_file (image, filename,
1191
merge, scale, -1, &vectors_list, NULL);
1195
num_vectors = g_list_length (vectors_list);
1201
vectors_ids = g_new (gint32, num_vectors);
1203
list = vectors_list;
1204
for (i = 0; i < num_vectors; i++, list = g_list_next (list))
1205
vectors_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));
1207
g_list_free (vectors_list);
1215
sub vectors_import_from_string {
1216
$blurb = 'Import paths from an SVG string.';
1219
This procedure works like gimp_vectors_import_from_file() but takes a string
1220
rather than reading the SVG from a file. This allows you to write scripts that
1221
generate SVG and feed it to GIMP.
1224
&simon_pdb_misc('2006', '2.4');
1227
{ name => 'image', type => 'image',
1228
desc => 'The image' },
1229
{ name => 'string', type => 'string', no_validate => 1,
1230
desc => 'A string that must be a complete and valid SVG document.' },
1231
{ name => 'length', type => 'int32',
1232
desc => 'Number of bytes in string or -1 if the string is NULL
1234
{ name => 'merge', type => 'boolean',
1235
desc => 'Merge paths into a single vectors object.' },
1236
{ name => 'scale', type => 'boolean',
1237
desc => 'Scale the SVG to image dimensions.' }
1241
{ name => 'vectors_ids', type => 'int32array', void_ret => 1,
1242
desc => 'The list of newly created vectors',
1243
array => { name => 'num_vectors',
1244
desc => 'The number of newly created vectors' } }
1248
headers => [ qw("vectors/gimpvectors-import.h") ],
1251
GList *list, *vectors_list = NULL;
1253
success = gimp_vectors_import_buffer (image, string, length,
1254
merge, scale, -1, &vectors_list, NULL);
1258
num_vectors = g_list_length (vectors_list);
1264
vectors_ids = g_new (gint32, num_vectors);
1266
list = vectors_list;
1267
for (i = 0; i < num_vectors; i++, list = g_list_next (list))
1268
vectors_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));
1270
g_list_free (vectors_list);
1279
@headers = qw(<string.h> "core/gimp.h" "core/gimplist.h" "core/gimpimage.h"
1280
"core/gimpchannel-select.h" "vectors/gimpanchor.h"
1281
"vectors/gimpstroke-new.h"
1282
"vectors/gimpbezierstroke.h"
1283
"vectors/gimpvectors.h"
1286
@procs = qw(vectors_is_valid
1289
vectors_get_name vectors_set_name
1290
vectors_get_visible vectors_set_visible
1291
vectors_get_linked vectors_set_linked
1292
vectors_get_tattoo vectors_set_tattoo
1294
vectors_stroke_get_length
1295
vectors_stroke_get_point_at_dist
1296
vectors_remove_stroke
1297
vectors_stroke_close
1298
vectors_stroke_translate
1299
vectors_stroke_scale
1300
vectors_stroke_rotate
1302
vectors_stroke_flip_free
1303
vectors_stroke_get_points
1304
vectors_stroke_new_from_points
1305
vectors_stroke_interpolate
1306
vectors_bezier_stroke_new_moveto
1307
vectors_bezier_stroke_lineto
1308
vectors_bezier_stroke_conicto
1309
vectors_bezier_stroke_cubicto
1310
vectors_bezier_stroke_new_ellipse
1311
vectors_to_selection
1312
vectors_import_from_file
1313
vectors_import_from_string);
1315
%exports = (app => [@procs], lib => [@procs]);