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

« back to all changes in this revision

Viewing changes to libgimp/gimpvectors_pdb.c

  • 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
/* LIBGIMP - The GIMP Library
 
2
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
 
3
 *
 
4
 * gimpvectors_pdb.c
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library; if not, write to the
 
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
 * Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
/* NOTE: This file is auto-generated by pdbgen.pl */
 
23
 
 
24
#include "config.h"
 
25
 
 
26
#include <string.h>
 
27
 
 
28
#include "gimp.h"
 
29
 
 
30
/**
 
31
 * gimp_vectors_is_valid:
 
32
 * @vectors_ID: The vectors object to check.
 
33
 *
 
34
 * Returns TRUE if the vectors object is valid.
 
35
 *
 
36
 * This procedure checks if the given vectors ID is valid and refers to
 
37
 * an existing vectors object.
 
38
 *
 
39
 * Returns: Whether the vectors ID is valid.
 
40
 *
 
41
 * Since: GIMP 2.4
 
42
 */
 
43
gboolean
 
44
gimp_vectors_is_valid (gint32 vectors_ID)
 
45
{
 
46
  GimpParam *return_vals;
 
47
  gint nreturn_vals;
 
48
  gboolean valid = FALSE;
 
49
 
 
50
  return_vals = gimp_run_procedure ("gimp-vectors-is-valid",
 
51
                                    &nreturn_vals,
 
52
                                    GIMP_PDB_VECTORS, vectors_ID,
 
53
                                    GIMP_PDB_END);
 
54
 
 
55
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
56
    valid = return_vals[1].data.d_int32;
 
57
 
 
58
  gimp_destroy_params (return_vals, nreturn_vals);
 
59
 
 
60
  return valid;
 
61
}
 
62
 
 
63
/**
 
64
 * gimp_vectors_new:
 
65
 * @image_ID: The image.
 
66
 * @name: the name of the new vector object.
 
67
 *
 
68
 * Creates a new empty vectors object.
 
69
 *
 
70
 * Creates a new empty vectors object. Needs to be added to an image
 
71
 * using gimp_image_add_vectors().
 
72
 *
 
73
 * Returns: the current vector object, 0 if no vector exists in the image.
 
74
 *
 
75
 * Since: GIMP 2.4
 
76
 */
 
77
gint32
 
78
gimp_vectors_new (gint32       image_ID,
 
79
                  const gchar *name)
 
80
{
 
81
  GimpParam *return_vals;
 
82
  gint nreturn_vals;
 
83
  gint32 vectors_ID = -1;
 
84
 
 
85
  return_vals = gimp_run_procedure ("gimp-vectors-new",
 
86
                                    &nreturn_vals,
 
87
                                    GIMP_PDB_IMAGE, image_ID,
 
88
                                    GIMP_PDB_STRING, name,
 
89
                                    GIMP_PDB_END);
 
90
 
 
91
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
92
    vectors_ID = return_vals[1].data.d_vectors;
 
93
 
 
94
  gimp_destroy_params (return_vals, nreturn_vals);
 
95
 
 
96
  return vectors_ID;
 
97
}
 
98
 
 
99
/**
 
100
 * gimp_vectors_get_image:
 
101
 * @vectors_ID: The vectors object.
 
102
 *
 
103
 * Returns the vectors objects image.
 
104
 *
 
105
 * Returns the vectors objects image.
 
106
 *
 
107
 * Returns: The vectors image.
 
108
 *
 
109
 * Since: GIMP 2.4
 
110
 */
 
111
gint32
 
112
gimp_vectors_get_image (gint32 vectors_ID)
 
113
{
 
114
  GimpParam *return_vals;
 
115
  gint nreturn_vals;
 
116
  gint32 image_ID = -1;
 
117
 
 
118
  return_vals = gimp_run_procedure ("gimp-vectors-get-image",
 
119
                                    &nreturn_vals,
 
120
                                    GIMP_PDB_VECTORS, vectors_ID,
 
121
                                    GIMP_PDB_END);
 
122
 
 
123
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
124
    image_ID = return_vals[1].data.d_image;
 
125
 
 
126
  gimp_destroy_params (return_vals, nreturn_vals);
 
127
 
 
128
  return image_ID;
 
129
}
 
130
 
 
131
/**
 
132
 * gimp_vectors_get_name:
 
133
 * @vectors_ID: The vectors object.
 
134
 *
 
135
 * Gets the name of the vectors object.
 
136
 *
 
137
 * Gets the name of the vectors object.
 
138
 *
 
139
 * Returns: The name of the vectors object.
 
140
 *
 
141
 * Since: GIMP 2.4
 
142
 */
 
143
gchar *
 
144
gimp_vectors_get_name (gint32 vectors_ID)
 
145
{
 
146
  GimpParam *return_vals;
 
147
  gint nreturn_vals;
 
148
  gchar *name = NULL;
 
149
 
 
150
  return_vals = gimp_run_procedure ("gimp-vectors-get-name",
 
151
                                    &nreturn_vals,
 
152
                                    GIMP_PDB_VECTORS, vectors_ID,
 
153
                                    GIMP_PDB_END);
 
154
 
 
155
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
156
    name = g_strdup (return_vals[1].data.d_string);
 
157
 
 
158
  gimp_destroy_params (return_vals, nreturn_vals);
 
159
 
 
160
  return name;
 
161
}
 
162
 
 
163
/**
 
164
 * gimp_vectors_set_name:
 
165
 * @vectors_ID: The vectors object.
 
166
 * @name: the new name of the path.
 
167
 *
 
168
 * Sets the name of the vectors object.
 
169
 *
 
170
 * Sets the name of the vectors object.
 
171
 *
 
172
 * Returns: TRUE on success.
 
173
 *
 
174
 * Since: GIMP 2.4
 
175
 */
 
176
gboolean
 
177
gimp_vectors_set_name (gint32       vectors_ID,
 
178
                       const gchar *name)
 
179
{
 
180
  GimpParam *return_vals;
 
181
  gint nreturn_vals;
 
182
  gboolean success = TRUE;
 
183
 
 
184
  return_vals = gimp_run_procedure ("gimp-vectors-set-name",
 
185
                                    &nreturn_vals,
 
186
                                    GIMP_PDB_VECTORS, vectors_ID,
 
187
                                    GIMP_PDB_STRING, name,
 
188
                                    GIMP_PDB_END);
 
189
 
 
190
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
191
 
 
192
  gimp_destroy_params (return_vals, nreturn_vals);
 
193
 
 
194
  return success;
 
195
}
 
196
 
 
197
/**
 
198
 * gimp_vectors_get_visible:
 
199
 * @vectors_ID: The vectors object.
 
200
 *
 
201
 * Gets the visibility of the vectors object.
 
202
 *
 
203
 * Gets the visibility of the vectors object.
 
204
 *
 
205
 * Returns: TRUE if the path is visible, FALSE otherwise.
 
206
 *
 
207
 * Since: GIMP 2.4
 
208
 */
 
209
gboolean
 
210
gimp_vectors_get_visible (gint32 vectors_ID)
 
211
{
 
212
  GimpParam *return_vals;
 
213
  gint nreturn_vals;
 
214
  gboolean visible = FALSE;
 
215
 
 
216
  return_vals = gimp_run_procedure ("gimp-vectors-get-visible",
 
217
                                    &nreturn_vals,
 
218
                                    GIMP_PDB_VECTORS, vectors_ID,
 
219
                                    GIMP_PDB_END);
 
220
 
 
221
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
222
    visible = return_vals[1].data.d_int32;
 
223
 
 
224
  gimp_destroy_params (return_vals, nreturn_vals);
 
225
 
 
226
  return visible;
 
227
}
 
228
 
 
229
/**
 
230
 * gimp_vectors_set_visible:
 
231
 * @vectors_ID: The vectors object.
 
232
 * @visible: Whether the path is visible.
 
233
 *
 
234
 * Sets the visibility of the vectors object.
 
235
 *
 
236
 * Sets the visibility of the vectors object.
 
237
 *
 
238
 * Returns: TRUE on success.
 
239
 *
 
240
 * Since: GIMP 2.4
 
241
 */
 
242
gboolean
 
243
gimp_vectors_set_visible (gint32   vectors_ID,
 
244
                          gboolean visible)
 
245
{
 
246
  GimpParam *return_vals;
 
247
  gint nreturn_vals;
 
248
  gboolean success = TRUE;
 
249
 
 
250
  return_vals = gimp_run_procedure ("gimp-vectors-set-visible",
 
251
                                    &nreturn_vals,
 
252
                                    GIMP_PDB_VECTORS, vectors_ID,
 
253
                                    GIMP_PDB_INT32, visible,
 
254
                                    GIMP_PDB_END);
 
255
 
 
256
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
257
 
 
258
  gimp_destroy_params (return_vals, nreturn_vals);
 
259
 
 
260
  return success;
 
261
}
 
262
 
 
263
/**
 
264
 * gimp_vectors_get_linked:
 
265
 * @vectors_ID: The vectors object.
 
266
 *
 
267
 * Gets the linked state of the vectors object.
 
268
 *
 
269
 * Gets the linked state of the vectors object.
 
270
 *
 
271
 * Returns: TRUE if the path is linked, FALSE otherwise.
 
272
 *
 
273
 * Since: GIMP 2.4
 
274
 */
 
275
gboolean
 
276
gimp_vectors_get_linked (gint32 vectors_ID)
 
277
{
 
278
  GimpParam *return_vals;
 
279
  gint nreturn_vals;
 
280
  gboolean linked = FALSE;
 
281
 
 
282
  return_vals = gimp_run_procedure ("gimp-vectors-get-linked",
 
283
                                    &nreturn_vals,
 
284
                                    GIMP_PDB_VECTORS, vectors_ID,
 
285
                                    GIMP_PDB_END);
 
286
 
 
287
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
288
    linked = return_vals[1].data.d_int32;
 
289
 
 
290
  gimp_destroy_params (return_vals, nreturn_vals);
 
291
 
 
292
  return linked;
 
293
}
 
294
 
 
295
/**
 
296
 * gimp_vectors_set_linked:
 
297
 * @vectors_ID: The vectors object.
 
298
 * @linked: Whether the path is linked.
 
299
 *
 
300
 * Sets the linked state of the vectors object.
 
301
 *
 
302
 * Sets the linked state of the vectors object.
 
303
 *
 
304
 * Returns: TRUE on success.
 
305
 *
 
306
 * Since: GIMP 2.4
 
307
 */
 
308
gboolean
 
309
gimp_vectors_set_linked (gint32   vectors_ID,
 
310
                         gboolean linked)
 
311
{
 
312
  GimpParam *return_vals;
 
313
  gint nreturn_vals;
 
314
  gboolean success = TRUE;
 
315
 
 
316
  return_vals = gimp_run_procedure ("gimp-vectors-set-linked",
 
317
                                    &nreturn_vals,
 
318
                                    GIMP_PDB_VECTORS, vectors_ID,
 
319
                                    GIMP_PDB_INT32, linked,
 
320
                                    GIMP_PDB_END);
 
321
 
 
322
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
323
 
 
324
  gimp_destroy_params (return_vals, nreturn_vals);
 
325
 
 
326
  return success;
 
327
}
 
328
 
 
329
/**
 
330
 * gimp_vectors_get_tattoo:
 
331
 * @vectors_ID: The vectors object.
 
332
 *
 
333
 * Get the tattoo of the vectors object.
 
334
 *
 
335
 * Get the tattoo state of the vectors object.
 
336
 *
 
337
 * Returns: The vectors tattoo.
 
338
 *
 
339
 * Since: GIMP 2.4
 
340
 */
 
341
gint
 
342
gimp_vectors_get_tattoo (gint32 vectors_ID)
 
343
{
 
344
  GimpParam *return_vals;
 
345
  gint nreturn_vals;
 
346
  gint tattoo = 0;
 
347
 
 
348
  return_vals = gimp_run_procedure ("gimp-vectors-get-tattoo",
 
349
                                    &nreturn_vals,
 
350
                                    GIMP_PDB_VECTORS, vectors_ID,
 
351
                                    GIMP_PDB_END);
 
352
 
 
353
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
354
    tattoo = return_vals[1].data.d_int32;
 
355
 
 
356
  gimp_destroy_params (return_vals, nreturn_vals);
 
357
 
 
358
  return tattoo;
 
359
}
 
360
 
 
361
/**
 
362
 * gimp_vectors_set_tattoo:
 
363
 * @vectors_ID: The vectors object.
 
364
 * @tattoo: the new tattoo.
 
365
 *
 
366
 * Set the tattoo of the vectors object.
 
367
 *
 
368
 * Set the tattoo of the vectors object.
 
369
 *
 
370
 * Returns: TRUE on success.
 
371
 *
 
372
 * Since: GIMP 2.4
 
373
 */
 
374
gboolean
 
375
gimp_vectors_set_tattoo (gint32 vectors_ID,
 
376
                         gint   tattoo)
 
377
{
 
378
  GimpParam *return_vals;
 
379
  gint nreturn_vals;
 
380
  gboolean success = TRUE;
 
381
 
 
382
  return_vals = gimp_run_procedure ("gimp-vectors-set-tattoo",
 
383
                                    &nreturn_vals,
 
384
                                    GIMP_PDB_VECTORS, vectors_ID,
 
385
                                    GIMP_PDB_INT32, tattoo,
 
386
                                    GIMP_PDB_END);
 
387
 
 
388
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
389
 
 
390
  gimp_destroy_params (return_vals, nreturn_vals);
 
391
 
 
392
  return success;
 
393
}
 
394
 
 
395
/**
 
396
 * gimp_vectors_get_strokes:
 
397
 * @vectors_ID: The vectors object.
 
398
 * @num_strokes: The number of strokes returned.
 
399
 *
 
400
 * List the strokes associated with the passed path.
 
401
 *
 
402
 * Returns an Array with the stroke-IDs associated with the passed
 
403
 * path.
 
404
 *
 
405
 * Returns: List of the strokes belonging to the path.
 
406
 *
 
407
 * Since: GIMP 2.4
 
408
 */
 
409
gint *
 
410
gimp_vectors_get_strokes (gint32  vectors_ID,
 
411
                          gint   *num_strokes)
 
412
{
 
413
  GimpParam *return_vals;
 
414
  gint nreturn_vals;
 
415
  gint *stroke_ids = NULL;
 
416
 
 
417
  return_vals = gimp_run_procedure ("gimp-vectors-get-strokes",
 
418
                                    &nreturn_vals,
 
419
                                    GIMP_PDB_VECTORS, vectors_ID,
 
420
                                    GIMP_PDB_END);
 
421
 
 
422
  *num_strokes = 0;
 
423
 
 
424
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
425
    {
 
426
      *num_strokes = return_vals[1].data.d_int32;
 
427
      stroke_ids = g_new (gint32, *num_strokes);
 
428
      memcpy (stroke_ids,
 
429
              return_vals[2].data.d_int32array,
 
430
              *num_strokes * sizeof (gint32));
 
431
    }
 
432
 
 
433
  gimp_destroy_params (return_vals, nreturn_vals);
 
434
 
 
435
  return stroke_ids;
 
436
}
 
437
 
 
438
/**
 
439
 * gimp_vectors_stroke_get_length:
 
440
 * @vectors_ID: The vectors object.
 
441
 * @stroke_id: The stroke ID.
 
442
 * @precision: The precision used for the approximation.
 
443
 *
 
444
 * Measure the length of the given stroke.
 
445
 *
 
446
 * Measure the length of the given stroke.
 
447
 *
 
448
 * Returns: The length (in pixels) of the given stroke.
 
449
 *
 
450
 * Since: GIMP 2.4
 
451
 */
 
452
gdouble
 
453
gimp_vectors_stroke_get_length (gint32  vectors_ID,
 
454
                                gint    stroke_id,
 
455
                                gdouble precision)
 
456
{
 
457
  GimpParam *return_vals;
 
458
  gint nreturn_vals;
 
459
  gdouble length = 0.0;
 
460
 
 
461
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-length",
 
462
                                    &nreturn_vals,
 
463
                                    GIMP_PDB_VECTORS, vectors_ID,
 
464
                                    GIMP_PDB_INT32, stroke_id,
 
465
                                    GIMP_PDB_FLOAT, precision,
 
466
                                    GIMP_PDB_END);
 
467
 
 
468
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
469
    length = return_vals[1].data.d_float;
 
470
 
 
471
  gimp_destroy_params (return_vals, nreturn_vals);
 
472
 
 
473
  return length;
 
474
}
 
475
 
 
476
/**
 
477
 * gimp_vectors_stroke_get_point_at_dist:
 
478
 * @vectors_ID: The vectors object.
 
479
 * @stroke_id: The stroke ID.
 
480
 * @dist: The given distance.
 
481
 * @precision: The precision used for the approximation.
 
482
 * @x_point: The x position of the point.
 
483
 * @y_point: The y position of the point.
 
484
 * @slope: The slope (dy / dx) at the specified point.
 
485
 * @valid: Indicator for the validity of the returned data.
 
486
 *
 
487
 * Get point at a specified distance along the stroke.
 
488
 *
 
489
 * This will return the x,y position of a point at a given distance
 
490
 * along the stroke. The distance will be obtained by first digitizing
 
491
 * the curve internally and then walking along the curve. For a closed
 
492
 * stroke the start of the path is the first point on the path that was
 
493
 * created. This might not be obvious. If the stroke is not long
 
494
 * enough, a \"valid\" flag will be FALSE.
 
495
 *
 
496
 * Returns: TRUE on success.
 
497
 *
 
498
 * Since: GIMP 2.4
 
499
 */
 
500
gboolean
 
501
gimp_vectors_stroke_get_point_at_dist (gint32    vectors_ID,
 
502
                                       gint      stroke_id,
 
503
                                       gdouble   dist,
 
504
                                       gdouble   precision,
 
505
                                       gdouble  *x_point,
 
506
                                       gdouble  *y_point,
 
507
                                       gdouble  *slope,
 
508
                                       gboolean *valid)
 
509
{
 
510
  GimpParam *return_vals;
 
511
  gint nreturn_vals;
 
512
  gboolean success = TRUE;
 
513
 
 
514
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-point-at-dist",
 
515
                                    &nreturn_vals,
 
516
                                    GIMP_PDB_VECTORS, vectors_ID,
 
517
                                    GIMP_PDB_INT32, stroke_id,
 
518
                                    GIMP_PDB_FLOAT, dist,
 
519
                                    GIMP_PDB_FLOAT, precision,
 
520
                                    GIMP_PDB_END);
 
521
 
 
522
  *x_point = 0.0;
 
523
  *y_point = 0.0;
 
524
  *slope = 0.0;
 
525
  *valid = FALSE;
 
526
 
 
527
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
528
 
 
529
  if (success)
 
530
    {
 
531
      *x_point = return_vals[1].data.d_float;
 
532
      *y_point = return_vals[2].data.d_float;
 
533
      *slope = return_vals[3].data.d_float;
 
534
      *valid = return_vals[4].data.d_int32;
 
535
    }
 
536
 
 
537
  gimp_destroy_params (return_vals, nreturn_vals);
 
538
 
 
539
  return success;
 
540
}
 
541
 
 
542
/**
 
543
 * gimp_vectors_remove_stroke:
 
544
 * @vectors_ID: The vectors object.
 
545
 * @stroke_id: The stroke ID.
 
546
 *
 
547
 * remove the stroke from a vectors object.
 
548
 *
 
549
 * Remove the stroke from a vectors object.
 
550
 *
 
551
 * Returns: TRUE on success.
 
552
 *
 
553
 * Since: GIMP 2.4
 
554
 */
 
555
gboolean
 
556
gimp_vectors_remove_stroke (gint32 vectors_ID,
 
557
                            gint   stroke_id)
 
558
{
 
559
  GimpParam *return_vals;
 
560
  gint nreturn_vals;
 
561
  gboolean success = TRUE;
 
562
 
 
563
  return_vals = gimp_run_procedure ("gimp-vectors-remove-stroke",
 
564
                                    &nreturn_vals,
 
565
                                    GIMP_PDB_VECTORS, vectors_ID,
 
566
                                    GIMP_PDB_INT32, stroke_id,
 
567
                                    GIMP_PDB_END);
 
568
 
 
569
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
570
 
 
571
  gimp_destroy_params (return_vals, nreturn_vals);
 
572
 
 
573
  return success;
 
574
}
 
575
 
 
576
/**
 
577
 * gimp_vectors_stroke_close:
 
578
 * @vectors_ID: The vectors object.
 
579
 * @stroke_id: The stroke ID.
 
580
 *
 
581
 * closes the specified stroke.
 
582
 *
 
583
 * Closes the specified stroke.
 
584
 *
 
585
 * Returns: TRUE on success.
 
586
 *
 
587
 * Since: GIMP 2.4
 
588
 */
 
589
gboolean
 
590
gimp_vectors_stroke_close (gint32 vectors_ID,
 
591
                           gint   stroke_id)
 
592
{
 
593
  GimpParam *return_vals;
 
594
  gint nreturn_vals;
 
595
  gboolean success = TRUE;
 
596
 
 
597
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-close",
 
598
                                    &nreturn_vals,
 
599
                                    GIMP_PDB_VECTORS, vectors_ID,
 
600
                                    GIMP_PDB_INT32, stroke_id,
 
601
                                    GIMP_PDB_END);
 
602
 
 
603
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
604
 
 
605
  gimp_destroy_params (return_vals, nreturn_vals);
 
606
 
 
607
  return success;
 
608
}
 
609
 
 
610
/**
 
611
 * gimp_vectors_stroke_translate:
 
612
 * @vectors_ID: The vectors object.
 
613
 * @stroke_id: The stroke ID.
 
614
 * @off_x: Offset in x direction.
 
615
 * @off_y: Offset in y direction.
 
616
 *
 
617
 * translate the given stroke.
 
618
 *
 
619
 * Translate the given stroke.
 
620
 *
 
621
 * Returns: TRUE on success.
 
622
 *
 
623
 * Since: GIMP 2.4
 
624
 */
 
625
gboolean
 
626
gimp_vectors_stroke_translate (gint32 vectors_ID,
 
627
                               gint   stroke_id,
 
628
                               gint   off_x,
 
629
                               gint   off_y)
 
630
{
 
631
  GimpParam *return_vals;
 
632
  gint nreturn_vals;
 
633
  gboolean success = TRUE;
 
634
 
 
635
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-translate",
 
636
                                    &nreturn_vals,
 
637
                                    GIMP_PDB_VECTORS, vectors_ID,
 
638
                                    GIMP_PDB_INT32, stroke_id,
 
639
                                    GIMP_PDB_INT32, off_x,
 
640
                                    GIMP_PDB_INT32, off_y,
 
641
                                    GIMP_PDB_END);
 
642
 
 
643
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
644
 
 
645
  gimp_destroy_params (return_vals, nreturn_vals);
 
646
 
 
647
  return success;
 
648
}
 
649
 
 
650
/**
 
651
 * gimp_vectors_stroke_scale:
 
652
 * @vectors_ID: The vectors object.
 
653
 * @stroke_id: The stroke ID.
 
654
 * @scale_x: Scale factor in x direction.
 
655
 * @scale_y: Scale factor in y direction.
 
656
 *
 
657
 * scales the given stroke.
 
658
 *
 
659
 * Scale the given stroke.
 
660
 *
 
661
 * Returns: TRUE on success.
 
662
 *
 
663
 * Since: GIMP 2.4
 
664
 */
 
665
gboolean
 
666
gimp_vectors_stroke_scale (gint32  vectors_ID,
 
667
                           gint    stroke_id,
 
668
                           gdouble scale_x,
 
669
                           gdouble scale_y)
 
670
{
 
671
  GimpParam *return_vals;
 
672
  gint nreturn_vals;
 
673
  gboolean success = TRUE;
 
674
 
 
675
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-scale",
 
676
                                    &nreturn_vals,
 
677
                                    GIMP_PDB_VECTORS, vectors_ID,
 
678
                                    GIMP_PDB_INT32, stroke_id,
 
679
                                    GIMP_PDB_FLOAT, scale_x,
 
680
                                    GIMP_PDB_FLOAT, scale_y,
 
681
                                    GIMP_PDB_END);
 
682
 
 
683
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
684
 
 
685
  gimp_destroy_params (return_vals, nreturn_vals);
 
686
 
 
687
  return success;
 
688
}
 
689
 
 
690
/**
 
691
 * gimp_vectors_stroke_rotate:
 
692
 * @vectors_ID: The vectors object.
 
693
 * @stroke_id: The stroke ID.
 
694
 * @center_x: X coordinate of the rotation center.
 
695
 * @center_y: Y coordinate of the rotation center.
 
696
 * @angle: angle to rotate about.
 
697
 *
 
698
 * rotates the given stroke.
 
699
 *
 
700
 * Rotates the given stroke around given center by angle (in degrees).
 
701
 *
 
702
 * Returns: TRUE on success.
 
703
 *
 
704
 * Since: GIMP 2.4
 
705
 */
 
706
gboolean
 
707
gimp_vectors_stroke_rotate (gint32  vectors_ID,
 
708
                            gint    stroke_id,
 
709
                            gdouble center_x,
 
710
                            gdouble center_y,
 
711
                            gdouble angle)
 
712
{
 
713
  GimpParam *return_vals;
 
714
  gint nreturn_vals;
 
715
  gboolean success = TRUE;
 
716
 
 
717
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-rotate",
 
718
                                    &nreturn_vals,
 
719
                                    GIMP_PDB_VECTORS, vectors_ID,
 
720
                                    GIMP_PDB_INT32, stroke_id,
 
721
                                    GIMP_PDB_FLOAT, center_x,
 
722
                                    GIMP_PDB_FLOAT, center_y,
 
723
                                    GIMP_PDB_FLOAT, angle,
 
724
                                    GIMP_PDB_END);
 
725
 
 
726
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
727
 
 
728
  gimp_destroy_params (return_vals, nreturn_vals);
 
729
 
 
730
  return success;
 
731
}
 
732
 
 
733
/**
 
734
 * gimp_vectors_stroke_flip:
 
735
 * @vectors_ID: The vectors object.
 
736
 * @stroke_id: The stroke ID.
 
737
 * @flip_type: Flip orientation, either vertical or horizontal.
 
738
 * @axis: axis coordinate about which to flip, in pixels.
 
739
 *
 
740
 * flips the given stroke.
 
741
 *
 
742
 * Rotates the given stroke around given center by angle (in degrees).
 
743
 *
 
744
 * Returns: TRUE on success.
 
745
 *
 
746
 * Since: GIMP 2.4
 
747
 */
 
748
gboolean
 
749
gimp_vectors_stroke_flip (gint32              vectors_ID,
 
750
                          gint                stroke_id,
 
751
                          GimpOrientationType flip_type,
 
752
                          gdouble             axis)
 
753
{
 
754
  GimpParam *return_vals;
 
755
  gint nreturn_vals;
 
756
  gboolean success = TRUE;
 
757
 
 
758
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-flip",
 
759
                                    &nreturn_vals,
 
760
                                    GIMP_PDB_VECTORS, vectors_ID,
 
761
                                    GIMP_PDB_INT32, stroke_id,
 
762
                                    GIMP_PDB_INT32, flip_type,
 
763
                                    GIMP_PDB_FLOAT, axis,
 
764
                                    GIMP_PDB_END);
 
765
 
 
766
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
767
 
 
768
  gimp_destroy_params (return_vals, nreturn_vals);
 
769
 
 
770
  return success;
 
771
}
 
772
 
 
773
/**
 
774
 * gimp_vectors_stroke_flip_free:
 
775
 * @vectors_ID: The vectors object.
 
776
 * @stroke_id: The stroke ID.
 
777
 * @x1: X coordinate of the first point of the flipping axis.
 
778
 * @y1: Y coordinate of the first point of the flipping axis.
 
779
 * @x2: X coordinate of the second point of the flipping axis.
 
780
 * @y2: Y coordinate of the second point of the flipping axis.
 
781
 *
 
782
 * flips the given stroke about an arbitrary axis.
 
783
 *
 
784
 * Flips the given stroke about an arbitrary axis. Axis is defined by
 
785
 * two coordinates in the image (in pixels), through which the flipping
 
786
 * axis passes.
 
787
 *
 
788
 * Returns: TRUE on success.
 
789
 *
 
790
 * Since: GIMP 2.4
 
791
 */
 
792
gboolean
 
793
gimp_vectors_stroke_flip_free (gint32  vectors_ID,
 
794
                               gint    stroke_id,
 
795
                               gdouble x1,
 
796
                               gdouble y1,
 
797
                               gdouble x2,
 
798
                               gdouble y2)
 
799
{
 
800
  GimpParam *return_vals;
 
801
  gint nreturn_vals;
 
802
  gboolean success = TRUE;
 
803
 
 
804
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-flip-free",
 
805
                                    &nreturn_vals,
 
806
                                    GIMP_PDB_VECTORS, vectors_ID,
 
807
                                    GIMP_PDB_INT32, stroke_id,
 
808
                                    GIMP_PDB_FLOAT, x1,
 
809
                                    GIMP_PDB_FLOAT, y1,
 
810
                                    GIMP_PDB_FLOAT, x2,
 
811
                                    GIMP_PDB_FLOAT, y2,
 
812
                                    GIMP_PDB_END);
 
813
 
 
814
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
815
 
 
816
  gimp_destroy_params (return_vals, nreturn_vals);
 
817
 
 
818
  return success;
 
819
}
 
820
 
 
821
/**
 
822
 * gimp_vectors_stroke_get_points:
 
823
 * @vectors_ID: The vectors object.
 
824
 * @stroke_id: The stroke ID.
 
825
 * @num_points: The number of floats returned.
 
826
 * @controlpoints: List of the control points for the stroke (x0, y0, x1, y1, ...).
 
827
 * @closed: Whether the stroke is closed or not.
 
828
 *
 
829
 * returns the control points of a stroke.
 
830
 *
 
831
 * returns the control points of a stroke. The interpretation of the
 
832
 * coordinates returned depends on the type of the stroke. For Gimp 2.4
 
833
 * this is always a bezier stroke, where the coordinates are the
 
834
 * control points.
 
835
 *
 
836
 * Returns: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now).
 
837
 *
 
838
 * Since: GIMP 2.4
 
839
 */
 
840
GimpVectorsStrokeType
 
841
gimp_vectors_stroke_get_points (gint32     vectors_ID,
 
842
                                gint       stroke_id,
 
843
                                gint      *num_points,
 
844
                                gdouble  **controlpoints,
 
845
                                gboolean  *closed)
 
846
{
 
847
  GimpParam *return_vals;
 
848
  gint nreturn_vals;
 
849
  GimpVectorsStrokeType type = 0;
 
850
 
 
851
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-points",
 
852
                                    &nreturn_vals,
 
853
                                    GIMP_PDB_VECTORS, vectors_ID,
 
854
                                    GIMP_PDB_INT32, stroke_id,
 
855
                                    GIMP_PDB_END);
 
856
 
 
857
  *num_points = 0;
 
858
 
 
859
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
860
    {
 
861
      type = return_vals[1].data.d_int32;
 
862
      *num_points = return_vals[2].data.d_int32;
 
863
      *controlpoints = g_new (gdouble, *num_points);
 
864
      memcpy (*controlpoints,
 
865
              return_vals[3].data.d_floatarray,
 
866
              *num_points * sizeof (gdouble));
 
867
      *closed = return_vals[4].data.d_int32;
 
868
    }
 
869
 
 
870
  gimp_destroy_params (return_vals, nreturn_vals);
 
871
 
 
872
  return type;
 
873
}
 
874
 
 
875
/**
 
876
 * gimp_vectors_stroke_new_from_points:
 
877
 * @vectors_ID: The vectors object.
 
878
 * @type: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now).
 
879
 * @num_points: The number of elements in the array, i.e. the number of controlpoints in the stroke * 2 (x- and y-coordinate).
 
880
 * @controlpoints: List of the x- and y-coordinates of the control points.
 
881
 * @closed: Whether the stroke is to be closed or not.
 
882
 *
 
883
 * Adds a stroke of a given type to the vectors object.
 
884
 *
 
885
 * Adds a stroke of a given type to the vectors object. The coordinates
 
886
 * of the control points can be specified. For now only strokes of the
 
887
 * type GIMP_VECTORS_STROKE_TYPE_BEZIER are supported. The control
 
888
 * points are specified as a pair of float values for the x- and
 
889
 * y-coordinate. The Bezier stroke type needs a multiple of three
 
890
 * control points. Each Bezier segment endpoint (anchor, A) has two
 
891
 * additional control points (C) associated. They are specified in the
 
892
 * order CACCACCAC...
 
893
 *
 
894
 * Returns: The stroke ID of the newly created stroke.
 
895
 *
 
896
 * Since: GIMP 2.4
 
897
 */
 
898
gint
 
899
gimp_vectors_stroke_new_from_points (gint32                 vectors_ID,
 
900
                                     GimpVectorsStrokeType  type,
 
901
                                     gint                   num_points,
 
902
                                     const gdouble         *controlpoints,
 
903
                                     gboolean               closed)
 
904
{
 
905
  GimpParam *return_vals;
 
906
  gint nreturn_vals;
 
907
  gint stroke_id = 0;
 
908
 
 
909
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-new-from-points",
 
910
                                    &nreturn_vals,
 
911
                                    GIMP_PDB_VECTORS, vectors_ID,
 
912
                                    GIMP_PDB_INT32, type,
 
913
                                    GIMP_PDB_INT32, num_points,
 
914
                                    GIMP_PDB_FLOATARRAY, controlpoints,
 
915
                                    GIMP_PDB_INT32, closed,
 
916
                                    GIMP_PDB_END);
 
917
 
 
918
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
919
    stroke_id = return_vals[1].data.d_int32;
 
920
 
 
921
  gimp_destroy_params (return_vals, nreturn_vals);
 
922
 
 
923
  return stroke_id;
 
924
}
 
925
 
 
926
/**
 
927
 * gimp_vectors_stroke_interpolate:
 
928
 * @vectors_ID: The vectors object.
 
929
 * @stroke_id: The stroke ID.
 
930
 * @precision: The precision used for the approximation.
 
931
 * @num_coords: The number of floats returned.
 
932
 * @closed: Whether the stroke is closed or not.
 
933
 *
 
934
 * returns polygonal approximation of the stroke.
 
935
 *
 
936
 * returns polygonal approximation of the stroke.
 
937
 *
 
938
 * Returns: List of the coords along the path (x0, y0, x1, y1, ...).
 
939
 *
 
940
 * Since: GIMP 2.4
 
941
 */
 
942
gdouble *
 
943
gimp_vectors_stroke_interpolate (gint32    vectors_ID,
 
944
                                 gint      stroke_id,
 
945
                                 gdouble   precision,
 
946
                                 gint     *num_coords,
 
947
                                 gboolean *closed)
 
948
{
 
949
  GimpParam *return_vals;
 
950
  gint nreturn_vals;
 
951
  gdouble *coords = NULL;
 
952
 
 
953
  return_vals = gimp_run_procedure ("gimp-vectors-stroke-interpolate",
 
954
                                    &nreturn_vals,
 
955
                                    GIMP_PDB_VECTORS, vectors_ID,
 
956
                                    GIMP_PDB_INT32, stroke_id,
 
957
                                    GIMP_PDB_FLOAT, precision,
 
958
                                    GIMP_PDB_END);
 
959
 
 
960
  *num_coords = 0;
 
961
 
 
962
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
963
    {
 
964
      *num_coords = return_vals[1].data.d_int32;
 
965
      coords = g_new (gdouble, *num_coords);
 
966
      memcpy (coords,
 
967
              return_vals[2].data.d_floatarray,
 
968
              *num_coords * sizeof (gdouble));
 
969
      *closed = return_vals[3].data.d_int32;
 
970
    }
 
971
 
 
972
  gimp_destroy_params (return_vals, nreturn_vals);
 
973
 
 
974
  return coords;
 
975
}
 
976
 
 
977
/**
 
978
 * gimp_vectors_bezier_stroke_new_moveto:
 
979
 * @vectors_ID: The vectors object.
 
980
 * @x0: The x-coordinate of the moveto.
 
981
 * @y0: The y-coordinate of the moveto.
 
982
 *
 
983
 * Adds a bezier stroke with a single moveto to the vectors object.
 
984
 *
 
985
 * Adds a bezier stroke with a single moveto to the vectors object.
 
986
 *
 
987
 * Returns: The resulting stroke.
 
988
 *
 
989
 * Since: GIMP 2.4
 
990
 */
 
991
gint
 
992
gimp_vectors_bezier_stroke_new_moveto (gint32  vectors_ID,
 
993
                                       gdouble x0,
 
994
                                       gdouble y0)
 
995
{
 
996
  GimpParam *return_vals;
 
997
  gint nreturn_vals;
 
998
  gint stroke_id = 0;
 
999
 
 
1000
  return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-new-moveto",
 
1001
                                    &nreturn_vals,
 
1002
                                    GIMP_PDB_VECTORS, vectors_ID,
 
1003
                                    GIMP_PDB_FLOAT, x0,
 
1004
                                    GIMP_PDB_FLOAT, y0,
 
1005
                                    GIMP_PDB_END);
 
1006
 
 
1007
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
1008
    stroke_id = return_vals[1].data.d_int32;
 
1009
 
 
1010
  gimp_destroy_params (return_vals, nreturn_vals);
 
1011
 
 
1012
  return stroke_id;
 
1013
}
 
1014
 
 
1015
/**
 
1016
 * gimp_vectors_bezier_stroke_lineto:
 
1017
 * @vectors_ID: The vectors object.
 
1018
 * @stroke_id: The stroke ID.
 
1019
 * @x0: The x-coordinate of the lineto.
 
1020
 * @y0: The y-coordinate of the lineto.
 
1021
 *
 
1022
 * Extends a bezier stroke with a lineto.
 
1023
 *
 
1024
 * Extends a bezier stroke with a lineto.
 
1025
 *
 
1026
 * Returns: TRUE on success.
 
1027
 *
 
1028
 * Since: GIMP 2.4
 
1029
 */
 
1030
gboolean
 
1031
gimp_vectors_bezier_stroke_lineto (gint32  vectors_ID,
 
1032
                                   gint    stroke_id,
 
1033
                                   gdouble x0,
 
1034
                                   gdouble y0)
 
1035
{
 
1036
  GimpParam *return_vals;
 
1037
  gint nreturn_vals;
 
1038
  gboolean success = TRUE;
 
1039
 
 
1040
  return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-lineto",
 
1041
                                    &nreturn_vals,
 
1042
                                    GIMP_PDB_VECTORS, vectors_ID,
 
1043
                                    GIMP_PDB_INT32, stroke_id,
 
1044
                                    GIMP_PDB_FLOAT, x0,
 
1045
                                    GIMP_PDB_FLOAT, y0,
 
1046
                                    GIMP_PDB_END);
 
1047
 
 
1048
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
1049
 
 
1050
  gimp_destroy_params (return_vals, nreturn_vals);
 
1051
 
 
1052
  return success;
 
1053
}
 
1054
 
 
1055
/**
 
1056
 * gimp_vectors_bezier_stroke_conicto:
 
1057
 * @vectors_ID: The vectors object.
 
1058
 * @stroke_id: The stroke ID.
 
1059
 * @x0: The x-coordinate of the control point.
 
1060
 * @y0: The y-coordinate of the control point.
 
1061
 * @x1: The x-coordinate of the end point.
 
1062
 * @y1: The y-coordinate of the end point.
 
1063
 *
 
1064
 * Extends a bezier stroke with a conic bezier spline.
 
1065
 *
 
1066
 * Extends a bezier stroke with a conic bezier spline. Actually a cubic
 
1067
 * bezier spline gets added that realizes the shape of a conic bezier
 
1068
 * spline.
 
1069
 *
 
1070
 * Returns: TRUE on success.
 
1071
 *
 
1072
 * Since: GIMP 2.4
 
1073
 */
 
1074
gboolean
 
1075
gimp_vectors_bezier_stroke_conicto (gint32  vectors_ID,
 
1076
                                    gint    stroke_id,
 
1077
                                    gdouble x0,
 
1078
                                    gdouble y0,
 
1079
                                    gdouble x1,
 
1080
                                    gdouble y1)
 
1081
{
 
1082
  GimpParam *return_vals;
 
1083
  gint nreturn_vals;
 
1084
  gboolean success = TRUE;
 
1085
 
 
1086
  return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-conicto",
 
1087
                                    &nreturn_vals,
 
1088
                                    GIMP_PDB_VECTORS, vectors_ID,
 
1089
                                    GIMP_PDB_INT32, stroke_id,
 
1090
                                    GIMP_PDB_FLOAT, x0,
 
1091
                                    GIMP_PDB_FLOAT, y0,
 
1092
                                    GIMP_PDB_FLOAT, x1,
 
1093
                                    GIMP_PDB_FLOAT, y1,
 
1094
                                    GIMP_PDB_END);
 
1095
 
 
1096
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
1097
 
 
1098
  gimp_destroy_params (return_vals, nreturn_vals);
 
1099
 
 
1100
  return success;
 
1101
}
 
1102
 
 
1103
/**
 
1104
 * gimp_vectors_bezier_stroke_cubicto:
 
1105
 * @vectors_ID: The vectors object.
 
1106
 * @stroke_id: The stroke ID.
 
1107
 * @x0: The x-coordinate of the first control point.
 
1108
 * @y0: The y-coordinate of the first control point.
 
1109
 * @x1: The x-coordinate of the second control point.
 
1110
 * @y1: The y-coordinate of the second control point.
 
1111
 * @x2: The x-coordinate of the end point.
 
1112
 * @y2: The y-coordinate of the end point.
 
1113
 *
 
1114
 * Extends a bezier stroke with a cubic bezier spline.
 
1115
 *
 
1116
 * Extends a bezier stroke with a cubic bezier spline.
 
1117
 *
 
1118
 * Returns: TRUE on success.
 
1119
 *
 
1120
 * Since: GIMP 2.4
 
1121
 */
 
1122
gboolean
 
1123
gimp_vectors_bezier_stroke_cubicto (gint32  vectors_ID,
 
1124
                                    gint    stroke_id,
 
1125
                                    gdouble x0,
 
1126
                                    gdouble y0,
 
1127
                                    gdouble x1,
 
1128
                                    gdouble y1,
 
1129
                                    gdouble x2,
 
1130
                                    gdouble y2)
 
1131
{
 
1132
  GimpParam *return_vals;
 
1133
  gint nreturn_vals;
 
1134
  gboolean success = TRUE;
 
1135
 
 
1136
  return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-cubicto",
 
1137
                                    &nreturn_vals,
 
1138
                                    GIMP_PDB_VECTORS, vectors_ID,
 
1139
                                    GIMP_PDB_INT32, stroke_id,
 
1140
                                    GIMP_PDB_FLOAT, x0,
 
1141
                                    GIMP_PDB_FLOAT, y0,
 
1142
                                    GIMP_PDB_FLOAT, x1,
 
1143
                                    GIMP_PDB_FLOAT, y1,
 
1144
                                    GIMP_PDB_FLOAT, x2,
 
1145
                                    GIMP_PDB_FLOAT, y2,
 
1146
                                    GIMP_PDB_END);
 
1147
 
 
1148
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
1149
 
 
1150
  gimp_destroy_params (return_vals, nreturn_vals);
 
1151
 
 
1152
  return success;
 
1153
}
 
1154
 
 
1155
/**
 
1156
 * gimp_vectors_bezier_stroke_new_ellipse:
 
1157
 * @vectors_ID: The vectors object.
 
1158
 * @x0: The x-coordinate of the center.
 
1159
 * @y0: The y-coordinate of the center.
 
1160
 * @radius_x: The radius in x direction.
 
1161
 * @radius_y: The radius in y direction.
 
1162
 * @angle: The angle the x-axis of the ellipse (radians, counterclockwise).
 
1163
 *
 
1164
 * Adds a bezier stroke describing an ellipse the vectors object.
 
1165
 *
 
1166
 * Adds a bezier stroke describing an ellipse the vectors object.
 
1167
 *
 
1168
 * Returns: The resulting stroke.
 
1169
 *
 
1170
 * Since: GIMP 2.4
 
1171
 */
 
1172
gint
 
1173
gimp_vectors_bezier_stroke_new_ellipse (gint32  vectors_ID,
 
1174
                                        gdouble x0,
 
1175
                                        gdouble y0,
 
1176
                                        gdouble radius_x,
 
1177
                                        gdouble radius_y,
 
1178
                                        gdouble angle)
 
1179
{
 
1180
  GimpParam *return_vals;
 
1181
  gint nreturn_vals;
 
1182
  gint stroke_id = 0;
 
1183
 
 
1184
  return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-new-ellipse",
 
1185
                                    &nreturn_vals,
 
1186
                                    GIMP_PDB_VECTORS, vectors_ID,
 
1187
                                    GIMP_PDB_FLOAT, x0,
 
1188
                                    GIMP_PDB_FLOAT, y0,
 
1189
                                    GIMP_PDB_FLOAT, radius_x,
 
1190
                                    GIMP_PDB_FLOAT, radius_y,
 
1191
                                    GIMP_PDB_FLOAT, angle,
 
1192
                                    GIMP_PDB_END);
 
1193
 
 
1194
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
1195
    stroke_id = return_vals[1].data.d_int32;
 
1196
 
 
1197
  gimp_destroy_params (return_vals, nreturn_vals);
 
1198
 
 
1199
  return stroke_id;
 
1200
}
 
1201
 
 
1202
/**
 
1203
 * gimp_vectors_to_selection:
 
1204
 * @vectors_ID: The vectors object to render to the selection.
 
1205
 * @operation: The desired operation with current selection.
 
1206
 * @antialias: Antialias selection.
 
1207
 * @feather: Feather selection.
 
1208
 * @feather_radius_x: Feather radius x.
 
1209
 * @feather_radius_y: Feather radius y.
 
1210
 *
 
1211
 * Transforms the specified vectors object into a selection
 
1212
 *
 
1213
 * This procedure renders the desired vectors object into the current
 
1214
 * selection of the image the vectors object belongs to.
 
1215
 *
 
1216
 * Returns: TRUE on success.
 
1217
 *
 
1218
 * Since: GIMP 2.4
 
1219
 */
 
1220
gboolean
 
1221
gimp_vectors_to_selection (gint32         vectors_ID,
 
1222
                           GimpChannelOps operation,
 
1223
                           gboolean       antialias,
 
1224
                           gboolean       feather,
 
1225
                           gdouble        feather_radius_x,
 
1226
                           gdouble        feather_radius_y)
 
1227
{
 
1228
  GimpParam *return_vals;
 
1229
  gint nreturn_vals;
 
1230
  gboolean success = TRUE;
 
1231
 
 
1232
  return_vals = gimp_run_procedure ("gimp-vectors-to-selection",
 
1233
                                    &nreturn_vals,
 
1234
                                    GIMP_PDB_VECTORS, vectors_ID,
 
1235
                                    GIMP_PDB_INT32, operation,
 
1236
                                    GIMP_PDB_INT32, antialias,
 
1237
                                    GIMP_PDB_INT32, feather,
 
1238
                                    GIMP_PDB_FLOAT, feather_radius_x,
 
1239
                                    GIMP_PDB_FLOAT, feather_radius_y,
 
1240
                                    GIMP_PDB_END);
 
1241
 
 
1242
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
1243
 
 
1244
  gimp_destroy_params (return_vals, nreturn_vals);
 
1245
 
 
1246
  return success;
 
1247
}
 
1248
 
 
1249
/**
 
1250
 * gimp_vectors_import_from_file:
 
1251
 * @image_ID: The image.
 
1252
 * @filename: The name of the SVG file to import.
 
1253
 * @merge: Merge paths into a single vectors object.
 
1254
 * @scale: Scale the SVG to image dimensions.
 
1255
 * @num_vectors: The number of newly created vectors.
 
1256
 * @vectors_ids: The list of newly created vectors.
 
1257
 *
 
1258
 * Import paths from an SVG file.
 
1259
 *
 
1260
 * This procedure imports paths from an SVG file. SVG elements other
 
1261
 * than paths and basic shapes are ignored.
 
1262
 *
 
1263
 * Returns: TRUE on success.
 
1264
 *
 
1265
 * Since: GIMP 2.4
 
1266
 */
 
1267
gboolean
 
1268
gimp_vectors_import_from_file (gint32        image_ID,
 
1269
                               const gchar  *filename,
 
1270
                               gboolean      merge,
 
1271
                               gboolean      scale,
 
1272
                               gint         *num_vectors,
 
1273
                               gint32      **vectors_ids)
 
1274
{
 
1275
  GimpParam *return_vals;
 
1276
  gint nreturn_vals;
 
1277
  gboolean success = TRUE;
 
1278
 
 
1279
  return_vals = gimp_run_procedure ("gimp-vectors-import-from-file",
 
1280
                                    &nreturn_vals,
 
1281
                                    GIMP_PDB_IMAGE, image_ID,
 
1282
                                    GIMP_PDB_STRING, filename,
 
1283
                                    GIMP_PDB_INT32, merge,
 
1284
                                    GIMP_PDB_INT32, scale,
 
1285
                                    GIMP_PDB_END);
 
1286
 
 
1287
  *num_vectors = 0;
 
1288
  *vectors_ids = NULL;
 
1289
 
 
1290
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
1291
 
 
1292
  if (success)
 
1293
    {
 
1294
      *num_vectors = return_vals[1].data.d_int32;
 
1295
      *vectors_ids = g_new (gint32, *num_vectors);
 
1296
      memcpy (*vectors_ids,
 
1297
              return_vals[2].data.d_int32array,
 
1298
              *num_vectors * sizeof (gint32));
 
1299
    }
 
1300
 
 
1301
  gimp_destroy_params (return_vals, nreturn_vals);
 
1302
 
 
1303
  return success;
 
1304
}
 
1305
 
 
1306
/**
 
1307
 * gimp_vectors_import_from_string:
 
1308
 * @image_ID: The image.
 
1309
 * @string: A string that must be a complete and valid SVG document.
 
1310
 * @length: Number of bytes in string or -1 if the string is NULL terminated.
 
1311
 * @merge: Merge paths into a single vectors object.
 
1312
 * @scale: Scale the SVG to image dimensions.
 
1313
 * @num_vectors: The number of newly created vectors.
 
1314
 * @vectors_ids: The list of newly created vectors.
 
1315
 *
 
1316
 * Import paths from an SVG string.
 
1317
 *
 
1318
 * This procedure works like gimp_vectors_import_from_file() but takes
 
1319
 * a string rather than reading the SVG from a file. This allows you to
 
1320
 * write scripts that generate SVG and feed it to GIMP.
 
1321
 *
 
1322
 * Returns: TRUE on success.
 
1323
 *
 
1324
 * Since: GIMP 2.4
 
1325
 */
 
1326
gboolean
 
1327
gimp_vectors_import_from_string (gint32        image_ID,
 
1328
                                 const gchar  *string,
 
1329
                                 gint          length,
 
1330
                                 gboolean      merge,
 
1331
                                 gboolean      scale,
 
1332
                                 gint         *num_vectors,
 
1333
                                 gint32      **vectors_ids)
 
1334
{
 
1335
  GimpParam *return_vals;
 
1336
  gint nreturn_vals;
 
1337
  gboolean success = TRUE;
 
1338
 
 
1339
  return_vals = gimp_run_procedure ("gimp-vectors-import-from-string",
 
1340
                                    &nreturn_vals,
 
1341
                                    GIMP_PDB_IMAGE, image_ID,
 
1342
                                    GIMP_PDB_STRING, string,
 
1343
                                    GIMP_PDB_INT32, length,
 
1344
                                    GIMP_PDB_INT32, merge,
 
1345
                                    GIMP_PDB_INT32, scale,
 
1346
                                    GIMP_PDB_END);
 
1347
 
 
1348
  *num_vectors = 0;
 
1349
  *vectors_ids = NULL;
 
1350
 
 
1351
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
1352
 
 
1353
  if (success)
 
1354
    {
 
1355
      *num_vectors = return_vals[1].data.d_int32;
 
1356
      *vectors_ids = g_new (gint32, *num_vectors);
 
1357
      memcpy (*vectors_ids,
 
1358
              return_vals[2].data.d_int32array,
 
1359
              *num_vectors * sizeof (gint32));
 
1360
    }
 
1361
 
 
1362
  gimp_destroy_params (return_vals, nreturn_vals);
 
1363
 
 
1364
  return success;
 
1365
}