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
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
|
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpvectors_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include <string.h>
#include "gimp.h"
/**
* SECTION: gimpvectors
* @title: gimpvectors
* @short_description: Functions for querying and manipulating vectors.
*
* Functions for querying and manipulating vectors.
**/
/**
* gimp_vectors_new:
* @image_ID: The image.
* @name: the name of the new vector object.
*
* Creates a new empty vectors object.
*
* Creates a new empty vectors object. The vectors object needs to be
* added to the image using gimp_image_insert_vectors().
*
* Returns: the current vector object, 0 if no vector exists in the
* image.
*
* Since: 2.4
**/
gint32
gimp_vectors_new (gint32 image_ID,
const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 vectors_ID = -1;
return_vals = gimp_run_procedure ("gimp-vectors-new",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
vectors_ID = return_vals[1].data.d_vectors;
gimp_destroy_params (return_vals, nreturn_vals);
return vectors_ID;
}
/**
* gimp_vectors_new_from_text_layer:
* @image_ID: The image.
* @layer_ID: The text layer.
*
* Creates a new vectors object from a text layer.
*
* Creates a new vectors object from a text layer. The vectors object
* needs to be added to the image using gimp_image_insert_vectors().
*
* Returns: The vectors of the text layer.
*
* Since: 2.6
**/
gint32
gimp_vectors_new_from_text_layer (gint32 image_ID,
gint32 layer_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 vectors_ID = -1;
return_vals = gimp_run_procedure ("gimp-vectors-new-from-text-layer",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_LAYER, layer_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
vectors_ID = return_vals[1].data.d_vectors;
gimp_destroy_params (return_vals, nreturn_vals);
return vectors_ID;
}
/**
* gimp_vectors_copy:
* @vectors_ID: The vectors object to copy.
*
* Copy a vectors object.
*
* This procedure copies the specified vectors object and returns the
* copy.
*
* Returns: The newly copied vectors object.
*
* Since: 2.6
**/
gint32
gimp_vectors_copy (gint32 vectors_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 vectors_copy_ID = -1;
return_vals = gimp_run_procedure ("gimp-vectors-copy",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
vectors_copy_ID = return_vals[1].data.d_vectors;
gimp_destroy_params (return_vals, nreturn_vals);
return vectors_copy_ID;
}
/**
* gimp_vectors_get_strokes:
* @vectors_ID: The vectors object.
* @num_strokes: The number of strokes returned.
*
* List the strokes associated with the passed path.
*
* Returns an Array with the stroke-IDs associated with the passed
* path.
*
* Returns: List of the strokes belonging to the path.
*
* Since: 2.4
**/
gint *
gimp_vectors_get_strokes (gint32 vectors_ID,
gint *num_strokes)
{
GimpParam *return_vals;
gint nreturn_vals;
gint *stroke_ids = NULL;
return_vals = gimp_run_procedure ("gimp-vectors-get-strokes",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_END);
*num_strokes = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_strokes = return_vals[1].data.d_int32;
stroke_ids = g_new (gint32, *num_strokes);
memcpy (stroke_ids,
return_vals[2].data.d_int32array,
*num_strokes * sizeof (gint32));
}
gimp_destroy_params (return_vals, nreturn_vals);
return stroke_ids;
}
/**
* gimp_vectors_stroke_get_length:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @precision: The precision used for the approximation.
*
* Measure the length of the given stroke.
*
* Measure the length of the given stroke.
*
* Returns: The length (in pixels) of the given stroke.
*
* Since: 2.4
**/
gdouble
gimp_vectors_stroke_get_length (gint32 vectors_ID,
gint stroke_id,
gdouble precision)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble length = 0.0;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-length",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, precision,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
length = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return length;
}
/**
* gimp_vectors_stroke_get_point_at_dist:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @dist: The given distance.
* @precision: The precision used for the approximation.
* @x_point: The x position of the point.
* @y_point: The y position of the point.
* @slope: The slope (dy / dx) at the specified point.
* @valid: Indicator for the validity of the returned data.
*
* Get point at a specified distance along the stroke.
*
* This will return the x,y position of a point at a given distance
* along the stroke. The distance will be obtained by first digitizing
* the curve internally and then walking along the curve. For a closed
* stroke the start of the path is the first point on the path that was
* created. This might not be obvious. If the stroke is not long
* enough, a \"valid\" flag will be FALSE.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID,
gint stroke_id,
gdouble dist,
gdouble precision,
gdouble *x_point,
gdouble *y_point,
gdouble *slope,
gboolean *valid)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-point-at-dist",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, dist,
GIMP_PDB_FLOAT, precision,
GIMP_PDB_END);
*x_point = 0.0;
*y_point = 0.0;
*slope = 0.0;
*valid = FALSE;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*x_point = return_vals[1].data.d_float;
*y_point = return_vals[2].data.d_float;
*slope = return_vals[3].data.d_float;
*valid = return_vals[4].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_remove_stroke:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
*
* remove the stroke from a vectors object.
*
* Remove the stroke from a vectors object.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_remove_stroke (gint32 vectors_ID,
gint stroke_id)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-remove-stroke",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_close:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
*
* closes the specified stroke.
*
* Closes the specified stroke.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_stroke_close (gint32 vectors_ID,
gint stroke_id)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-close",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_translate:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @off_x: Offset in x direction.
* @off_y: Offset in y direction.
*
* translate the given stroke.
*
* Translate the given stroke.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_stroke_translate (gint32 vectors_ID,
gint stroke_id,
gint off_x,
gint off_y)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-translate",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_INT32, off_x,
GIMP_PDB_INT32, off_y,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_scale:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @scale_x: Scale factor in x direction.
* @scale_y: Scale factor in y direction.
*
* scales the given stroke.
*
* Scale the given stroke.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_stroke_scale (gint32 vectors_ID,
gint stroke_id,
gdouble scale_x,
gdouble scale_y)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-scale",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, scale_x,
GIMP_PDB_FLOAT, scale_y,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_rotate:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @center_x: X coordinate of the rotation center.
* @center_y: Y coordinate of the rotation center.
* @angle: angle to rotate about.
*
* rotates the given stroke.
*
* Rotates the given stroke around given center by angle (in degrees).
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_stroke_rotate (gint32 vectors_ID,
gint stroke_id,
gdouble center_x,
gdouble center_y,
gdouble angle)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-rotate",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, center_x,
GIMP_PDB_FLOAT, center_y,
GIMP_PDB_FLOAT, angle,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_flip:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @flip_type: Flip orientation, either vertical or horizontal.
* @axis: axis coordinate about which to flip, in pixels.
*
* flips the given stroke.
*
* Rotates the given stroke around given center by angle (in degrees).
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_stroke_flip (gint32 vectors_ID,
gint stroke_id,
GimpOrientationType flip_type,
gdouble axis)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-flip",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_INT32, flip_type,
GIMP_PDB_FLOAT, axis,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_flip_free:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @x1: X coordinate of the first point of the flipping axis.
* @y1: Y coordinate of the first point of the flipping axis.
* @x2: X coordinate of the second point of the flipping axis.
* @y2: Y coordinate of the second point of the flipping axis.
*
* flips the given stroke about an arbitrary axis.
*
* Flips the given stroke about an arbitrary axis. Axis is defined by
* two coordinates in the image (in pixels), through which the flipping
* axis passes.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_stroke_flip_free (gint32 vectors_ID,
gint stroke_id,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-flip-free",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, x1,
GIMP_PDB_FLOAT, y1,
GIMP_PDB_FLOAT, x2,
GIMP_PDB_FLOAT, y2,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_get_points:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @num_points: The number of floats returned.
* @controlpoints: List of the control points for the stroke (x0, y0, x1, y1, ...).
* @closed: Whether the stroke is closed or not.
*
* returns the control points of a stroke.
*
* returns the control points of a stroke. The interpretation of the
* coordinates returned depends on the type of the stroke. For Gimp 2.4
* this is always a bezier stroke, where the coordinates are the
* control points.
*
* Returns: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER
* for now).
*
* Since: 2.4
**/
GimpVectorsStrokeType
gimp_vectors_stroke_get_points (gint32 vectors_ID,
gint stroke_id,
gint *num_points,
gdouble **controlpoints,
gboolean *closed)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpVectorsStrokeType type = 0;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-points",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_END);
*num_points = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
type = return_vals[1].data.d_int32;
*num_points = return_vals[2].data.d_int32;
*controlpoints = g_new (gdouble, *num_points);
memcpy (*controlpoints,
return_vals[3].data.d_floatarray,
*num_points * sizeof (gdouble));
*closed = return_vals[4].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return type;
}
/**
* gimp_vectors_stroke_new_from_points:
* @vectors_ID: The vectors object.
* @type: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now).
* @num_points: The number of elements in the array, i.e. the number of controlpoints in the stroke * 2 (x- and y-coordinate).
* @controlpoints: List of the x- and y-coordinates of the control points.
* @closed: Whether the stroke is to be closed or not.
*
* Adds a stroke of a given type to the vectors object.
*
* Adds a stroke of a given type to the vectors object. The coordinates
* of the control points can be specified. For now only strokes of the
* type GIMP_VECTORS_STROKE_TYPE_BEZIER are supported. The control
* points are specified as a pair of float values for the x- and
* y-coordinate. The Bezier stroke type needs a multiple of three
* control points. Each Bezier segment endpoint (anchor, A) has two
* additional control points (C) associated. They are specified in the
* order CACCACCAC...
*
* Returns: The stroke ID of the newly created stroke.
*
* Since: 2.4
**/
gint
gimp_vectors_stroke_new_from_points (gint32 vectors_ID,
GimpVectorsStrokeType type,
gint num_points,
const gdouble *controlpoints,
gboolean closed)
{
GimpParam *return_vals;
gint nreturn_vals;
gint stroke_id = 0;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-new-from-points",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, type,
GIMP_PDB_INT32, num_points,
GIMP_PDB_FLOATARRAY, controlpoints,
GIMP_PDB_INT32, closed,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
stroke_id = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return stroke_id;
}
/**
* gimp_vectors_stroke_interpolate:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @precision: The precision used for the approximation.
* @num_coords: The number of floats returned.
* @closed: Whether the stroke is closed or not.
*
* returns polygonal approximation of the stroke.
*
* returns polygonal approximation of the stroke.
*
* Returns: List of the coords along the path (x0, y0, x1, y1, ...).
*
* Since: 2.4
**/
gdouble *
gimp_vectors_stroke_interpolate (gint32 vectors_ID,
gint stroke_id,
gdouble precision,
gint *num_coords,
gboolean *closed)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble *coords = NULL;
return_vals = gimp_run_procedure ("gimp-vectors-stroke-interpolate",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, precision,
GIMP_PDB_END);
*num_coords = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_coords = return_vals[1].data.d_int32;
coords = g_new (gdouble, *num_coords);
memcpy (coords,
return_vals[2].data.d_floatarray,
*num_coords * sizeof (gdouble));
*closed = return_vals[3].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return coords;
}
/**
* gimp_vectors_bezier_stroke_new_moveto:
* @vectors_ID: The vectors object.
* @x0: The x-coordinate of the moveto.
* @y0: The y-coordinate of the moveto.
*
* Adds a bezier stroke with a single moveto to the vectors object.
*
* Adds a bezier stroke with a single moveto to the vectors object.
*
* Returns: The resulting stroke.
*
* Since: 2.4
**/
gint
gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID,
gdouble x0,
gdouble y0)
{
GimpParam *return_vals;
gint nreturn_vals;
gint stroke_id = 0;
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-new-moveto",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_FLOAT, x0,
GIMP_PDB_FLOAT, y0,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
stroke_id = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return stroke_id;
}
/**
* gimp_vectors_bezier_stroke_lineto:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @x0: The x-coordinate of the lineto.
* @y0: The y-coordinate of the lineto.
*
* Extends a bezier stroke with a lineto.
*
* Extends a bezier stroke with a lineto.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID,
gint stroke_id,
gdouble x0,
gdouble y0)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-lineto",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, x0,
GIMP_PDB_FLOAT, y0,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_bezier_stroke_conicto:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @x0: The x-coordinate of the control point.
* @y0: The y-coordinate of the control point.
* @x1: The x-coordinate of the end point.
* @y1: The y-coordinate of the end point.
*
* Extends a bezier stroke with a conic bezier spline.
*
* Extends a bezier stroke with a conic bezier spline. Actually a cubic
* bezier spline gets added that realizes the shape of a conic bezier
* spline.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID,
gint stroke_id,
gdouble x0,
gdouble y0,
gdouble x1,
gdouble y1)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-conicto",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, x0,
GIMP_PDB_FLOAT, y0,
GIMP_PDB_FLOAT, x1,
GIMP_PDB_FLOAT, y1,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_bezier_stroke_cubicto:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @x0: The x-coordinate of the first control point.
* @y0: The y-coordinate of the first control point.
* @x1: The x-coordinate of the second control point.
* @y1: The y-coordinate of the second control point.
* @x2: The x-coordinate of the end point.
* @y2: The y-coordinate of the end point.
*
* Extends a bezier stroke with a cubic bezier spline.
*
* Extends a bezier stroke with a cubic bezier spline.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID,
gint stroke_id,
gdouble x0,
gdouble y0,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-cubicto",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, x0,
GIMP_PDB_FLOAT, y0,
GIMP_PDB_FLOAT, x1,
GIMP_PDB_FLOAT, y1,
GIMP_PDB_FLOAT, x2,
GIMP_PDB_FLOAT, y2,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_bezier_stroke_new_ellipse:
* @vectors_ID: The vectors object.
* @x0: The x-coordinate of the center.
* @y0: The y-coordinate of the center.
* @radius_x: The radius in x direction.
* @radius_y: The radius in y direction.
* @angle: The angle the x-axis of the ellipse (radians, counterclockwise).
*
* Adds a bezier stroke describing an ellipse the vectors object.
*
* Adds a bezier stroke describing an ellipse the vectors object.
*
* Returns: The resulting stroke.
*
* Since: 2.4
**/
gint
gimp_vectors_bezier_stroke_new_ellipse (gint32 vectors_ID,
gdouble x0,
gdouble y0,
gdouble radius_x,
gdouble radius_y,
gdouble angle)
{
GimpParam *return_vals;
gint nreturn_vals;
gint stroke_id = 0;
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-new-ellipse",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_FLOAT, x0,
GIMP_PDB_FLOAT, y0,
GIMP_PDB_FLOAT, radius_x,
GIMP_PDB_FLOAT, radius_y,
GIMP_PDB_FLOAT, angle,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
stroke_id = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return stroke_id;
}
/**
* gimp_vectors_to_selection:
* @vectors_ID: The vectors object to render to the selection.
* @operation: The desired operation with current selection.
* @antialias: Antialias selection.
* @feather: Feather selection.
* @feather_radius_x: Feather radius x.
* @feather_radius_y: Feather radius y.
*
* Deprecated: Use gimp_image_select_item() instead.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_to_selection (gint32 vectors_ID,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-to-selection",
&nreturn_vals,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius_x,
GIMP_PDB_FLOAT, feather_radius_y,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_import_from_file:
* @image_ID: The image.
* @filename: The name of the SVG file to import.
* @merge: Merge paths into a single vectors object.
* @scale: Scale the SVG to image dimensions.
* @num_vectors: The number of newly created vectors.
* @vectors_ids: The list of newly created vectors.
*
* Import paths from an SVG file.
*
* This procedure imports paths from an SVG file. SVG elements other
* than paths and basic shapes are ignored.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_import_from_file (gint32 image_ID,
const gchar *filename,
gboolean merge,
gboolean scale,
gint *num_vectors,
gint32 **vectors_ids)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-import-from-file",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, filename,
GIMP_PDB_INT32, merge,
GIMP_PDB_INT32, scale,
GIMP_PDB_END);
*num_vectors = 0;
*vectors_ids = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*num_vectors = return_vals[1].data.d_int32;
*vectors_ids = g_new (gint32, *num_vectors);
memcpy (*vectors_ids,
return_vals[2].data.d_int32array,
*num_vectors * sizeof (gint32));
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_import_from_string:
* @image_ID: The image.
* @string: A string that must be a complete and valid SVG document.
* @length: Number of bytes in string or -1 if the string is NULL terminated.
* @merge: Merge paths into a single vectors object.
* @scale: Scale the SVG to image dimensions.
* @num_vectors: The number of newly created vectors.
* @vectors_ids: The list of newly created vectors.
*
* Import paths from an SVG string.
*
* This procedure works like gimp_vectors_import_from_file() but takes
* a string rather than reading the SVG from a file. This allows you to
* write scripts that generate SVG and feed it to GIMP.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_vectors_import_from_string (gint32 image_ID,
const gchar *string,
gint length,
gboolean merge,
gboolean scale,
gint *num_vectors,
gint32 **vectors_ids)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-import-from-string",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, string,
GIMP_PDB_INT32, length,
GIMP_PDB_INT32, merge,
GIMP_PDB_INT32, scale,
GIMP_PDB_END);
*num_vectors = 0;
*vectors_ids = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*num_vectors = return_vals[1].data.d_int32;
*vectors_ids = g_new (gint32, *num_vectors);
memcpy (*vectors_ids,
return_vals[2].data.d_int32array,
*num_vectors * sizeof (gint32));
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_export_to_file:
* @image_ID: The image.
* @filename: The name of the SVG file to create.
* @vectors_ID: The vectors object to be saved, or 0 for all in the image.
*
* save a path as an SVG file.
*
* This procedure creates an SVG file to save a Vectors object, that
* is, a path. The resulting file can be edited using a vector graphics
* application, or later reloaded into GIMP. If you pass 0 as the
* 'vectors' argument, then all paths in the image will be exported.
*
* Returns: TRUE on success.
*
* Since: 2.6
**/
gboolean
gimp_vectors_export_to_file (gint32 image_ID,
const gchar *filename,
gint32 vectors_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-vectors-export-to-file",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, filename,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_export_to_string:
* @image_ID: The image.
* @vectors_ID: The vectors object to save, or 0 for all in the image.
*
* Save a path as an SVG string.
*
* This procedure works like gimp_vectors_export_to_file() but creates
* a string rather than a file. The contents are a NUL-terminated
* string that holds a complete XML document. If you pass 0 as the
* 'vectors' argument, then all paths in the image will be exported.
*
* Returns: A string whose contents are a complete SVG document.
*
* Since: 2.6
**/
gchar *
gimp_vectors_export_to_string (gint32 image_ID,
gint32 vectors_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *string = NULL;
return_vals = gimp_run_procedure ("gimp-vectors-export-to-string",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
string = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return string;
}
|