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

« back to all changes in this revision

Viewing changes to app/pdb/drawable_transform_cmds.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
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
17
 */
18
18
 
19
 
/* NOTE: This file is autogenerated by pdbgen.pl. */
 
19
/* NOTE: This file is auto-generated by pdbgen.pl. */
20
20
 
21
21
#include "config.h"
22
22
 
26
26
#include "libgimpmath/gimpmath.h"
27
27
 
28
28
#include "pdb-types.h"
29
 
#include "procedural_db.h"
 
29
#include "gimppdb.h"
 
30
#include "gimpprocedure.h"
 
31
#include "core/gimpparamspecs.h"
30
32
 
31
33
#include "config/gimpcoreconfig.h"
32
34
#include "core/gimp-transform-utils.h"
37
39
#include "core/gimpprogress.h"
38
40
#include "gimp-intl.h"
39
41
 
40
 
static ProcRecord drawable_transform_flip_simple_proc;
41
 
static ProcRecord drawable_transform_flip_proc;
42
 
static ProcRecord drawable_transform_flip_default_proc;
43
 
static ProcRecord drawable_transform_perspective_proc;
44
 
static ProcRecord drawable_transform_perspective_default_proc;
45
 
static ProcRecord drawable_transform_rotate_simple_proc;
46
 
static ProcRecord drawable_transform_rotate_proc;
47
 
static ProcRecord drawable_transform_rotate_default_proc;
48
 
static ProcRecord drawable_transform_scale_proc;
49
 
static ProcRecord drawable_transform_scale_default_proc;
50
 
static ProcRecord drawable_transform_shear_proc;
51
 
static ProcRecord drawable_transform_shear_default_proc;
52
 
static ProcRecord drawable_transform_2d_proc;
53
 
static ProcRecord drawable_transform_2d_default_proc;
54
 
static ProcRecord drawable_transform_matrix_proc;
55
 
static ProcRecord drawable_transform_matrix_default_proc;
56
 
 
57
 
void
58
 
register_drawable_transform_procs (Gimp *gimp)
59
 
{
60
 
  procedural_db_register (gimp, &drawable_transform_flip_simple_proc);
61
 
  procedural_db_register (gimp, &drawable_transform_flip_proc);
62
 
  procedural_db_register (gimp, &drawable_transform_flip_default_proc);
63
 
  procedural_db_register (gimp, &drawable_transform_perspective_proc);
64
 
  procedural_db_register (gimp, &drawable_transform_perspective_default_proc);
65
 
  procedural_db_register (gimp, &drawable_transform_rotate_simple_proc);
66
 
  procedural_db_register (gimp, &drawable_transform_rotate_proc);
67
 
  procedural_db_register (gimp, &drawable_transform_rotate_default_proc);
68
 
  procedural_db_register (gimp, &drawable_transform_scale_proc);
69
 
  procedural_db_register (gimp, &drawable_transform_scale_default_proc);
70
 
  procedural_db_register (gimp, &drawable_transform_shear_proc);
71
 
  procedural_db_register (gimp, &drawable_transform_shear_default_proc);
72
 
  procedural_db_register (gimp, &drawable_transform_2d_proc);
73
 
  procedural_db_register (gimp, &drawable_transform_2d_default_proc);
74
 
  procedural_db_register (gimp, &drawable_transform_matrix_proc);
75
 
  procedural_db_register (gimp, &drawable_transform_matrix_default_proc);
76
 
}
77
 
 
78
 
static Argument *
79
 
drawable_transform_flip_simple_invoker (Gimp         *gimp,
80
 
                                        GimpContext  *context,
81
 
                                        GimpProgress *progress,
82
 
                                        Argument     *args)
 
42
#include "internal_procs.h"
 
43
 
 
44
 
 
45
static GValueArray *
 
46
drawable_transform_flip_simple_invoker (GimpProcedure     *procedure,
 
47
                                        Gimp              *gimp,
 
48
                                        GimpContext       *context,
 
49
                                        GimpProgress      *progress,
 
50
                                        const GValueArray *args)
83
51
{
84
52
  gboolean success = TRUE;
85
 
  Argument *return_args;
 
53
  GValueArray *return_vals;
86
54
  GimpDrawable *drawable;
87
55
  gint32 flip_type;
88
56
  gboolean auto_center;
89
57
  gdouble axis;
90
58
  gboolean clip_result;
91
59
 
92
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
93
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
94
 
    success = FALSE;
95
 
 
96
 
  flip_type = args[1].value.pdb_int;
97
 
  if (flip_type < GIMP_ORIENTATION_HORIZONTAL || flip_type > GIMP_ORIENTATION_VERTICAL)
98
 
    success = FALSE;
99
 
 
100
 
  auto_center = args[2].value.pdb_int ? TRUE : FALSE;
101
 
 
102
 
  axis = args[3].value.pdb_float;
103
 
 
104
 
  clip_result = args[4].value.pdb_int ? TRUE : FALSE;
 
60
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
61
  flip_type = g_value_get_enum (&args->values[1]);
 
62
  auto_center = g_value_get_boolean (&args->values[2]);
 
63
  axis = g_value_get_double (&args->values[3]);
 
64
  clip_result = g_value_get_boolean (&args->values[4]);
105
65
 
106
66
  if (success)
107
67
    {
119
79
        }
120
80
    }
121
81
 
122
 
  return_args = procedural_db_return_args (&drawable_transform_flip_simple_proc, success);
123
 
 
124
 
  if (success)
125
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
126
 
 
127
 
  return return_args;
128
 
}
129
 
 
130
 
static ProcArg drawable_transform_flip_simple_inargs[] =
131
 
{
132
 
  {
133
 
    GIMP_PDB_DRAWABLE,
134
 
    "drawable",
135
 
    "The affected drawable"
136
 
  },
137
 
  {
138
 
    GIMP_PDB_INT32,
139
 
    "flip_type",
140
 
    "Type of flip: GIMP_ORIENTATION_HORIZONTAL (0) or GIMP_ORIENTATION_VERTICAL (1)"
141
 
  },
142
 
  {
143
 
    GIMP_PDB_INT32,
144
 
    "auto_center",
145
 
    "Whether to automatically position the axis in the selection center"
146
 
  },
147
 
  {
148
 
    GIMP_PDB_FLOAT,
149
 
    "axis",
150
 
    "coord. of flip axis"
151
 
  },
152
 
  {
153
 
    GIMP_PDB_INT32,
154
 
    "clip_result",
155
 
    "Whether to clip results"
156
 
  }
157
 
};
158
 
 
159
 
static ProcArg drawable_transform_flip_simple_outargs[] =
160
 
{
161
 
  {
162
 
    GIMP_PDB_DRAWABLE,
163
 
    "drawable",
164
 
    "The flipped drawable"
165
 
  }
166
 
};
167
 
 
168
 
static ProcRecord drawable_transform_flip_simple_proc =
169
 
{
170
 
  "gimp_drawable_transform_flip_simple",
171
 
  "Flip the specified drawable either vertically or horizontally.",
172
 
  "This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. If auto_center is set to true, the flip is around the selection's center. Otherwise, the coordinate of the axis needs to be specified. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable.",
173
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
174
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
175
 
  "2004",
176
 
  NULL,
177
 
  GIMP_INTERNAL,
178
 
  5,
179
 
  drawable_transform_flip_simple_inargs,
180
 
  1,
181
 
  drawable_transform_flip_simple_outargs,
182
 
  { { drawable_transform_flip_simple_invoker } }
183
 
};
184
 
 
185
 
static Argument *
186
 
drawable_transform_flip_invoker (Gimp         *gimp,
187
 
                                 GimpContext  *context,
188
 
                                 GimpProgress *progress,
189
 
                                 Argument     *args)
190
 
{
191
 
  gboolean success = TRUE;
192
 
  Argument *return_args;
193
 
  GimpDrawable *drawable;
194
 
  gdouble x0;
195
 
  gdouble y0;
196
 
  gdouble x1;
197
 
  gdouble y1;
198
 
  gint32 transform_direction;
199
 
  gint32 interpolation;
200
 
  gboolean supersample;
201
 
  gint32 recursion_level;
202
 
  gboolean clip_result;
203
 
 
204
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
205
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
206
 
    success = FALSE;
207
 
 
208
 
  x0 = args[1].value.pdb_float;
209
 
 
210
 
  y0 = args[2].value.pdb_float;
211
 
 
212
 
  x1 = args[3].value.pdb_float;
213
 
 
214
 
  y1 = args[4].value.pdb_float;
215
 
 
216
 
  transform_direction = args[5].value.pdb_int;
217
 
  if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
218
 
    success = FALSE;
219
 
 
220
 
  interpolation = args[6].value.pdb_int;
221
 
  if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
222
 
    success = FALSE;
223
 
 
224
 
  supersample = args[7].value.pdb_int ? TRUE : FALSE;
225
 
 
226
 
  recursion_level = args[8].value.pdb_int;
227
 
  if (recursion_level <= 0)
228
 
    success = FALSE;
229
 
 
230
 
  clip_result = args[9].value.pdb_int ? TRUE : FALSE;
231
 
 
232
 
  if (success)
233
 
    {
234
 
      gint x, y, width, height;
235
 
 
236
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
237
 
 
238
 
      if (success &&
239
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
240
 
        {
241
 
          GimpMatrix3 matrix;
242
 
          gint        off_x, off_y;
243
 
 
244
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
245
 
 
246
 
          x += off_x;
247
 
          y += off_y;
248
 
 
249
 
          /* Assemble the transformation matrix */
250
 
          gimp_transform_matrix_flip_free (x, y, width, height,
251
 
                                           x0, y0, x1, y1,
252
 
                                           &matrix);
253
 
 
254
 
          if (progress)
255
 
            gimp_progress_start (progress, _("Flip..."), FALSE);
256
 
 
257
 
          /* Transform the selection */
258
 
          success = gimp_drawable_transform_affine (drawable, context,
259
 
                                                    &matrix, transform_direction,
260
 
                                                    interpolation, supersample,
261
 
                                                    recursion_level,
262
 
                                                    clip_result, progress);
263
 
 
264
 
          if (progress)
265
 
            gimp_progress_end (progress);
266
 
        }
267
 
    }
268
 
 
269
 
  return_args = procedural_db_return_args (&drawable_transform_flip_proc, success);
270
 
 
271
 
  if (success)
272
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
273
 
 
274
 
  return return_args;
275
 
}
276
 
 
277
 
static ProcArg drawable_transform_flip_inargs[] =
278
 
{
279
 
  {
280
 
    GIMP_PDB_DRAWABLE,
281
 
    "drawable",
282
 
    "The affected drawable"
283
 
  },
284
 
  {
285
 
    GIMP_PDB_FLOAT,
286
 
    "x0",
287
 
    "horz. coord. of one end of axis"
288
 
  },
289
 
  {
290
 
    GIMP_PDB_FLOAT,
291
 
    "y0",
292
 
    "vert. coord. of one end of axis"
293
 
  },
294
 
  {
295
 
    GIMP_PDB_FLOAT,
296
 
    "x1",
297
 
    "horz. coord. of other end of axis"
298
 
  },
299
 
  {
300
 
    GIMP_PDB_FLOAT,
301
 
    "y1",
302
 
    "vert. coord. of other end of axis"
303
 
  },
304
 
  {
305
 
    GIMP_PDB_INT32,
306
 
    "transform_direction",
307
 
    "Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
308
 
  },
309
 
  {
310
 
    GIMP_PDB_INT32,
311
 
    "interpolation",
312
 
    "Type of interpolation: { GIMP_INTERPOLATION_NONE (0), GIMP_INTERPOLATION_LINEAR (1), GIMP_INTERPOLATION_CUBIC (2) }"
313
 
  },
314
 
  {
315
 
    GIMP_PDB_INT32,
316
 
    "supersample",
317
 
    "Whether to perform supersample"
318
 
  },
319
 
  {
320
 
    GIMP_PDB_INT32,
321
 
    "recursion_level",
322
 
    "Level of recursion (3 is a nice default)"
323
 
  },
324
 
  {
325
 
    GIMP_PDB_INT32,
326
 
    "clip_result",
327
 
    "Whether to clip results"
328
 
  }
329
 
};
330
 
 
331
 
static ProcArg drawable_transform_flip_outargs[] =
332
 
{
333
 
  {
334
 
    GIMP_PDB_DRAWABLE,
335
 
    "drawable",
336
 
    "The flipped drawable"
337
 
  }
338
 
};
339
 
 
340
 
static ProcRecord drawable_transform_flip_proc =
341
 
{
342
 
  "gimp_drawable_transform_flip",
343
 
  "Flip the specified drawable around a given line.",
344
 
  "This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. The axis to flip around is specified by specifying two points from that line. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable. The clip results parameter specifies wheter current selection will affect the transform.",
345
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
346
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
347
 
  "2004",
348
 
  NULL,
349
 
  GIMP_INTERNAL,
350
 
  10,
351
 
  drawable_transform_flip_inargs,
352
 
  1,
353
 
  drawable_transform_flip_outargs,
354
 
  { { drawable_transform_flip_invoker } }
355
 
};
356
 
 
357
 
static Argument *
358
 
drawable_transform_flip_default_invoker (Gimp         *gimp,
359
 
                                         GimpContext  *context,
360
 
                                         GimpProgress *progress,
361
 
                                         Argument     *args)
362
 
{
363
 
  gboolean success = TRUE;
364
 
  Argument *return_args;
365
 
  GimpDrawable *drawable;
366
 
  gdouble x0;
367
 
  gdouble y0;
368
 
  gdouble x1;
369
 
  gdouble y1;
370
 
  gboolean interpolate;
371
 
  gboolean clip_result;
372
 
 
373
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
374
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
375
 
    success = FALSE;
376
 
 
377
 
  x0 = args[1].value.pdb_float;
378
 
 
379
 
  y0 = args[2].value.pdb_float;
380
 
 
381
 
  x1 = args[3].value.pdb_float;
382
 
 
383
 
  y1 = args[4].value.pdb_float;
384
 
 
385
 
  interpolate = args[5].value.pdb_int ? TRUE : FALSE;
386
 
 
387
 
  clip_result = args[6].value.pdb_int ? TRUE : FALSE;
388
 
 
389
 
  if (success)
390
 
    {
391
 
      gint x, y, width, height;
392
 
 
393
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
394
 
 
395
 
      if (success &&
396
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
397
 
        {
398
 
          GimpMatrix3           matrix;
399
 
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
400
 
          gint                  off_x, off_y;
401
 
 
402
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
403
 
 
404
 
          x += off_x;
405
 
          y += off_y;
406
 
 
407
 
          /* Assemble the transformation matrix */
408
 
          gimp_transform_matrix_flip_free (x, y, width, height,
409
 
                                           x0, y0, x1, y1,
410
 
                                           &matrix);
411
 
 
412
 
          if (interpolate)
413
 
            interpolation_type = gimp->config->interpolation_type;
414
 
 
415
 
          if (progress)
416
 
            gimp_progress_start (progress, _("Flip..."), FALSE);
417
 
 
418
 
          /* Transform the selection */
419
 
          success = gimp_drawable_transform_affine (drawable, context,
420
 
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
421
 
                                                    interpolation_type,
422
 
                                                    interpolate, 3,
423
 
                                                    clip_result, progress);
424
 
 
425
 
          if (progress)
426
 
            gimp_progress_end (progress);
427
 
        }
428
 
    }
429
 
 
430
 
  return_args = procedural_db_return_args (&drawable_transform_flip_default_proc, success);
431
 
 
432
 
  if (success)
433
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
434
 
 
435
 
  return return_args;
436
 
}
437
 
 
438
 
static ProcArg drawable_transform_flip_default_inargs[] =
439
 
{
440
 
  {
441
 
    GIMP_PDB_DRAWABLE,
442
 
    "drawable",
443
 
    "The affected drawable"
444
 
  },
445
 
  {
446
 
    GIMP_PDB_FLOAT,
447
 
    "x0",
448
 
    "horz. coord. of one end of axis"
449
 
  },
450
 
  {
451
 
    GIMP_PDB_FLOAT,
452
 
    "y0",
453
 
    "vert. coord. of one end of axis"
454
 
  },
455
 
  {
456
 
    GIMP_PDB_FLOAT,
457
 
    "x1",
458
 
    "horz. coord. of other end of axis"
459
 
  },
460
 
  {
461
 
    GIMP_PDB_FLOAT,
462
 
    "y1",
463
 
    "vert. coord. of other end of axis"
464
 
  },
465
 
  {
466
 
    GIMP_PDB_INT32,
467
 
    "interpolate",
468
 
    "Whether to use interpolation and supersampling"
469
 
  },
470
 
  {
471
 
    GIMP_PDB_INT32,
472
 
    "clip_result",
473
 
    "Whether to clip results"
474
 
  }
475
 
};
476
 
 
477
 
static ProcArg drawable_transform_flip_default_outargs[] =
478
 
{
479
 
  {
480
 
    GIMP_PDB_DRAWABLE,
481
 
    "drawable",
482
 
    "The flipped drawable"
483
 
  }
484
 
};
485
 
 
486
 
static ProcRecord drawable_transform_flip_default_proc =
487
 
{
488
 
  "gimp_drawable_transform_flip_default",
489
 
  "Flip the specified drawable around a given line.",
490
 
  "This procedure is a variant of gimp_drawable_transform_flip() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
491
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
492
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
493
 
  "2004",
494
 
  NULL,
495
 
  GIMP_INTERNAL,
496
 
  7,
497
 
  drawable_transform_flip_default_inargs,
498
 
  1,
499
 
  drawable_transform_flip_default_outargs,
500
 
  { { drawable_transform_flip_default_invoker } }
501
 
};
502
 
 
503
 
static Argument *
504
 
drawable_transform_perspective_invoker (Gimp         *gimp,
505
 
                                        GimpContext  *context,
506
 
                                        GimpProgress *progress,
507
 
                                        Argument     *args)
508
 
{
509
 
  gboolean success = TRUE;
510
 
  Argument *return_args;
511
 
  GimpDrawable *drawable;
512
 
  gint32 transform_direction;
513
 
  gint32 interpolation;
514
 
  gboolean supersample;
515
 
  gint32 recursion_level;
516
 
  gboolean clip_result;
517
 
  gdouble trans_info[8];
518
 
 
519
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
520
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
521
 
    success = FALSE;
522
 
 
523
 
  trans_info[X0] = args[1].value.pdb_float;
524
 
 
525
 
  trans_info[Y0] = args[2].value.pdb_float;
526
 
 
527
 
  trans_info[X1] = args[3].value.pdb_float;
528
 
 
529
 
  trans_info[Y1] = args[4].value.pdb_float;
530
 
 
531
 
  trans_info[X2] = args[5].value.pdb_float;
532
 
 
533
 
  trans_info[Y2] = args[6].value.pdb_float;
534
 
 
535
 
  trans_info[X3] = args[7].value.pdb_float;
536
 
 
537
 
  trans_info[Y3] = args[8].value.pdb_float;
538
 
 
539
 
  transform_direction = args[9].value.pdb_int;
540
 
  if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
541
 
    success = FALSE;
542
 
 
543
 
  interpolation = args[10].value.pdb_int;
544
 
  if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
545
 
    success = FALSE;
546
 
 
547
 
  supersample = args[11].value.pdb_int ? TRUE : FALSE;
548
 
 
549
 
  recursion_level = args[12].value.pdb_int;
550
 
  if (recursion_level <= 0)
551
 
    success = FALSE;
552
 
 
553
 
  clip_result = args[13].value.pdb_int ? TRUE : FALSE;
554
 
 
555
 
  if (success)
556
 
    {
557
 
      gint x, y, width, height;
558
 
 
559
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
560
 
 
561
 
      if (success &&
562
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
563
 
        {
564
 
          GimpMatrix3 matrix;
565
 
          gint        off_x, off_y;
566
 
 
567
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
568
 
 
569
 
          x += off_x;
570
 
          y += off_y;
571
 
 
572
 
          /* Assemble the transformation matrix */
573
 
          gimp_transform_matrix_perspective (x, y, width, height,
574
 
                                             trans_info[X0], trans_info[Y0],
575
 
                                             trans_info[X1], trans_info[Y1],
576
 
                                             trans_info[X2], trans_info[Y2],
577
 
                                             trans_info[X3], trans_info[Y3],
578
 
                                             &matrix);
579
 
 
580
 
          if (progress)
581
 
            gimp_progress_start (progress, _("Perspective..."), FALSE);
582
 
 
583
 
          /* Transform the selection */
584
 
          success = gimp_drawable_transform_affine (drawable, context,
585
 
                                                    &matrix, transform_direction,
586
 
                                                    interpolation, supersample,
587
 
                                                    recursion_level,
588
 
                                                    clip_result, progress);
589
 
 
590
 
          if (progress)
591
 
            gimp_progress_end (progress);
592
 
        }
593
 
    }
594
 
 
595
 
  return_args = procedural_db_return_args (&drawable_transform_perspective_proc, success);
596
 
 
597
 
  if (success)
598
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
599
 
 
600
 
  return return_args;
601
 
}
602
 
 
603
 
static ProcArg drawable_transform_perspective_inargs[] =
604
 
{
605
 
  {
606
 
    GIMP_PDB_DRAWABLE,
607
 
    "drawable",
608
 
    "The affected drawable"
609
 
  },
610
 
  {
611
 
    GIMP_PDB_FLOAT,
612
 
    "x0",
613
 
    "The new x coordinate of upper-left corner of original bounding box"
614
 
  },
615
 
  {
616
 
    GIMP_PDB_FLOAT,
617
 
    "y0",
618
 
    "The new y coordinate of upper-left corner of original bounding box"
619
 
  },
620
 
  {
621
 
    GIMP_PDB_FLOAT,
622
 
    "x1",
623
 
    "The new x coordinate of upper-right corner of original bounding box"
624
 
  },
625
 
  {
626
 
    GIMP_PDB_FLOAT,
627
 
    "y1",
628
 
    "The new y coordinate of upper-right corner of original bounding box"
629
 
  },
630
 
  {
631
 
    GIMP_PDB_FLOAT,
632
 
    "x2",
633
 
    "The new x coordinate of lower-left corner of original bounding box"
634
 
  },
635
 
  {
636
 
    GIMP_PDB_FLOAT,
637
 
    "y2",
638
 
    "The new y coordinate of lower-left corner of original bounding box"
639
 
  },
640
 
  {
641
 
    GIMP_PDB_FLOAT,
642
 
    "x3",
643
 
    "The new x coordinate of lower-right corner of original bounding box"
644
 
  },
645
 
  {
646
 
    GIMP_PDB_FLOAT,
647
 
    "y3",
648
 
    "The new y coordinate of lower-right corner of original bounding box"
649
 
  },
650
 
  {
651
 
    GIMP_PDB_INT32,
652
 
    "transform_direction",
653
 
    "Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
654
 
  },
655
 
  {
656
 
    GIMP_PDB_INT32,
657
 
    "interpolation",
658
 
    "Type of interpolation: { GIMP_INTERPOLATION_NONE (0), GIMP_INTERPOLATION_LINEAR (1), GIMP_INTERPOLATION_CUBIC (2) }"
659
 
  },
660
 
  {
661
 
    GIMP_PDB_INT32,
662
 
    "supersample",
663
 
    "Whether to perform supersample"
664
 
  },
665
 
  {
666
 
    GIMP_PDB_INT32,
667
 
    "recursion_level",
668
 
    "Level of recursion (3 is a nice default)"
669
 
  },
670
 
  {
671
 
    GIMP_PDB_INT32,
672
 
    "clip_result",
673
 
    "Whether to clip results"
674
 
  }
675
 
};
676
 
 
677
 
static ProcArg drawable_transform_perspective_outargs[] =
678
 
{
679
 
  {
680
 
    GIMP_PDB_DRAWABLE,
681
 
    "drawable",
682
 
    "The newly mapped drawable"
683
 
  }
684
 
};
685
 
 
686
 
static ProcRecord drawable_transform_perspective_proc =
687
 
{
688
 
  "gimp_drawable_transform_perspective",
689
 
  "Perform a possibly non-affine transformation on the specified drawable, with extra parameters.",
690
 
  "This procedure performs a possibly non-affine transformation on the specified drawable by allowing the corners of the original bounding box to be arbitrarily remapped to any values. The specified drawable is remapped if no selection exists. However, if a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then remapped as specified. The return value is the ID of the remapped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and remapped drawable. The 4 coordinates specify the new locations of each corner of the original bounding box. By specifying these values, any affine transformation (rotation, scaling, translation) can be affected. Additionally, these values can be specified such that the resulting transformed drawable will appear to have been projected via a perspective transform.",
691
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
692
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
693
 
  "2004",
694
 
  NULL,
695
 
  GIMP_INTERNAL,
696
 
  14,
697
 
  drawable_transform_perspective_inargs,
698
 
  1,
699
 
  drawable_transform_perspective_outargs,
700
 
  { { drawable_transform_perspective_invoker } }
701
 
};
702
 
 
703
 
static Argument *
704
 
drawable_transform_perspective_default_invoker (Gimp         *gimp,
705
 
                                                GimpContext  *context,
706
 
                                                GimpProgress *progress,
707
 
                                                Argument     *args)
708
 
{
709
 
  gboolean success = TRUE;
710
 
  Argument *return_args;
711
 
  GimpDrawable *drawable;
712
 
  gboolean interpolate;
713
 
  gboolean clip_result;
714
 
  gdouble trans_info[8];
715
 
 
716
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
717
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
718
 
    success = FALSE;
719
 
 
720
 
  trans_info[X0] = args[1].value.pdb_float;
721
 
 
722
 
  trans_info[Y0] = args[2].value.pdb_float;
723
 
 
724
 
  trans_info[X1] = args[3].value.pdb_float;
725
 
 
726
 
  trans_info[Y1] = args[4].value.pdb_float;
727
 
 
728
 
  trans_info[X2] = args[5].value.pdb_float;
729
 
 
730
 
  trans_info[Y2] = args[6].value.pdb_float;
731
 
 
732
 
  trans_info[X3] = args[7].value.pdb_float;
733
 
 
734
 
  trans_info[Y3] = args[8].value.pdb_float;
735
 
 
736
 
  interpolate = args[9].value.pdb_int ? TRUE : FALSE;
737
 
 
738
 
  clip_result = args[10].value.pdb_int ? TRUE : FALSE;
739
 
 
740
 
  if (success)
741
 
    {
742
 
      gint x, y, width, height;
743
 
 
744
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
745
 
 
746
 
      if (success &&
747
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
748
 
        {
749
 
          GimpMatrix3           matrix;
750
 
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
751
 
          gint                  off_x, off_y;
752
 
 
753
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
754
 
 
755
 
          x += off_x;
756
 
          y += off_y;
757
 
 
758
 
          /* Assemble the transformation matrix */
759
 
          gimp_transform_matrix_perspective (x, y, width, height,
760
 
                                             trans_info[X0], trans_info[Y0],
761
 
                                             trans_info[X1], trans_info[Y1],
762
 
                                             trans_info[X2], trans_info[Y2],
763
 
                                             trans_info[X3], trans_info[Y3],
764
 
                                             &matrix);
765
 
 
766
 
          if (interpolate)
767
 
            interpolation_type = gimp->config->interpolation_type;
768
 
 
769
 
          if (progress)
770
 
            gimp_progress_start (progress, _("Perspective..."), FALSE);
771
 
 
772
 
          /* Transform the selection */
773
 
          success = gimp_drawable_transform_affine (drawable, context,
774
 
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
775
 
                                                    interpolation_type,
776
 
                                                    interpolate, 3,
777
 
                                                    clip_result, progress);
778
 
 
779
 
          if (progress)
780
 
            gimp_progress_end (progress);
781
 
        }
782
 
    }
783
 
 
784
 
  return_args = procedural_db_return_args (&drawable_transform_perspective_default_proc, success);
785
 
 
786
 
  if (success)
787
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
788
 
 
789
 
  return return_args;
790
 
}
791
 
 
792
 
static ProcArg drawable_transform_perspective_default_inargs[] =
793
 
{
794
 
  {
795
 
    GIMP_PDB_DRAWABLE,
796
 
    "drawable",
797
 
    "The affected drawable"
798
 
  },
799
 
  {
800
 
    GIMP_PDB_FLOAT,
801
 
    "x0",
802
 
    "The new x coordinate of upper-left corner of original bounding box"
803
 
  },
804
 
  {
805
 
    GIMP_PDB_FLOAT,
806
 
    "y0",
807
 
    "The new y coordinate of upper-left corner of original bounding box"
808
 
  },
809
 
  {
810
 
    GIMP_PDB_FLOAT,
811
 
    "x1",
812
 
    "The new x coordinate of upper-right corner of original bounding box"
813
 
  },
814
 
  {
815
 
    GIMP_PDB_FLOAT,
816
 
    "y1",
817
 
    "The new y coordinate of upper-right corner of original bounding box"
818
 
  },
819
 
  {
820
 
    GIMP_PDB_FLOAT,
821
 
    "x2",
822
 
    "The new x coordinate of lower-left corner of original bounding box"
823
 
  },
824
 
  {
825
 
    GIMP_PDB_FLOAT,
826
 
    "y2",
827
 
    "The new y coordinate of lower-left corner of original bounding box"
828
 
  },
829
 
  {
830
 
    GIMP_PDB_FLOAT,
831
 
    "x3",
832
 
    "The new x coordinate of lower-right corner of original bounding box"
833
 
  },
834
 
  {
835
 
    GIMP_PDB_FLOAT,
836
 
    "y3",
837
 
    "The new y coordinate of lower-right corner of original bounding box"
838
 
  },
839
 
  {
840
 
    GIMP_PDB_INT32,
841
 
    "interpolate",
842
 
    "Whether to use interpolation and supersampling"
843
 
  },
844
 
  {
845
 
    GIMP_PDB_INT32,
846
 
    "clip_result",
847
 
    "Whether to clip results"
848
 
  }
849
 
};
850
 
 
851
 
static ProcArg drawable_transform_perspective_default_outargs[] =
852
 
{
853
 
  {
854
 
    GIMP_PDB_DRAWABLE,
855
 
    "drawable",
856
 
    "The newly mapped drawable"
857
 
  }
858
 
};
859
 
 
860
 
static ProcRecord drawable_transform_perspective_default_proc =
861
 
{
862
 
  "gimp_drawable_transform_perspective_default",
863
 
  "Perform a possibly non-affine transformation on the specified drawable, with extra parameters.",
864
 
  "This procedure is a variant of gimp_drawable_transform_perspective() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
865
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
866
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
867
 
  "2004",
868
 
  NULL,
869
 
  GIMP_INTERNAL,
870
 
  11,
871
 
  drawable_transform_perspective_default_inargs,
872
 
  1,
873
 
  drawable_transform_perspective_default_outargs,
874
 
  { { drawable_transform_perspective_default_invoker } }
875
 
};
876
 
 
877
 
static Argument *
878
 
drawable_transform_rotate_simple_invoker (Gimp         *gimp,
879
 
                                          GimpContext  *context,
880
 
                                          GimpProgress *progress,
881
 
                                          Argument     *args)
882
 
{
883
 
  gboolean success = TRUE;
884
 
  Argument *return_args;
 
82
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
83
 
 
84
  if (success)
 
85
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
86
 
 
87
  return return_vals;
 
88
}
 
89
 
 
90
static GValueArray *
 
91
drawable_transform_flip_invoker (GimpProcedure     *procedure,
 
92
                                 Gimp              *gimp,
 
93
                                 GimpContext       *context,
 
94
                                 GimpProgress      *progress,
 
95
                                 const GValueArray *args)
 
96
{
 
97
  gboolean success = TRUE;
 
98
  GValueArray *return_vals;
 
99
  GimpDrawable *drawable;
 
100
  gdouble x0;
 
101
  gdouble y0;
 
102
  gdouble x1;
 
103
  gdouble y1;
 
104
  gint32 transform_direction;
 
105
  gint32 interpolation;
 
106
  gboolean supersample;
 
107
  gint32 recursion_level;
 
108
  gboolean clip_result;
 
109
 
 
110
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
111
  x0 = g_value_get_double (&args->values[1]);
 
112
  y0 = g_value_get_double (&args->values[2]);
 
113
  x1 = g_value_get_double (&args->values[3]);
 
114
  y1 = g_value_get_double (&args->values[4]);
 
115
  transform_direction = g_value_get_enum (&args->values[5]);
 
116
  interpolation = g_value_get_enum (&args->values[6]);
 
117
  supersample = g_value_get_boolean (&args->values[7]);
 
118
  recursion_level = g_value_get_int (&args->values[8]);
 
119
  clip_result = g_value_get_boolean (&args->values[9]);
 
120
 
 
121
  if (success)
 
122
    {
 
123
      gint x, y, width, height;
 
124
 
 
125
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
126
 
 
127
      if (success &&
 
128
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
129
        {
 
130
          GimpMatrix3 matrix;
 
131
          gint        off_x, off_y;
 
132
 
 
133
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
134
 
 
135
          x += off_x;
 
136
          y += off_y;
 
137
 
 
138
          /* Assemble the transformation matrix */
 
139
          gimp_matrix3_identity (&matrix);
 
140
          gimp_transform_matrix_flip_free (&matrix,
 
141
                                           x0, y0, x1, y1);
 
142
 
 
143
          if (progress)
 
144
            gimp_progress_start (progress, _("Flipping"), FALSE);
 
145
 
 
146
          /* Transform the selection */
 
147
          success = gimp_drawable_transform_affine (drawable, context,
 
148
                                                    &matrix, transform_direction,
 
149
                                                    interpolation, supersample,
 
150
                                                    recursion_level,
 
151
                                                    clip_result, progress);
 
152
 
 
153
          if (progress)
 
154
            gimp_progress_end (progress);
 
155
        }
 
156
    }
 
157
 
 
158
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
159
 
 
160
  if (success)
 
161
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
162
 
 
163
  return return_vals;
 
164
}
 
165
 
 
166
static GValueArray *
 
167
drawable_transform_flip_default_invoker (GimpProcedure     *procedure,
 
168
                                         Gimp              *gimp,
 
169
                                         GimpContext       *context,
 
170
                                         GimpProgress      *progress,
 
171
                                         const GValueArray *args)
 
172
{
 
173
  gboolean success = TRUE;
 
174
  GValueArray *return_vals;
 
175
  GimpDrawable *drawable;
 
176
  gdouble x0;
 
177
  gdouble y0;
 
178
  gdouble x1;
 
179
  gdouble y1;
 
180
  gboolean interpolate;
 
181
  gboolean clip_result;
 
182
 
 
183
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
184
  x0 = g_value_get_double (&args->values[1]);
 
185
  y0 = g_value_get_double (&args->values[2]);
 
186
  x1 = g_value_get_double (&args->values[3]);
 
187
  y1 = g_value_get_double (&args->values[4]);
 
188
  interpolate = g_value_get_boolean (&args->values[5]);
 
189
  clip_result = g_value_get_boolean (&args->values[6]);
 
190
 
 
191
  if (success)
 
192
    {
 
193
      gint x, y, width, height;
 
194
 
 
195
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
196
 
 
197
      if (success &&
 
198
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
199
        {
 
200
          GimpMatrix3           matrix;
 
201
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
 
202
          gint                  off_x, off_y;
 
203
 
 
204
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
205
 
 
206
          x += off_x;
 
207
          y += off_y;
 
208
 
 
209
          /* Assemble the transformation matrix */
 
210
          gimp_matrix3_identity (&matrix);
 
211
          gimp_transform_matrix_flip_free (&matrix,
 
212
                                           x0, y0, x1, y1);
 
213
 
 
214
          if (interpolate)
 
215
            interpolation_type = gimp->config->interpolation_type;
 
216
 
 
217
          if (progress)
 
218
            gimp_progress_start (progress, _("Flipping"), FALSE);
 
219
 
 
220
          /* Transform the selection */
 
221
          success = gimp_drawable_transform_affine (drawable, context,
 
222
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
 
223
                                                    interpolation_type,
 
224
                                                    interpolate, 3,
 
225
                                                    clip_result, progress);
 
226
 
 
227
          if (progress)
 
228
            gimp_progress_end (progress);
 
229
        }
 
230
    }
 
231
 
 
232
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
233
 
 
234
  if (success)
 
235
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
236
 
 
237
  return return_vals;
 
238
}
 
239
 
 
240
static GValueArray *
 
241
drawable_transform_perspective_invoker (GimpProcedure     *procedure,
 
242
                                        Gimp              *gimp,
 
243
                                        GimpContext       *context,
 
244
                                        GimpProgress      *progress,
 
245
                                        const GValueArray *args)
 
246
{
 
247
  gboolean success = TRUE;
 
248
  GValueArray *return_vals;
 
249
  GimpDrawable *drawable;
 
250
  gdouble x0;
 
251
  gdouble y0;
 
252
  gdouble x1;
 
253
  gdouble y1;
 
254
  gdouble x2;
 
255
  gdouble y2;
 
256
  gdouble x3;
 
257
  gdouble y3;
 
258
  gint32 transform_direction;
 
259
  gint32 interpolation;
 
260
  gboolean supersample;
 
261
  gint32 recursion_level;
 
262
  gint32 clip_result;
 
263
 
 
264
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
265
  x0 = g_value_get_double (&args->values[1]);
 
266
  y0 = g_value_get_double (&args->values[2]);
 
267
  x1 = g_value_get_double (&args->values[3]);
 
268
  y1 = g_value_get_double (&args->values[4]);
 
269
  x2 = g_value_get_double (&args->values[5]);
 
270
  y2 = g_value_get_double (&args->values[6]);
 
271
  x3 = g_value_get_double (&args->values[7]);
 
272
  y3 = g_value_get_double (&args->values[8]);
 
273
  transform_direction = g_value_get_enum (&args->values[9]);
 
274
  interpolation = g_value_get_enum (&args->values[10]);
 
275
  supersample = g_value_get_boolean (&args->values[11]);
 
276
  recursion_level = g_value_get_int (&args->values[12]);
 
277
  clip_result = g_value_get_enum (&args->values[13]);
 
278
 
 
279
  if (success)
 
280
    {
 
281
      gint x, y, width, height;
 
282
 
 
283
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
284
 
 
285
      if (success &&
 
286
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
287
        {
 
288
          GimpMatrix3 matrix;
 
289
          gint        off_x, off_y;
 
290
 
 
291
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
292
 
 
293
          x += off_x;
 
294
          y += off_y;
 
295
 
 
296
          /* Assemble the transformation matrix */
 
297
          gimp_matrix3_identity (&matrix);
 
298
          gimp_transform_matrix_perspective (&matrix,
 
299
                                             x, y, width, height,
 
300
                                             x0, y0, x1, y1,
 
301
                                             x2, y2, x3, y3);
 
302
 
 
303
          if (progress)
 
304
            gimp_progress_start (progress, _("Perspective"), FALSE);
 
305
 
 
306
          /* Transform the selection */
 
307
          success = gimp_drawable_transform_affine (drawable, context,
 
308
                                                    &matrix, transform_direction,
 
309
                                                    interpolation, supersample,
 
310
                                                    recursion_level,
 
311
                                                    clip_result, progress);
 
312
 
 
313
          if (progress)
 
314
            gimp_progress_end (progress);
 
315
        }
 
316
    }
 
317
 
 
318
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
319
 
 
320
  if (success)
 
321
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
322
 
 
323
  return return_vals;
 
324
}
 
325
 
 
326
static GValueArray *
 
327
drawable_transform_perspective_default_invoker (GimpProcedure     *procedure,
 
328
                                                Gimp              *gimp,
 
329
                                                GimpContext       *context,
 
330
                                                GimpProgress      *progress,
 
331
                                                const GValueArray *args)
 
332
{
 
333
  gboolean success = TRUE;
 
334
  GValueArray *return_vals;
 
335
  GimpDrawable *drawable;
 
336
  gdouble x0;
 
337
  gdouble y0;
 
338
  gdouble x1;
 
339
  gdouble y1;
 
340
  gdouble x2;
 
341
  gdouble y2;
 
342
  gdouble x3;
 
343
  gdouble y3;
 
344
  gboolean interpolate;
 
345
  gint32 clip_result;
 
346
 
 
347
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
348
  x0 = g_value_get_double (&args->values[1]);
 
349
  y0 = g_value_get_double (&args->values[2]);
 
350
  x1 = g_value_get_double (&args->values[3]);
 
351
  y1 = g_value_get_double (&args->values[4]);
 
352
  x2 = g_value_get_double (&args->values[5]);
 
353
  y2 = g_value_get_double (&args->values[6]);
 
354
  x3 = g_value_get_double (&args->values[7]);
 
355
  y3 = g_value_get_double (&args->values[8]);
 
356
  interpolate = g_value_get_boolean (&args->values[9]);
 
357
  clip_result = g_value_get_enum (&args->values[10]);
 
358
 
 
359
  if (success)
 
360
    {
 
361
      gint x, y, width, height;
 
362
 
 
363
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
364
 
 
365
      if (success &&
 
366
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
367
        {
 
368
          GimpMatrix3           matrix;
 
369
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
 
370
          gint                  off_x, off_y;
 
371
 
 
372
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
373
 
 
374
          x += off_x;
 
375
          y += off_y;
 
376
 
 
377
          /* Assemble the transformation matrix */
 
378
          gimp_matrix3_identity (&matrix);
 
379
          gimp_transform_matrix_perspective (&matrix,
 
380
                                             x, y, width, height,
 
381
                                             x0, y0, x1, y1,
 
382
                                             x2, y2, x3, y3);
 
383
 
 
384
          if (interpolate)
 
385
            interpolation_type = gimp->config->interpolation_type;
 
386
 
 
387
          if (progress)
 
388
            gimp_progress_start (progress, _("Perspective"), FALSE);
 
389
 
 
390
          /* Transform the selection */
 
391
          success = gimp_drawable_transform_affine (drawable, context,
 
392
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
 
393
                                                    interpolation_type,
 
394
                                                    interpolate, 3,
 
395
                                                    clip_result, progress);
 
396
 
 
397
          if (progress)
 
398
            gimp_progress_end (progress);
 
399
        }
 
400
    }
 
401
 
 
402
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
403
 
 
404
  if (success)
 
405
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
406
 
 
407
  return return_vals;
 
408
}
 
409
 
 
410
static GValueArray *
 
411
drawable_transform_rotate_simple_invoker (GimpProcedure     *procedure,
 
412
                                          Gimp              *gimp,
 
413
                                          GimpContext       *context,
 
414
                                          GimpProgress      *progress,
 
415
                                          const GValueArray *args)
 
416
{
 
417
  gboolean success = TRUE;
 
418
  GValueArray *return_vals;
885
419
  GimpDrawable *drawable;
886
420
  gint32 rotate_type;
887
421
  gboolean auto_center;
889
423
  gint32 center_y;
890
424
  gboolean clip_result;
891
425
 
892
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
893
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
894
 
    success = FALSE;
895
 
 
896
 
  rotate_type = args[1].value.pdb_int;
897
 
  if (rotate_type < GIMP_ROTATE_90 || rotate_type > GIMP_ROTATE_270)
898
 
    success = FALSE;
899
 
 
900
 
  auto_center = args[2].value.pdb_int ? TRUE : FALSE;
901
 
 
902
 
  center_x = args[3].value.pdb_int;
903
 
 
904
 
  center_y = args[4].value.pdb_int;
905
 
 
906
 
  clip_result = args[5].value.pdb_int ? TRUE : FALSE;
 
426
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
427
  rotate_type = g_value_get_enum (&args->values[1]);
 
428
  auto_center = g_value_get_boolean (&args->values[2]);
 
429
  center_x = g_value_get_int (&args->values[3]);
 
430
  center_y = g_value_get_int (&args->values[4]);
 
431
  clip_result = g_value_get_boolean (&args->values[5]);
907
432
 
908
433
  if (success)
909
434
    {
921
446
        }
922
447
    }
923
448
 
924
 
  return_args = procedural_db_return_args (&drawable_transform_rotate_simple_proc, success);
925
 
 
926
 
  if (success)
927
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
928
 
 
929
 
  return return_args;
930
 
}
931
 
 
932
 
static ProcArg drawable_transform_rotate_simple_inargs[] =
933
 
{
934
 
  {
935
 
    GIMP_PDB_DRAWABLE,
936
 
    "drawable",
937
 
    "The affected drawable"
938
 
  },
939
 
  {
940
 
    GIMP_PDB_INT32,
941
 
    "rotate_type",
942
 
    "Type of rotation: GIMP_ROTATE_90 (0), GIMP_ROTATE_180 (1), GIMP_ROTATE_270 (2)"
943
 
  },
944
 
  {
945
 
    GIMP_PDB_INT32,
946
 
    "auto_center",
947
 
    "Whether to automatically rotate around the selection center"
948
 
  },
949
 
  {
950
 
    GIMP_PDB_INT32,
951
 
    "center_x",
952
 
    "The hor. coordinate of the center of rotation"
953
 
  },
954
 
  {
955
 
    GIMP_PDB_INT32,
956
 
    "center_y",
957
 
    "The vert. coordinate of the center of rotation"
958
 
  },
959
 
  {
960
 
    GIMP_PDB_INT32,
961
 
    "clip_result",
962
 
    "Whether to clip results"
963
 
  }
964
 
};
965
 
 
966
 
static ProcArg drawable_transform_rotate_simple_outargs[] =
967
 
{
968
 
  {
969
 
    GIMP_PDB_DRAWABLE,
970
 
    "drawable",
971
 
    "The rotated drawable"
972
 
  }
973
 
};
974
 
 
975
 
static ProcRecord drawable_transform_rotate_simple_proc =
976
 
{
977
 
  "gimp_drawable_transform_rotate_simple",
978
 
  "Rotate the specified drawable about given coordinates through the specified angle.",
979
 
  "This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
980
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
981
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
982
 
  "2004",
983
 
  NULL,
984
 
  GIMP_INTERNAL,
985
 
  6,
986
 
  drawable_transform_rotate_simple_inargs,
987
 
  1,
988
 
  drawable_transform_rotate_simple_outargs,
989
 
  { { drawable_transform_rotate_simple_invoker } }
990
 
};
991
 
 
992
 
static Argument *
993
 
drawable_transform_rotate_invoker (Gimp         *gimp,
994
 
                                   GimpContext  *context,
995
 
                                   GimpProgress *progress,
996
 
                                   Argument     *args)
997
 
{
998
 
  gboolean success = TRUE;
999
 
  Argument *return_args;
1000
 
  GimpDrawable *drawable;
1001
 
  gdouble angle;
1002
 
  gboolean auto_center;
1003
 
  gint32 center_x;
1004
 
  gint32 center_y;
1005
 
  gint32 transform_direction;
1006
 
  gint32 interpolation;
1007
 
  gboolean supersample;
1008
 
  gint32 recursion_level;
1009
 
  gboolean clip_result;
1010
 
 
1011
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1012
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
1013
 
    success = FALSE;
1014
 
 
1015
 
  angle = args[1].value.pdb_float;
1016
 
 
1017
 
  auto_center = args[2].value.pdb_int ? TRUE : FALSE;
1018
 
 
1019
 
  center_x = args[3].value.pdb_int;
1020
 
 
1021
 
  center_y = args[4].value.pdb_int;
1022
 
 
1023
 
  transform_direction = args[5].value.pdb_int;
1024
 
  if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
1025
 
    success = FALSE;
1026
 
 
1027
 
  interpolation = args[6].value.pdb_int;
1028
 
  if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
1029
 
    success = FALSE;
1030
 
 
1031
 
  supersample = args[7].value.pdb_int ? TRUE : FALSE;
1032
 
 
1033
 
  recursion_level = args[8].value.pdb_int;
1034
 
  if (recursion_level <= 0)
1035
 
    success = FALSE;
1036
 
 
1037
 
  clip_result = args[9].value.pdb_int ? TRUE : FALSE;
1038
 
 
1039
 
  if (success)
1040
 
    {
1041
 
      gint x, y, width, height;
1042
 
 
1043
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
1044
 
 
1045
 
      if (success &&
1046
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
1047
 
        {
1048
 
          GimpMatrix3 matrix;
1049
 
          gint        off_x, off_y;
1050
 
 
1051
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
1052
 
 
1053
 
          x += off_x;
1054
 
          y += off_y;
1055
 
 
1056
 
          /* Assemble the transformation matrix */
1057
 
          if (auto_center)
1058
 
            gimp_transform_matrix_rotate (x, y, width, height, angle,
1059
 
                                          &matrix);
1060
 
          else
1061
 
            gimp_transform_matrix_rotate_center (center_x, center_y, angle,
1062
 
                                                 &matrix);
1063
 
 
1064
 
          if (progress)
1065
 
            gimp_progress_start (progress, _("Rotating..."), FALSE);
1066
 
 
1067
 
          /* Transform the selection */
1068
 
          success = gimp_drawable_transform_affine (drawable, context,
1069
 
                                                    &matrix, transform_direction,
1070
 
                                                    interpolation, supersample,
1071
 
                                                    recursion_level,
1072
 
                                                    clip_result, progress);
1073
 
 
1074
 
          if (progress)
1075
 
            gimp_progress_end (progress);
1076
 
        }
1077
 
    }
1078
 
 
1079
 
  return_args = procedural_db_return_args (&drawable_transform_rotate_proc, success);
1080
 
 
1081
 
  if (success)
1082
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
1083
 
 
1084
 
  return return_args;
1085
 
}
1086
 
 
1087
 
static ProcArg drawable_transform_rotate_inargs[] =
1088
 
{
1089
 
  {
1090
 
    GIMP_PDB_DRAWABLE,
1091
 
    "drawable",
1092
 
    "The affected drawable"
1093
 
  },
1094
 
  {
1095
 
    GIMP_PDB_FLOAT,
1096
 
    "angle",
1097
 
    "The angle of rotation (radians)"
1098
 
  },
1099
 
  {
1100
 
    GIMP_PDB_INT32,
1101
 
    "auto_center",
1102
 
    "Whether to automatically rotate around the selection center"
1103
 
  },
1104
 
  {
1105
 
    GIMP_PDB_INT32,
1106
 
    "center_x",
1107
 
    "The hor. coordinate of the center of rotation"
1108
 
  },
1109
 
  {
1110
 
    GIMP_PDB_INT32,
1111
 
    "center_y",
1112
 
    "The vert. coordinate of the center of rotation"
1113
 
  },
1114
 
  {
1115
 
    GIMP_PDB_INT32,
1116
 
    "transform_direction",
1117
 
    "Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
1118
 
  },
1119
 
  {
1120
 
    GIMP_PDB_INT32,
1121
 
    "interpolation",
1122
 
    "Type of interpolation: { GIMP_INTERPOLATION_NONE (0), GIMP_INTERPOLATION_LINEAR (1), GIMP_INTERPOLATION_CUBIC (2) }"
1123
 
  },
1124
 
  {
1125
 
    GIMP_PDB_INT32,
1126
 
    "supersample",
1127
 
    "Whether to perform supersample"
1128
 
  },
1129
 
  {
1130
 
    GIMP_PDB_INT32,
1131
 
    "recursion_level",
1132
 
    "Level of recursion (3 is a nice default)"
1133
 
  },
1134
 
  {
1135
 
    GIMP_PDB_INT32,
1136
 
    "clip_result",
1137
 
    "Whether to clip results"
1138
 
  }
1139
 
};
1140
 
 
1141
 
static ProcArg drawable_transform_rotate_outargs[] =
1142
 
{
1143
 
  {
1144
 
    GIMP_PDB_DRAWABLE,
1145
 
    "drawable",
1146
 
    "The rotated drawable"
1147
 
  }
1148
 
};
1149
 
 
1150
 
static ProcRecord drawable_transform_rotate_proc =
1151
 
{
1152
 
  "gimp_drawable_transform_rotate",
1153
 
  "Rotate the specified drawable about given coordinates through the specified angle.",
1154
 
  "This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
1155
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1156
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1157
 
  "2004",
1158
 
  NULL,
1159
 
  GIMP_INTERNAL,
1160
 
  10,
1161
 
  drawable_transform_rotate_inargs,
1162
 
  1,
1163
 
  drawable_transform_rotate_outargs,
1164
 
  { { drawable_transform_rotate_invoker } }
1165
 
};
1166
 
 
1167
 
static Argument *
1168
 
drawable_transform_rotate_default_invoker (Gimp         *gimp,
1169
 
                                           GimpContext  *context,
1170
 
                                           GimpProgress *progress,
1171
 
                                           Argument     *args)
1172
 
{
1173
 
  gboolean success = TRUE;
1174
 
  Argument *return_args;
1175
 
  GimpDrawable *drawable;
1176
 
  gdouble angle;
1177
 
  gboolean auto_center;
1178
 
  gint32 center_x;
1179
 
  gint32 center_y;
1180
 
  gboolean interpolate;
1181
 
  gboolean clip_result;
1182
 
 
1183
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1184
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
1185
 
    success = FALSE;
1186
 
 
1187
 
  angle = args[1].value.pdb_float;
1188
 
 
1189
 
  auto_center = args[2].value.pdb_int ? TRUE : FALSE;
1190
 
 
1191
 
  center_x = args[3].value.pdb_int;
1192
 
 
1193
 
  center_y = args[4].value.pdb_int;
1194
 
 
1195
 
  interpolate = args[5].value.pdb_int ? TRUE : FALSE;
1196
 
 
1197
 
  clip_result = args[6].value.pdb_int ? TRUE : FALSE;
1198
 
 
1199
 
  if (success)
1200
 
    {
1201
 
      gint x, y, width, height;
1202
 
 
1203
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
1204
 
 
1205
 
      if (success &&
1206
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
1207
 
        {
1208
 
          GimpMatrix3           matrix;
1209
 
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
1210
 
          gint                  off_x, off_y;
1211
 
 
1212
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
1213
 
 
1214
 
          x += off_x;
1215
 
          y += off_y;
1216
 
 
1217
 
          /* Assemble the transformation matrix */
1218
 
          if (auto_center)
1219
 
            gimp_transform_matrix_rotate (x, y, width, height, angle,
1220
 
                                          &matrix);
1221
 
          else
1222
 
            gimp_transform_matrix_rotate_center (center_x, center_y, angle,
1223
 
                                                 &matrix);
1224
 
 
1225
 
          if (interpolate)
1226
 
            interpolation_type = gimp->config->interpolation_type;
1227
 
 
1228
 
          if (progress)
1229
 
            gimp_progress_start (progress, _("Rotating..."), FALSE);
1230
 
 
1231
 
          /* Transform the selection */
1232
 
          success = gimp_drawable_transform_affine (drawable, context,
1233
 
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
1234
 
                                                    interpolation_type,
1235
 
                                                    interpolate, 3,
1236
 
                                                    clip_result, progress);
1237
 
 
1238
 
          if (progress)
1239
 
            gimp_progress_end (progress);
1240
 
        }
1241
 
    }
1242
 
 
1243
 
  return_args = procedural_db_return_args (&drawable_transform_rotate_default_proc, success);
1244
 
 
1245
 
  if (success)
1246
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
1247
 
 
1248
 
  return return_args;
1249
 
}
1250
 
 
1251
 
static ProcArg drawable_transform_rotate_default_inargs[] =
1252
 
{
1253
 
  {
1254
 
    GIMP_PDB_DRAWABLE,
1255
 
    "drawable",
1256
 
    "The affected drawable"
1257
 
  },
1258
 
  {
1259
 
    GIMP_PDB_FLOAT,
1260
 
    "angle",
1261
 
    "The angle of rotation (radians)"
1262
 
  },
1263
 
  {
1264
 
    GIMP_PDB_INT32,
1265
 
    "auto_center",
1266
 
    "Whether to automatically rotate around the selection center"
1267
 
  },
1268
 
  {
1269
 
    GIMP_PDB_INT32,
1270
 
    "center_x",
1271
 
    "The hor. coordinate of the center of rotation"
1272
 
  },
1273
 
  {
1274
 
    GIMP_PDB_INT32,
1275
 
    "center_y",
1276
 
    "The vert. coordinate of the center of rotation"
1277
 
  },
1278
 
  {
1279
 
    GIMP_PDB_INT32,
1280
 
    "interpolate",
1281
 
    "Whether to use interpolation and supersampling"
1282
 
  },
1283
 
  {
1284
 
    GIMP_PDB_INT32,
1285
 
    "clip_result",
1286
 
    "Whether to clip results"
1287
 
  }
1288
 
};
1289
 
 
1290
 
static ProcArg drawable_transform_rotate_default_outargs[] =
1291
 
{
1292
 
  {
1293
 
    GIMP_PDB_DRAWABLE,
1294
 
    "drawable",
1295
 
    "The rotated drawable"
1296
 
  }
1297
 
};
1298
 
 
1299
 
static ProcRecord drawable_transform_rotate_default_proc =
1300
 
{
1301
 
  "gimp_drawable_transform_rotate_default",
1302
 
  "Rotate the specified drawable about given coordinates through the specified angle.",
1303
 
  "This procedure is a variant of gimp_drawable_transform_rotate() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
1304
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1305
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1306
 
  "2004",
1307
 
  NULL,
1308
 
  GIMP_INTERNAL,
1309
 
  7,
1310
 
  drawable_transform_rotate_default_inargs,
1311
 
  1,
1312
 
  drawable_transform_rotate_default_outargs,
1313
 
  { { drawable_transform_rotate_default_invoker } }
1314
 
};
1315
 
 
1316
 
static Argument *
1317
 
drawable_transform_scale_invoker (Gimp         *gimp,
1318
 
                                  GimpContext  *context,
1319
 
                                  GimpProgress *progress,
1320
 
                                  Argument     *args)
1321
 
{
1322
 
  gboolean success = TRUE;
1323
 
  Argument *return_args;
1324
 
  GimpDrawable *drawable;
1325
 
  gint32 transform_direction;
1326
 
  gint32 interpolation;
1327
 
  gboolean supersample;
1328
 
  gint32 recursion_level;
1329
 
  gboolean clip_result;
1330
 
  gdouble trans_info[4];
1331
 
 
1332
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1333
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
1334
 
    success = FALSE;
1335
 
 
1336
 
  trans_info[X0] = args[1].value.pdb_float;
1337
 
 
1338
 
  trans_info[Y0] = args[2].value.pdb_float;
1339
 
 
1340
 
  trans_info[X1] = args[3].value.pdb_float;
1341
 
 
1342
 
  trans_info[Y1] = args[4].value.pdb_float;
1343
 
 
1344
 
  transform_direction = args[5].value.pdb_int;
1345
 
  if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
1346
 
    success = FALSE;
1347
 
 
1348
 
  interpolation = args[6].value.pdb_int;
1349
 
  if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
1350
 
    success = FALSE;
1351
 
 
1352
 
  supersample = args[7].value.pdb_int ? TRUE : FALSE;
1353
 
 
1354
 
  recursion_level = args[8].value.pdb_int;
1355
 
  if (recursion_level <= 0)
1356
 
    success = FALSE;
1357
 
 
1358
 
  clip_result = args[9].value.pdb_int ? TRUE : FALSE;
1359
 
 
1360
 
  if (success)
1361
 
    {
1362
 
      gint x, y, width, height;
1363
 
 
1364
 
      success = (gimp_item_is_attached (GIMP_ITEM (drawable)) &&
1365
 
                 trans_info[X0] < trans_info[X1] &&
1366
 
                 trans_info[Y0] < trans_info[Y1]);
1367
 
 
1368
 
      if (success &&
1369
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
1370
 
        {
1371
 
          GimpMatrix3 matrix;
1372
 
          gint        off_x, off_y;
1373
 
 
1374
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
1375
 
 
1376
 
          x += off_x;
1377
 
          y += off_y;
1378
 
 
1379
 
          /* Assemble the transformation matrix */
1380
 
          gimp_transform_matrix_scale (x, y, width, height,
1381
 
                                       trans_info[X0],
1382
 
                                       trans_info[Y0],
1383
 
                                       trans_info[X1] - trans_info[X0],
1384
 
                                       trans_info[Y1] - trans_info[Y0],
1385
 
                                       &matrix);
1386
 
 
1387
 
          if (progress)
1388
 
            gimp_progress_start (progress, _("Scaling..."), FALSE);
1389
 
 
1390
 
          /* Transform the selection */
1391
 
          success = gimp_drawable_transform_affine (drawable, context,
1392
 
                                                    &matrix, transform_direction,
1393
 
                                                    interpolation, supersample,
1394
 
                                                    recursion_level,
1395
 
                                                    clip_result, progress);
1396
 
 
1397
 
          if (progress)
1398
 
            gimp_progress_end (progress);
1399
 
        }
1400
 
    }
1401
 
 
1402
 
  return_args = procedural_db_return_args (&drawable_transform_scale_proc, success);
1403
 
 
1404
 
  if (success)
1405
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
1406
 
 
1407
 
  return return_args;
1408
 
}
1409
 
 
1410
 
static ProcArg drawable_transform_scale_inargs[] =
1411
 
{
1412
 
  {
1413
 
    GIMP_PDB_DRAWABLE,
1414
 
    "drawable",
1415
 
    "The affected drawable"
1416
 
  },
1417
 
  {
1418
 
    GIMP_PDB_FLOAT,
1419
 
    "x0",
1420
 
    "The new x coordinate of upper-left corner of newly scaled region"
1421
 
  },
1422
 
  {
1423
 
    GIMP_PDB_FLOAT,
1424
 
    "y0",
1425
 
    "The new y coordinate of upper-left corner of newly scaled region"
1426
 
  },
1427
 
  {
1428
 
    GIMP_PDB_FLOAT,
1429
 
    "x1",
1430
 
    "The new x coordinate of lower-right corner of newly scaled region"
1431
 
  },
1432
 
  {
1433
 
    GIMP_PDB_FLOAT,
1434
 
    "y1",
1435
 
    "The new y coordinate of lower-right corner of newly scaled region"
1436
 
  },
1437
 
  {
1438
 
    GIMP_PDB_INT32,
1439
 
    "transform_direction",
1440
 
    "Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
1441
 
  },
1442
 
  {
1443
 
    GIMP_PDB_INT32,
1444
 
    "interpolation",
1445
 
    "Type of interpolation: { GIMP_INTERPOLATION_NONE (0), GIMP_INTERPOLATION_LINEAR (1), GIMP_INTERPOLATION_CUBIC (2) }"
1446
 
  },
1447
 
  {
1448
 
    GIMP_PDB_INT32,
1449
 
    "supersample",
1450
 
    "Whether to perform supersample"
1451
 
  },
1452
 
  {
1453
 
    GIMP_PDB_INT32,
1454
 
    "recursion_level",
1455
 
    "Level of recursion (3 is a nice default)"
1456
 
  },
1457
 
  {
1458
 
    GIMP_PDB_INT32,
1459
 
    "clip_result",
1460
 
    "Whether to clip results"
1461
 
  }
1462
 
};
1463
 
 
1464
 
static ProcArg drawable_transform_scale_outargs[] =
1465
 
{
1466
 
  {
1467
 
    GIMP_PDB_DRAWABLE,
1468
 
    "drawable",
1469
 
    "The scaled drawable"
1470
 
  }
1471
 
};
1472
 
 
1473
 
static ProcRecord drawable_transform_scale_proc =
1474
 
{
1475
 
  "gimp_drawable_transform_scale",
1476
 
  "Scale the specified drawable with extra parameters",
1477
 
  "This procedure scales the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then scaled by the specified amount. The return value is the ID of the scaled drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and scaled drawable.",
1478
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1479
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1480
 
  "2004",
1481
 
  NULL,
1482
 
  GIMP_INTERNAL,
1483
 
  10,
1484
 
  drawable_transform_scale_inargs,
1485
 
  1,
1486
 
  drawable_transform_scale_outargs,
1487
 
  { { drawable_transform_scale_invoker } }
1488
 
};
1489
 
 
1490
 
static Argument *
1491
 
drawable_transform_scale_default_invoker (Gimp         *gimp,
1492
 
                                          GimpContext  *context,
1493
 
                                          GimpProgress *progress,
1494
 
                                          Argument     *args)
1495
 
{
1496
 
  gboolean success = TRUE;
1497
 
  Argument *return_args;
1498
 
  GimpDrawable *drawable;
1499
 
  gboolean interpolate;
1500
 
  gboolean clip_result;
1501
 
  gdouble trans_info[4];
1502
 
 
1503
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1504
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
1505
 
    success = FALSE;
1506
 
 
1507
 
  trans_info[X0] = args[1].value.pdb_float;
1508
 
 
1509
 
  trans_info[Y0] = args[2].value.pdb_float;
1510
 
 
1511
 
  trans_info[X1] = args[3].value.pdb_float;
1512
 
 
1513
 
  trans_info[Y1] = args[4].value.pdb_float;
1514
 
 
1515
 
  interpolate = args[5].value.pdb_int ? TRUE : FALSE;
1516
 
 
1517
 
  clip_result = args[6].value.pdb_int ? TRUE : FALSE;
1518
 
 
1519
 
  if (success)
1520
 
    {
1521
 
      gint x, y, width, height;
1522
 
 
1523
 
      success = (gimp_item_is_attached (GIMP_ITEM (drawable)) &&
1524
 
                 trans_info[X0] < trans_info[X1] &&
1525
 
                 trans_info[Y0] < trans_info[Y1]);
1526
 
 
1527
 
      if (success &&
1528
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
1529
 
        {
1530
 
          GimpMatrix3           matrix;
1531
 
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
1532
 
          gint                  off_x, off_y;
1533
 
 
1534
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
1535
 
 
1536
 
          x += off_x;
1537
 
          y += off_y;
1538
 
 
1539
 
          /* Assemble the transformation matrix */
1540
 
          gimp_transform_matrix_scale (x, y, width, height,
1541
 
                                       trans_info[X0],
1542
 
                                       trans_info[Y0],
1543
 
                                       trans_info[X1] - trans_info[X0],
1544
 
                                       trans_info[Y1] - trans_info[Y0],
1545
 
                                       &matrix);
1546
 
 
1547
 
          if (interpolate)
1548
 
            interpolation_type = gimp->config->interpolation_type;
1549
 
 
1550
 
          if (progress)
1551
 
            gimp_progress_start (progress, _("Scaling..."), FALSE);
1552
 
 
1553
 
          /* Transform the selection */
1554
 
          success = gimp_drawable_transform_affine (drawable, context,
1555
 
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
1556
 
                                                    interpolation_type,
1557
 
                                                    interpolate, 3,
1558
 
                                                    clip_result, progress);
1559
 
 
1560
 
          if (progress)
1561
 
            gimp_progress_end (progress);
1562
 
        }
1563
 
    }
1564
 
 
1565
 
  return_args = procedural_db_return_args (&drawable_transform_scale_default_proc, success);
1566
 
 
1567
 
  if (success)
1568
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
1569
 
 
1570
 
  return return_args;
1571
 
}
1572
 
 
1573
 
static ProcArg drawable_transform_scale_default_inargs[] =
1574
 
{
1575
 
  {
1576
 
    GIMP_PDB_DRAWABLE,
1577
 
    "drawable",
1578
 
    "The affected drawable"
1579
 
  },
1580
 
  {
1581
 
    GIMP_PDB_FLOAT,
1582
 
    "x0",
1583
 
    "The new x coordinate of upper-left corner of newly scaled region"
1584
 
  },
1585
 
  {
1586
 
    GIMP_PDB_FLOAT,
1587
 
    "y0",
1588
 
    "The new y coordinate of upper-left corner of newly scaled region"
1589
 
  },
1590
 
  {
1591
 
    GIMP_PDB_FLOAT,
1592
 
    "x1",
1593
 
    "The new x coordinate of lower-right corner of newly scaled region"
1594
 
  },
1595
 
  {
1596
 
    GIMP_PDB_FLOAT,
1597
 
    "y1",
1598
 
    "The new y coordinate of lower-right corner of newly scaled region"
1599
 
  },
1600
 
  {
1601
 
    GIMP_PDB_INT32,
1602
 
    "interpolate",
1603
 
    "Whether to use interpolation and supersampling"
1604
 
  },
1605
 
  {
1606
 
    GIMP_PDB_INT32,
1607
 
    "clip_result",
1608
 
    "Whether to clip results"
1609
 
  }
1610
 
};
1611
 
 
1612
 
static ProcArg drawable_transform_scale_default_outargs[] =
1613
 
{
1614
 
  {
1615
 
    GIMP_PDB_DRAWABLE,
1616
 
    "drawable",
1617
 
    "The scaled drawable"
1618
 
  }
1619
 
};
1620
 
 
1621
 
static ProcRecord drawable_transform_scale_default_proc =
1622
 
{
1623
 
  "gimp_drawable_transform_scale_default",
1624
 
  "Scale the specified drawable with extra parameters",
1625
 
  "This procedure is a variant of gimp_drawable_transform_scale() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
1626
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1627
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1628
 
  "2004",
1629
 
  NULL,
1630
 
  GIMP_INTERNAL,
1631
 
  7,
1632
 
  drawable_transform_scale_default_inargs,
1633
 
  1,
1634
 
  drawable_transform_scale_default_outargs,
1635
 
  { { drawable_transform_scale_default_invoker } }
1636
 
};
1637
 
 
1638
 
static Argument *
1639
 
drawable_transform_shear_invoker (Gimp         *gimp,
1640
 
                                  GimpContext  *context,
1641
 
                                  GimpProgress *progress,
1642
 
                                  Argument     *args)
1643
 
{
1644
 
  gboolean success = TRUE;
1645
 
  Argument *return_args;
1646
 
  GimpDrawable *drawable;
1647
 
  gint32 shear_type;
1648
 
  gdouble magnitude;
1649
 
  gint32 transform_direction;
1650
 
  gint32 interpolation;
1651
 
  gboolean supersample;
1652
 
  gint32 recursion_level;
1653
 
  gboolean clip_result;
1654
 
 
1655
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1656
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
1657
 
    success = FALSE;
1658
 
 
1659
 
  shear_type = args[1].value.pdb_int;
1660
 
  if (shear_type < GIMP_ORIENTATION_HORIZONTAL || shear_type > GIMP_ORIENTATION_VERTICAL)
1661
 
    success = FALSE;
1662
 
 
1663
 
  magnitude = args[2].value.pdb_float;
1664
 
 
1665
 
  transform_direction = args[3].value.pdb_int;
1666
 
  if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
1667
 
    success = FALSE;
1668
 
 
1669
 
  interpolation = args[4].value.pdb_int;
1670
 
  if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
1671
 
    success = FALSE;
1672
 
 
1673
 
  supersample = args[5].value.pdb_int ? TRUE : FALSE;
1674
 
 
1675
 
  recursion_level = args[6].value.pdb_int;
1676
 
  if (recursion_level <= 0)
1677
 
    success = FALSE;
1678
 
 
1679
 
  clip_result = args[7].value.pdb_int ? TRUE : FALSE;
1680
 
 
1681
 
  if (success)
1682
 
    {
1683
 
      gint x, y, width, height;
1684
 
 
1685
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
1686
 
 
1687
 
      if (success &&
1688
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
1689
 
        {
1690
 
          GimpMatrix3 matrix;
1691
 
          gint        off_x, off_y;
1692
 
 
1693
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
1694
 
 
1695
 
          x += off_x;
1696
 
          y += off_y;
1697
 
 
1698
 
          /* Assemble the transformation matrix */
1699
 
          gimp_transform_matrix_shear (x, y, width, height,
1700
 
                                       shear_type, magnitude,
1701
 
                                       &matrix);
1702
 
 
1703
 
          if (progress)
1704
 
            gimp_progress_start (progress, _("Shearing..."), FALSE);
1705
 
 
1706
 
          /* Transform the selection */
1707
 
          success = gimp_drawable_transform_affine (drawable, context,
1708
 
                                                    &matrix, transform_direction,
1709
 
                                                    interpolation, supersample,
1710
 
                                                    recursion_level,
1711
 
                                                    clip_result, progress);
1712
 
 
1713
 
          if (progress)
1714
 
            gimp_progress_end (progress);
1715
 
        }
1716
 
    }
1717
 
 
1718
 
  return_args = procedural_db_return_args (&drawable_transform_shear_proc, success);
1719
 
 
1720
 
  if (success)
1721
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
1722
 
 
1723
 
  return return_args;
1724
 
}
1725
 
 
1726
 
static ProcArg drawable_transform_shear_inargs[] =
1727
 
{
1728
 
  {
1729
 
    GIMP_PDB_DRAWABLE,
1730
 
    "drawable",
1731
 
    "The affected drawable"
1732
 
  },
1733
 
  {
1734
 
    GIMP_PDB_INT32,
1735
 
    "shear_type",
1736
 
    "Type of shear: GIMP_ORIENTATION_HORIZONTAL (0) or GIMP_ORIENTATION_VERTICAL (1)"
1737
 
  },
1738
 
  {
1739
 
    GIMP_PDB_FLOAT,
1740
 
    "magnitude",
1741
 
    "The magnitude of the shear"
1742
 
  },
1743
 
  {
1744
 
    GIMP_PDB_INT32,
1745
 
    "transform_direction",
1746
 
    "Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
1747
 
  },
1748
 
  {
1749
 
    GIMP_PDB_INT32,
1750
 
    "interpolation",
1751
 
    "Type of interpolation: { GIMP_INTERPOLATION_NONE (0), GIMP_INTERPOLATION_LINEAR (1), GIMP_INTERPOLATION_CUBIC (2) }"
1752
 
  },
1753
 
  {
1754
 
    GIMP_PDB_INT32,
1755
 
    "supersample",
1756
 
    "Whether to perform supersample"
1757
 
  },
1758
 
  {
1759
 
    GIMP_PDB_INT32,
1760
 
    "recursion_level",
1761
 
    "Level of recursion (3 is a nice default)"
1762
 
  },
1763
 
  {
1764
 
    GIMP_PDB_INT32,
1765
 
    "clip_result",
1766
 
    "Whether to clip results"
1767
 
  }
1768
 
};
1769
 
 
1770
 
static ProcArg drawable_transform_shear_outargs[] =
1771
 
{
1772
 
  {
1773
 
    GIMP_PDB_DRAWABLE,
1774
 
    "drawable",
1775
 
    "The sheared drawable"
1776
 
  }
1777
 
};
1778
 
 
1779
 
static ProcRecord drawable_transform_shear_proc =
1780
 
{
1781
 
  "gimp_drawable_transform_shear",
1782
 
  "Shear the specified drawable about its center by the specified magnitude, with extra parameters.",
1783
 
  "This procedure shears the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then sheard by the specified amount. The return value is the ID of the sheard drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and sheard drawable. The shear type parameter indicates whether the shear will be applied horizontally or vertically. The magnitude can be either positive or negative and indicates the extent (in pixels) to shear by.",
1784
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1785
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1786
 
  "2004",
1787
 
  NULL,
1788
 
  GIMP_INTERNAL,
1789
 
  8,
1790
 
  drawable_transform_shear_inargs,
1791
 
  1,
1792
 
  drawable_transform_shear_outargs,
1793
 
  { { drawable_transform_shear_invoker } }
1794
 
};
1795
 
 
1796
 
static Argument *
1797
 
drawable_transform_shear_default_invoker (Gimp         *gimp,
1798
 
                                          GimpContext  *context,
1799
 
                                          GimpProgress *progress,
1800
 
                                          Argument     *args)
1801
 
{
1802
 
  gboolean success = TRUE;
1803
 
  Argument *return_args;
1804
 
  GimpDrawable *drawable;
1805
 
  gint32 shear_type;
1806
 
  gdouble magnitude;
1807
 
  gboolean interpolate;
1808
 
  gboolean clip_result;
1809
 
 
1810
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1811
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
1812
 
    success = FALSE;
1813
 
 
1814
 
  shear_type = args[1].value.pdb_int;
1815
 
  if (shear_type < GIMP_ORIENTATION_HORIZONTAL || shear_type > GIMP_ORIENTATION_VERTICAL)
1816
 
    success = FALSE;
1817
 
 
1818
 
  magnitude = args[2].value.pdb_float;
1819
 
 
1820
 
  interpolate = args[3].value.pdb_int ? TRUE : FALSE;
1821
 
 
1822
 
  clip_result = args[4].value.pdb_int ? TRUE : FALSE;
1823
 
 
1824
 
  if (success)
1825
 
    {
1826
 
      gint x, y, width, height;
1827
 
 
1828
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
1829
 
 
1830
 
      if (success &&
1831
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
1832
 
        {
1833
 
          GimpMatrix3           matrix;
1834
 
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
1835
 
          gint                  off_x, off_y;
1836
 
 
1837
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
1838
 
 
1839
 
          x += off_x;
1840
 
          y += off_y;
1841
 
 
1842
 
          /* Assemble the transformation matrix */
1843
 
          gimp_transform_matrix_shear (x, y, width, height,
1844
 
                                       shear_type, magnitude,
1845
 
                                       &matrix);
1846
 
 
1847
 
          if (interpolate)
1848
 
            interpolation_type = gimp->config->interpolation_type;
1849
 
 
1850
 
          if (progress)
1851
 
            gimp_progress_start (progress, _("Shearing..."), FALSE);
1852
 
 
1853
 
          /* Transform the selection */
1854
 
          success = gimp_drawable_transform_affine (drawable, context,
1855
 
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
1856
 
                                                    interpolation_type,
1857
 
                                                    interpolate, 3,
1858
 
                                                    clip_result, progress);
1859
 
 
1860
 
          if (progress)
1861
 
            gimp_progress_end (progress);
1862
 
        }
1863
 
    }
1864
 
 
1865
 
  return_args = procedural_db_return_args (&drawable_transform_shear_default_proc, success);
1866
 
 
1867
 
  if (success)
1868
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
1869
 
 
1870
 
  return return_args;
1871
 
}
1872
 
 
1873
 
static ProcArg drawable_transform_shear_default_inargs[] =
1874
 
{
1875
 
  {
1876
 
    GIMP_PDB_DRAWABLE,
1877
 
    "drawable",
1878
 
    "The affected drawable"
1879
 
  },
1880
 
  {
1881
 
    GIMP_PDB_INT32,
1882
 
    "shear_type",
1883
 
    "Type of shear: GIMP_ORIENTATION_HORIZONTAL (0) or GIMP_ORIENTATION_VERTICAL (1)"
1884
 
  },
1885
 
  {
1886
 
    GIMP_PDB_FLOAT,
1887
 
    "magnitude",
1888
 
    "The magnitude of the shear"
1889
 
  },
1890
 
  {
1891
 
    GIMP_PDB_INT32,
1892
 
    "interpolate",
1893
 
    "Whether to use interpolation and supersampling"
1894
 
  },
1895
 
  {
1896
 
    GIMP_PDB_INT32,
1897
 
    "clip_result",
1898
 
    "Whether to clip results"
1899
 
  }
1900
 
};
1901
 
 
1902
 
static ProcArg drawable_transform_shear_default_outargs[] =
1903
 
{
1904
 
  {
1905
 
    GIMP_PDB_DRAWABLE,
1906
 
    "drawable",
1907
 
    "The sheared drawable"
1908
 
  }
1909
 
};
1910
 
 
1911
 
static ProcRecord drawable_transform_shear_default_proc =
1912
 
{
1913
 
  "gimp_drawable_transform_shear_default",
1914
 
  "Shear the specified drawable about its center by the specified magnitude, with extra parameters.",
1915
 
  "This procedure is a variant of gimp_drawable_transform_shear() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
1916
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1917
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
1918
 
  "2004",
1919
 
  NULL,
1920
 
  GIMP_INTERNAL,
1921
 
  5,
1922
 
  drawable_transform_shear_default_inargs,
1923
 
  1,
1924
 
  drawable_transform_shear_default_outargs,
1925
 
  { { drawable_transform_shear_default_invoker } }
1926
 
};
1927
 
 
1928
 
static Argument *
1929
 
drawable_transform_2d_invoker (Gimp         *gimp,
1930
 
                               GimpContext  *context,
1931
 
                               GimpProgress *progress,
1932
 
                               Argument     *args)
1933
 
{
1934
 
  gboolean success = TRUE;
1935
 
  Argument *return_args;
1936
 
  GimpDrawable *drawable;
1937
 
  gdouble source_x;
1938
 
  gdouble source_y;
1939
 
  gdouble scale_x;
1940
 
  gdouble scale_y;
1941
 
  gdouble angle;
1942
 
  gdouble dest_x;
1943
 
  gdouble dest_y;
1944
 
  gint32 transform_direction;
1945
 
  gint32 interpolation;
1946
 
  gboolean supersample;
1947
 
  gint32 recursion_level;
1948
 
  gboolean clip_result;
1949
 
 
1950
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1951
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
1952
 
    success = FALSE;
1953
 
 
1954
 
  source_x = args[1].value.pdb_float;
1955
 
 
1956
 
  source_y = args[2].value.pdb_float;
1957
 
 
1958
 
  scale_x = args[3].value.pdb_float;
1959
 
 
1960
 
  scale_y = args[4].value.pdb_float;
1961
 
 
1962
 
  angle = args[5].value.pdb_float;
1963
 
 
1964
 
  dest_x = args[6].value.pdb_float;
1965
 
 
1966
 
  dest_y = args[7].value.pdb_float;
1967
 
 
1968
 
  transform_direction = args[8].value.pdb_int;
1969
 
  if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
1970
 
    success = FALSE;
1971
 
 
1972
 
  interpolation = args[9].value.pdb_int;
1973
 
  if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
1974
 
    success = FALSE;
1975
 
 
1976
 
  supersample = args[10].value.pdb_int ? TRUE : FALSE;
1977
 
 
1978
 
  recursion_level = args[11].value.pdb_int;
1979
 
  if (recursion_level <= 0)
1980
 
    success = FALSE;
1981
 
 
1982
 
  clip_result = args[12].value.pdb_int ? TRUE : FALSE;
1983
 
 
1984
 
  if (success)
1985
 
    {
1986
 
      gint x, y, width, height;
1987
 
 
1988
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
1989
 
 
1990
 
      if (success &&
1991
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
1992
 
        {
1993
 
          GimpMatrix3 matrix;
1994
 
          gint        off_x, off_y;
1995
 
 
1996
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
1997
 
 
1998
 
          x += off_x;
1999
 
          y += off_y;
2000
 
 
2001
 
          /* Assemble the transformation matrix */
2002
 
          gimp_matrix3_identity  (&matrix);
2003
 
          gimp_matrix3_translate (&matrix, -source_x, -source_y);
2004
 
          gimp_matrix3_scale     (&matrix, scale_x, scale_y);
2005
 
          gimp_matrix3_rotate    (&matrix, angle);
2006
 
          gimp_matrix3_translate (&matrix, dest_x, dest_y);
2007
 
 
2008
 
          if (progress)
2009
 
            gimp_progress_start (progress, _("2D Transform..."), FALSE);
2010
 
 
2011
 
          /* Transform the selection */
2012
 
          success = gimp_drawable_transform_affine (drawable, context,
2013
 
                                                    &matrix, transform_direction,
2014
 
                                                    interpolation, supersample,
2015
 
                                                    recursion_level,
2016
 
                                                    clip_result, progress);
2017
 
 
2018
 
          if (progress)
2019
 
            gimp_progress_end (progress);
2020
 
        }
2021
 
    }
2022
 
 
2023
 
  return_args = procedural_db_return_args (&drawable_transform_2d_proc, success);
2024
 
 
2025
 
  if (success)
2026
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
2027
 
 
2028
 
  return return_args;
2029
 
}
2030
 
 
2031
 
static ProcArg drawable_transform_2d_inargs[] =
2032
 
{
2033
 
  {
2034
 
    GIMP_PDB_DRAWABLE,
2035
 
    "drawable",
2036
 
    "The affected drawable"
2037
 
  },
2038
 
  {
2039
 
    GIMP_PDB_FLOAT,
2040
 
    "source_x",
2041
 
    "X coordinate of the transformation center"
2042
 
  },
2043
 
  {
2044
 
    GIMP_PDB_FLOAT,
2045
 
    "source_y",
2046
 
    "Y coordinate of the transformation center"
2047
 
  },
2048
 
  {
2049
 
    GIMP_PDB_FLOAT,
2050
 
    "scale_x",
2051
 
    "Amount to scale in x direction"
2052
 
  },
2053
 
  {
2054
 
    GIMP_PDB_FLOAT,
2055
 
    "scale_y",
2056
 
    "Amount to scale in y direction"
2057
 
  },
2058
 
  {
2059
 
    GIMP_PDB_FLOAT,
2060
 
    "angle",
2061
 
    "The angle of rotation (radians)"
2062
 
  },
2063
 
  {
2064
 
    GIMP_PDB_FLOAT,
2065
 
    "dest_x",
2066
 
    "X coordinate of where the center goes"
2067
 
  },
2068
 
  {
2069
 
    GIMP_PDB_FLOAT,
2070
 
    "dest_y",
2071
 
    "Y coordinate of where the center goes"
2072
 
  },
2073
 
  {
2074
 
    GIMP_PDB_INT32,
2075
 
    "transform_direction",
2076
 
    "Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
2077
 
  },
2078
 
  {
2079
 
    GIMP_PDB_INT32,
2080
 
    "interpolation",
2081
 
    "Type of interpolation: { GIMP_INTERPOLATION_NONE (0), GIMP_INTERPOLATION_LINEAR (1), GIMP_INTERPOLATION_CUBIC (2) }"
2082
 
  },
2083
 
  {
2084
 
    GIMP_PDB_INT32,
2085
 
    "supersample",
2086
 
    "Whether to perform supersample"
2087
 
  },
2088
 
  {
2089
 
    GIMP_PDB_INT32,
2090
 
    "recursion_level",
2091
 
    "Level of recursion (3 is a nice default)"
2092
 
  },
2093
 
  {
2094
 
    GIMP_PDB_INT32,
2095
 
    "clip_result",
2096
 
    "Whether to clip results"
2097
 
  }
2098
 
};
2099
 
 
2100
 
static ProcArg drawable_transform_2d_outargs[] =
2101
 
{
2102
 
  {
2103
 
    GIMP_PDB_DRAWABLE,
2104
 
    "drawable",
2105
 
    "The transformed drawable"
2106
 
  }
2107
 
};
2108
 
 
2109
 
static ProcRecord drawable_transform_2d_proc =
2110
 
{
2111
 
  "gimp_drawable_transform_2d",
2112
 
  "Transform the specified drawable in 2d, with extra parameters.",
2113
 
  "This procedure transforms the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by scaling the image by the x and y scale factors about the point (source_x, source_y), then rotating around the same point, then translating that point to the new position (dest_x, dest_y). The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and transformed drawable.",
2114
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2115
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2116
 
  "2004",
2117
 
  NULL,
2118
 
  GIMP_INTERNAL,
2119
 
  13,
2120
 
  drawable_transform_2d_inargs,
2121
 
  1,
2122
 
  drawable_transform_2d_outargs,
2123
 
  { { drawable_transform_2d_invoker } }
2124
 
};
2125
 
 
2126
 
static Argument *
2127
 
drawable_transform_2d_default_invoker (Gimp         *gimp,
2128
 
                                       GimpContext  *context,
2129
 
                                       GimpProgress *progress,
2130
 
                                       Argument     *args)
2131
 
{
2132
 
  gboolean success = TRUE;
2133
 
  Argument *return_args;
2134
 
  GimpDrawable *drawable;
2135
 
  gdouble source_x;
2136
 
  gdouble source_y;
2137
 
  gdouble scale_x;
2138
 
  gdouble scale_y;
2139
 
  gdouble angle;
2140
 
  gdouble dest_x;
2141
 
  gdouble dest_y;
2142
 
  gboolean interpolate;
2143
 
  gboolean clip_result;
2144
 
 
2145
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
2146
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
2147
 
    success = FALSE;
2148
 
 
2149
 
  source_x = args[1].value.pdb_float;
2150
 
 
2151
 
  source_y = args[2].value.pdb_float;
2152
 
 
2153
 
  scale_x = args[3].value.pdb_float;
2154
 
 
2155
 
  scale_y = args[4].value.pdb_float;
2156
 
 
2157
 
  angle = args[5].value.pdb_float;
2158
 
 
2159
 
  dest_x = args[6].value.pdb_float;
2160
 
 
2161
 
  dest_y = args[7].value.pdb_float;
2162
 
 
2163
 
  interpolate = args[8].value.pdb_int ? TRUE : FALSE;
2164
 
 
2165
 
  clip_result = args[9].value.pdb_int ? TRUE : FALSE;
2166
 
 
2167
 
  if (success)
2168
 
    {
2169
 
      gint x, y, width, height;
2170
 
 
2171
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
2172
 
 
2173
 
      if (success &&
2174
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
2175
 
        {
2176
 
          GimpMatrix3           matrix;
2177
 
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
2178
 
          gint                  off_x, off_y;
2179
 
 
2180
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
2181
 
 
2182
 
          x += off_x;
2183
 
          y += off_y;
2184
 
 
2185
 
          /* Assemble the transformation matrix */
2186
 
          gimp_matrix3_identity  (&matrix);
2187
 
          gimp_matrix3_translate (&matrix, -source_x, -source_y);
2188
 
          gimp_matrix3_scale     (&matrix, scale_x, scale_y);
2189
 
          gimp_matrix3_rotate    (&matrix, angle);
2190
 
          gimp_matrix3_translate (&matrix, dest_x, dest_y);
2191
 
 
2192
 
          if (interpolate)
2193
 
            interpolation_type = gimp->config->interpolation_type;
2194
 
 
2195
 
          if (progress)
2196
 
            gimp_progress_start (progress, _("2D Transform..."), FALSE);
2197
 
 
2198
 
          /* Transform the selection */
2199
 
          success = gimp_drawable_transform_affine (drawable, context,
2200
 
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
2201
 
                                                    interpolation_type,
2202
 
                                                    interpolate, 3,
2203
 
                                                    clip_result, progress);
2204
 
 
2205
 
          if (progress)
2206
 
            gimp_progress_end (progress);
2207
 
        }
2208
 
    }
2209
 
 
2210
 
  return_args = procedural_db_return_args (&drawable_transform_2d_default_proc, success);
2211
 
 
2212
 
  if (success)
2213
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
2214
 
 
2215
 
  return return_args;
2216
 
}
2217
 
 
2218
 
static ProcArg drawable_transform_2d_default_inargs[] =
2219
 
{
2220
 
  {
2221
 
    GIMP_PDB_DRAWABLE,
2222
 
    "drawable",
2223
 
    "The affected drawable"
2224
 
  },
2225
 
  {
2226
 
    GIMP_PDB_FLOAT,
2227
 
    "source_x",
2228
 
    "X coordinate of the transformation center"
2229
 
  },
2230
 
  {
2231
 
    GIMP_PDB_FLOAT,
2232
 
    "source_y",
2233
 
    "Y coordinate of the transformation center"
2234
 
  },
2235
 
  {
2236
 
    GIMP_PDB_FLOAT,
2237
 
    "scale_x",
2238
 
    "Amount to scale in x direction"
2239
 
  },
2240
 
  {
2241
 
    GIMP_PDB_FLOAT,
2242
 
    "scale_y",
2243
 
    "Amount to scale in y direction"
2244
 
  },
2245
 
  {
2246
 
    GIMP_PDB_FLOAT,
2247
 
    "angle",
2248
 
    "The angle of rotation (radians)"
2249
 
  },
2250
 
  {
2251
 
    GIMP_PDB_FLOAT,
2252
 
    "dest_x",
2253
 
    "X coordinate of where the center goes"
2254
 
  },
2255
 
  {
2256
 
    GIMP_PDB_FLOAT,
2257
 
    "dest_y",
2258
 
    "Y coordinate of where the center goes"
2259
 
  },
2260
 
  {
2261
 
    GIMP_PDB_INT32,
2262
 
    "interpolate",
2263
 
    "Whether to use interpolation and supersampling"
2264
 
  },
2265
 
  {
2266
 
    GIMP_PDB_INT32,
2267
 
    "clip_result",
2268
 
    "Whether to clip results"
2269
 
  }
2270
 
};
2271
 
 
2272
 
static ProcArg drawable_transform_2d_default_outargs[] =
2273
 
{
2274
 
  {
2275
 
    GIMP_PDB_DRAWABLE,
2276
 
    "drawable",
2277
 
    "The transformed drawable"
2278
 
  }
2279
 
};
2280
 
 
2281
 
static ProcRecord drawable_transform_2d_default_proc =
2282
 
{
2283
 
  "gimp_drawable_transform_2d_default",
2284
 
  "Transform the specified drawable in 2d, with extra parameters.",
2285
 
  "This procedure is a variant of gimp_drawable_transform_2d() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
2286
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2287
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2288
 
  "2004",
2289
 
  NULL,
2290
 
  GIMP_INTERNAL,
2291
 
  10,
2292
 
  drawable_transform_2d_default_inargs,
2293
 
  1,
2294
 
  drawable_transform_2d_default_outargs,
2295
 
  { { drawable_transform_2d_default_invoker } }
2296
 
};
2297
 
 
2298
 
static Argument *
2299
 
drawable_transform_matrix_invoker (Gimp         *gimp,
2300
 
                                   GimpContext  *context,
2301
 
                                   GimpProgress *progress,
2302
 
                                   Argument     *args)
2303
 
{
2304
 
  gboolean success = TRUE;
2305
 
  Argument *return_args;
2306
 
  GimpDrawable *drawable;
2307
 
  gdouble coeff_0_0;
2308
 
  gdouble coeff_0_1;
2309
 
  gdouble coeff_0_2;
2310
 
  gdouble coeff_1_0;
2311
 
  gdouble coeff_1_1;
2312
 
  gdouble coeff_1_2;
2313
 
  gdouble coeff_2_0;
2314
 
  gdouble coeff_2_1;
2315
 
  gdouble coeff_2_2;
2316
 
  gint32 transform_direction;
2317
 
  gint32 interpolation;
2318
 
  gboolean supersample;
2319
 
  gint32 recursion_level;
2320
 
  gboolean clip_result;
2321
 
 
2322
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
2323
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
2324
 
    success = FALSE;
2325
 
 
2326
 
  coeff_0_0 = args[1].value.pdb_float;
2327
 
 
2328
 
  coeff_0_1 = args[2].value.pdb_float;
2329
 
 
2330
 
  coeff_0_2 = args[3].value.pdb_float;
2331
 
 
2332
 
  coeff_1_0 = args[4].value.pdb_float;
2333
 
 
2334
 
  coeff_1_1 = args[5].value.pdb_float;
2335
 
 
2336
 
  coeff_1_2 = args[6].value.pdb_float;
2337
 
 
2338
 
  coeff_2_0 = args[7].value.pdb_float;
2339
 
 
2340
 
  coeff_2_1 = args[8].value.pdb_float;
2341
 
 
2342
 
  coeff_2_2 = args[9].value.pdb_float;
2343
 
 
2344
 
  transform_direction = args[10].value.pdb_int;
2345
 
  if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
2346
 
    success = FALSE;
2347
 
 
2348
 
  interpolation = args[11].value.pdb_int;
2349
 
  if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
2350
 
    success = FALSE;
2351
 
 
2352
 
  supersample = args[12].value.pdb_int ? TRUE : FALSE;
2353
 
 
2354
 
  recursion_level = args[13].value.pdb_int;
2355
 
  if (recursion_level <= 0)
2356
 
    success = FALSE;
2357
 
 
2358
 
  clip_result = args[14].value.pdb_int ? TRUE : FALSE;
2359
 
 
2360
 
  if (success)
2361
 
    {
2362
 
      gint x, y, width, height;
2363
 
 
2364
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
2365
 
 
2366
 
      if (success &&
2367
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
2368
 
        {
2369
 
          GimpMatrix3 matrix;
2370
 
          gint        off_x, off_y;
2371
 
 
2372
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
2373
 
 
2374
 
          x += off_x;
2375
 
          y += off_y;
2376
 
 
2377
 
          /* Assemble the transformation matrix */
2378
 
          matrix.coeff[0][0] = coeff_0_0;
2379
 
          matrix.coeff[0][1] = coeff_0_1;
2380
 
          matrix.coeff[0][2] = coeff_0_2;
2381
 
          matrix.coeff[1][0] = coeff_1_0;
2382
 
          matrix.coeff[1][1] = coeff_1_1;
2383
 
          matrix.coeff[1][2] = coeff_1_2;
2384
 
          matrix.coeff[2][0] = coeff_2_0;
2385
 
          matrix.coeff[2][1] = coeff_2_1;
2386
 
          matrix.coeff[2][2] = coeff_2_2;
2387
 
 
2388
 
          if (progress)
2389
 
            gimp_progress_start (progress, _("2D Transform..."), FALSE);
2390
 
 
2391
 
          /* Transform the selection */
2392
 
          success = gimp_drawable_transform_affine (drawable, context,
2393
 
                                                    &matrix, transform_direction,
2394
 
                                                    interpolation, supersample,
2395
 
                                                    recursion_level,
2396
 
                                                    clip_result, progress);
2397
 
 
2398
 
          if (progress)
2399
 
            gimp_progress_end (progress);
2400
 
        }
2401
 
    }
2402
 
 
2403
 
  return_args = procedural_db_return_args (&drawable_transform_matrix_proc, success);
2404
 
 
2405
 
  if (success)
2406
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
2407
 
 
2408
 
  return return_args;
2409
 
}
2410
 
 
2411
 
static ProcArg drawable_transform_matrix_inargs[] =
2412
 
{
2413
 
  {
2414
 
    GIMP_PDB_DRAWABLE,
2415
 
    "drawable",
2416
 
    "The affected drawable"
2417
 
  },
2418
 
  {
2419
 
    GIMP_PDB_FLOAT,
2420
 
    "coeff_0_0",
2421
 
    "coefficient (0,0) of the transformation matrix"
2422
 
  },
2423
 
  {
2424
 
    GIMP_PDB_FLOAT,
2425
 
    "coeff_0_1",
2426
 
    "coefficient (0,1) of the transformation matrix"
2427
 
  },
2428
 
  {
2429
 
    GIMP_PDB_FLOAT,
2430
 
    "coeff_0_2",
2431
 
    "coefficient (0,2) of the transformation matrix"
2432
 
  },
2433
 
  {
2434
 
    GIMP_PDB_FLOAT,
2435
 
    "coeff_1_0",
2436
 
    "coefficient (1,0) of the transformation matrix"
2437
 
  },
2438
 
  {
2439
 
    GIMP_PDB_FLOAT,
2440
 
    "coeff_1_1",
2441
 
    "coefficient (1,1) of the transformation matrix"
2442
 
  },
2443
 
  {
2444
 
    GIMP_PDB_FLOAT,
2445
 
    "coeff_1_2",
2446
 
    "coefficient (1,2) of the transformation matrix"
2447
 
  },
2448
 
  {
2449
 
    GIMP_PDB_FLOAT,
2450
 
    "coeff_2_0",
2451
 
    "coefficient (2,0) of the transformation matrix"
2452
 
  },
2453
 
  {
2454
 
    GIMP_PDB_FLOAT,
2455
 
    "coeff_2_1",
2456
 
    "coefficient (2,1) of the transformation matrix"
2457
 
  },
2458
 
  {
2459
 
    GIMP_PDB_FLOAT,
2460
 
    "coeff_2_2",
2461
 
    "coefficient (2,2) of the transformation matrix"
2462
 
  },
2463
 
  {
2464
 
    GIMP_PDB_INT32,
2465
 
    "transform_direction",
2466
 
    "Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
2467
 
  },
2468
 
  {
2469
 
    GIMP_PDB_INT32,
2470
 
    "interpolation",
2471
 
    "Type of interpolation: { GIMP_INTERPOLATION_NONE (0), GIMP_INTERPOLATION_LINEAR (1), GIMP_INTERPOLATION_CUBIC (2) }"
2472
 
  },
2473
 
  {
2474
 
    GIMP_PDB_INT32,
2475
 
    "supersample",
2476
 
    "Whether to perform supersample"
2477
 
  },
2478
 
  {
2479
 
    GIMP_PDB_INT32,
2480
 
    "recursion_level",
2481
 
    "Level of recursion (3 is a nice default)"
2482
 
  },
2483
 
  {
2484
 
    GIMP_PDB_INT32,
2485
 
    "clip_result",
2486
 
    "Whether to clip results"
2487
 
  }
2488
 
};
2489
 
 
2490
 
static ProcArg drawable_transform_matrix_outargs[] =
2491
 
{
2492
 
  {
2493
 
    GIMP_PDB_DRAWABLE,
2494
 
    "drawable",
2495
 
    "The transformed drawable"
2496
 
  }
2497
 
};
2498
 
 
2499
 
static ProcRecord drawable_transform_matrix_proc =
2500
 
{
2501
 
  "gimp_drawable_transform_matrix",
2502
 
  "Transform the specified drawable in 2d, with extra parameters.",
2503
 
  "This procedure transforms the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by assembling a 3x3 matrix from the coefficients passed. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and transformed drawable.",
2504
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2505
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2506
 
  "2004",
2507
 
  NULL,
2508
 
  GIMP_INTERNAL,
2509
 
  15,
2510
 
  drawable_transform_matrix_inargs,
2511
 
  1,
2512
 
  drawable_transform_matrix_outargs,
2513
 
  { { drawable_transform_matrix_invoker } }
2514
 
};
2515
 
 
2516
 
static Argument *
2517
 
drawable_transform_matrix_default_invoker (Gimp         *gimp,
2518
 
                                           GimpContext  *context,
2519
 
                                           GimpProgress *progress,
2520
 
                                           Argument     *args)
2521
 
{
2522
 
  gboolean success = TRUE;
2523
 
  Argument *return_args;
2524
 
  GimpDrawable *drawable;
2525
 
  gdouble coeff_0_0;
2526
 
  gdouble coeff_0_1;
2527
 
  gdouble coeff_0_2;
2528
 
  gdouble coeff_1_0;
2529
 
  gdouble coeff_1_1;
2530
 
  gdouble coeff_1_2;
2531
 
  gdouble coeff_2_0;
2532
 
  gdouble coeff_2_1;
2533
 
  gdouble coeff_2_2;
2534
 
  gboolean interpolate;
2535
 
  gboolean clip_result;
2536
 
 
2537
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
2538
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
2539
 
    success = FALSE;
2540
 
 
2541
 
  coeff_0_0 = args[1].value.pdb_float;
2542
 
 
2543
 
  coeff_0_1 = args[2].value.pdb_float;
2544
 
 
2545
 
  coeff_0_2 = args[3].value.pdb_float;
2546
 
 
2547
 
  coeff_1_0 = args[4].value.pdb_float;
2548
 
 
2549
 
  coeff_1_1 = args[5].value.pdb_float;
2550
 
 
2551
 
  coeff_1_2 = args[6].value.pdb_float;
2552
 
 
2553
 
  coeff_2_0 = args[7].value.pdb_float;
2554
 
 
2555
 
  coeff_2_1 = args[8].value.pdb_float;
2556
 
 
2557
 
  coeff_2_2 = args[9].value.pdb_float;
2558
 
 
2559
 
  interpolate = args[10].value.pdb_int ? TRUE : FALSE;
2560
 
 
2561
 
  clip_result = args[11].value.pdb_int ? TRUE : FALSE;
2562
 
 
2563
 
  if (success)
2564
 
    {
2565
 
      gint x, y, width, height;
2566
 
 
2567
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
2568
 
 
2569
 
      if (success &&
2570
 
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
2571
 
        {
2572
 
          GimpMatrix3           matrix;
2573
 
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
2574
 
          gint                  off_x, off_y;
2575
 
 
2576
 
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
2577
 
 
2578
 
          x += off_x;
2579
 
          y += off_y;
2580
 
 
2581
 
          /* Assemble the transformation matrix */
2582
 
          matrix.coeff[0][0] = coeff_0_0;
2583
 
          matrix.coeff[0][1] = coeff_0_1;
2584
 
          matrix.coeff[0][2] = coeff_0_2;
2585
 
          matrix.coeff[1][0] = coeff_1_0;
2586
 
          matrix.coeff[1][1] = coeff_1_1;
2587
 
          matrix.coeff[1][2] = coeff_1_2;
2588
 
          matrix.coeff[2][0] = coeff_2_0;
2589
 
          matrix.coeff[2][1] = coeff_2_1;
2590
 
          matrix.coeff[2][2] = coeff_2_2;
2591
 
 
2592
 
          if (interpolate)
2593
 
            interpolation_type = gimp->config->interpolation_type;
2594
 
 
2595
 
          if (progress)
2596
 
            gimp_progress_start (progress, _("2D Transform..."), FALSE);
2597
 
 
2598
 
          /* Transform the selection */
2599
 
          success = gimp_drawable_transform_affine (drawable, context,
2600
 
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
2601
 
                                                    interpolation_type,
2602
 
                                                    interpolate, 3,
2603
 
                                                    clip_result, progress);
2604
 
 
2605
 
          if (progress)
2606
 
            gimp_progress_end (progress);
2607
 
        }
2608
 
    }
2609
 
 
2610
 
  return_args = procedural_db_return_args (&drawable_transform_matrix_default_proc, success);
2611
 
 
2612
 
  if (success)
2613
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
2614
 
 
2615
 
  return return_args;
2616
 
}
2617
 
 
2618
 
static ProcArg drawable_transform_matrix_default_inargs[] =
2619
 
{
2620
 
  {
2621
 
    GIMP_PDB_DRAWABLE,
2622
 
    "drawable",
2623
 
    "The affected drawable"
2624
 
  },
2625
 
  {
2626
 
    GIMP_PDB_FLOAT,
2627
 
    "coeff_0_0",
2628
 
    "coefficient (0,0) of the transformation matrix"
2629
 
  },
2630
 
  {
2631
 
    GIMP_PDB_FLOAT,
2632
 
    "coeff_0_1",
2633
 
    "coefficient (0,1) of the transformation matrix"
2634
 
  },
2635
 
  {
2636
 
    GIMP_PDB_FLOAT,
2637
 
    "coeff_0_2",
2638
 
    "coefficient (0,2) of the transformation matrix"
2639
 
  },
2640
 
  {
2641
 
    GIMP_PDB_FLOAT,
2642
 
    "coeff_1_0",
2643
 
    "coefficient (1,0) of the transformation matrix"
2644
 
  },
2645
 
  {
2646
 
    GIMP_PDB_FLOAT,
2647
 
    "coeff_1_1",
2648
 
    "coefficient (1,1) of the transformation matrix"
2649
 
  },
2650
 
  {
2651
 
    GIMP_PDB_FLOAT,
2652
 
    "coeff_1_2",
2653
 
    "coefficient (1,2) of the transformation matrix"
2654
 
  },
2655
 
  {
2656
 
    GIMP_PDB_FLOAT,
2657
 
    "coeff_2_0",
2658
 
    "coefficient (2,0) of the transformation matrix"
2659
 
  },
2660
 
  {
2661
 
    GIMP_PDB_FLOAT,
2662
 
    "coeff_2_1",
2663
 
    "coefficient (2,1) of the transformation matrix"
2664
 
  },
2665
 
  {
2666
 
    GIMP_PDB_FLOAT,
2667
 
    "coeff_2_2",
2668
 
    "coefficient (2,2) of the transformation matrix"
2669
 
  },
2670
 
  {
2671
 
    GIMP_PDB_INT32,
2672
 
    "interpolate",
2673
 
    "Whether to use interpolation and supersampling"
2674
 
  },
2675
 
  {
2676
 
    GIMP_PDB_INT32,
2677
 
    "clip_result",
2678
 
    "Whether to clip results"
2679
 
  }
2680
 
};
2681
 
 
2682
 
static ProcArg drawable_transform_matrix_default_outargs[] =
2683
 
{
2684
 
  {
2685
 
    GIMP_PDB_DRAWABLE,
2686
 
    "drawable",
2687
 
    "The transformed drawable"
2688
 
  }
2689
 
};
2690
 
 
2691
 
static ProcRecord drawable_transform_matrix_default_proc =
2692
 
{
2693
 
  "gimp_drawable_transform_matrix_default",
2694
 
  "Transform the specified drawable in 2d, with extra parameters.",
2695
 
  "This procedure is a variant of gimp_drawable_transform_matrix() which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
2696
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2697
 
  "Jo\xc3\xa3o S. O. Bueno Calligaris",
2698
 
  "2004",
2699
 
  NULL,
2700
 
  GIMP_INTERNAL,
2701
 
  12,
2702
 
  drawable_transform_matrix_default_inargs,
2703
 
  1,
2704
 
  drawable_transform_matrix_default_outargs,
2705
 
  { { drawable_transform_matrix_default_invoker } }
2706
 
};
 
449
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
450
 
 
451
  if (success)
 
452
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
453
 
 
454
  return return_vals;
 
455
}
 
456
 
 
457
static GValueArray *
 
458
drawable_transform_rotate_invoker (GimpProcedure     *procedure,
 
459
                                   Gimp              *gimp,
 
460
                                   GimpContext       *context,
 
461
                                   GimpProgress      *progress,
 
462
                                   const GValueArray *args)
 
463
{
 
464
  gboolean success = TRUE;
 
465
  GValueArray *return_vals;
 
466
  GimpDrawable *drawable;
 
467
  gdouble angle;
 
468
  gboolean auto_center;
 
469
  gint32 center_x;
 
470
  gint32 center_y;
 
471
  gint32 transform_direction;
 
472
  gint32 interpolation;
 
473
  gboolean supersample;
 
474
  gint32 recursion_level;
 
475
  gint32 clip_result;
 
476
 
 
477
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
478
  angle = g_value_get_double (&args->values[1]);
 
479
  auto_center = g_value_get_boolean (&args->values[2]);
 
480
  center_x = g_value_get_int (&args->values[3]);
 
481
  center_y = g_value_get_int (&args->values[4]);
 
482
  transform_direction = g_value_get_enum (&args->values[5]);
 
483
  interpolation = g_value_get_enum (&args->values[6]);
 
484
  supersample = g_value_get_boolean (&args->values[7]);
 
485
  recursion_level = g_value_get_int (&args->values[8]);
 
486
  clip_result = g_value_get_enum (&args->values[9]);
 
487
 
 
488
  if (success)
 
489
    {
 
490
      gint x, y, width, height;
 
491
 
 
492
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
493
 
 
494
      if (success &&
 
495
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
496
        {
 
497
          GimpMatrix3 matrix;
 
498
          gint        off_x, off_y;
 
499
 
 
500
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
501
 
 
502
          x += off_x;
 
503
          y += off_y;
 
504
 
 
505
          /* Assemble the transformation matrix */
 
506
          gimp_matrix3_identity (&matrix);
 
507
          if (auto_center)
 
508
            gimp_transform_matrix_rotate_rect (&matrix,
 
509
                                               x, y, width, height, angle);
 
510
          else
 
511
            gimp_transform_matrix_rotate_center (&matrix,
 
512
                                                 center_x, center_y, angle);
 
513
 
 
514
          if (progress)
 
515
            gimp_progress_start (progress, _("Rotating"), FALSE);
 
516
 
 
517
          /* Transform the selection */
 
518
          success = gimp_drawable_transform_affine (drawable, context,
 
519
                                                    &matrix, transform_direction,
 
520
                                                    interpolation, supersample,
 
521
                                                    recursion_level,
 
522
                                                    clip_result, progress);
 
523
 
 
524
          if (progress)
 
525
            gimp_progress_end (progress);
 
526
        }
 
527
    }
 
528
 
 
529
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
530
 
 
531
  if (success)
 
532
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
533
 
 
534
  return return_vals;
 
535
}
 
536
 
 
537
static GValueArray *
 
538
drawable_transform_rotate_default_invoker (GimpProcedure     *procedure,
 
539
                                           Gimp              *gimp,
 
540
                                           GimpContext       *context,
 
541
                                           GimpProgress      *progress,
 
542
                                           const GValueArray *args)
 
543
{
 
544
  gboolean success = TRUE;
 
545
  GValueArray *return_vals;
 
546
  GimpDrawable *drawable;
 
547
  gdouble angle;
 
548
  gboolean auto_center;
 
549
  gint32 center_x;
 
550
  gint32 center_y;
 
551
  gboolean interpolate;
 
552
  gint32 clip_result;
 
553
 
 
554
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
555
  angle = g_value_get_double (&args->values[1]);
 
556
  auto_center = g_value_get_boolean (&args->values[2]);
 
557
  center_x = g_value_get_int (&args->values[3]);
 
558
  center_y = g_value_get_int (&args->values[4]);
 
559
  interpolate = g_value_get_boolean (&args->values[5]);
 
560
  clip_result = g_value_get_enum (&args->values[6]);
 
561
 
 
562
  if (success)
 
563
    {
 
564
      gint x, y, width, height;
 
565
 
 
566
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
567
 
 
568
      if (success &&
 
569
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
570
        {
 
571
          GimpMatrix3           matrix;
 
572
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
 
573
          gint                  off_x, off_y;
 
574
 
 
575
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
576
 
 
577
          x += off_x;
 
578
          y += off_y;
 
579
 
 
580
          /* Assemble the transformation matrix */
 
581
          gimp_matrix3_identity (&matrix);
 
582
          if (auto_center)
 
583
            gimp_transform_matrix_rotate_rect (&matrix,
 
584
                                               x, y, width, height, angle);
 
585
          else
 
586
            gimp_transform_matrix_rotate_center (&matrix,
 
587
                                                 center_x, center_y, angle);
 
588
 
 
589
          if (interpolate)
 
590
            interpolation_type = gimp->config->interpolation_type;
 
591
 
 
592
          if (progress)
 
593
            gimp_progress_start (progress, _("Rotating"), FALSE);
 
594
 
 
595
          /* Transform the selection */
 
596
          success = gimp_drawable_transform_affine (drawable, context,
 
597
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
 
598
                                                    interpolation_type,
 
599
                                                    interpolate, 3,
 
600
                                                    clip_result, progress);
 
601
 
 
602
          if (progress)
 
603
            gimp_progress_end (progress);
 
604
        }
 
605
    }
 
606
 
 
607
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
608
 
 
609
  if (success)
 
610
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
611
 
 
612
  return return_vals;
 
613
}
 
614
 
 
615
static GValueArray *
 
616
drawable_transform_scale_invoker (GimpProcedure     *procedure,
 
617
                                  Gimp              *gimp,
 
618
                                  GimpContext       *context,
 
619
                                  GimpProgress      *progress,
 
620
                                  const GValueArray *args)
 
621
{
 
622
  gboolean success = TRUE;
 
623
  GValueArray *return_vals;
 
624
  GimpDrawable *drawable;
 
625
  gdouble x0;
 
626
  gdouble y0;
 
627
  gdouble x1;
 
628
  gdouble y1;
 
629
  gint32 transform_direction;
 
630
  gint32 interpolation;
 
631
  gboolean supersample;
 
632
  gint32 recursion_level;
 
633
  gint32 clip_result;
 
634
 
 
635
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
636
  x0 = g_value_get_double (&args->values[1]);
 
637
  y0 = g_value_get_double (&args->values[2]);
 
638
  x1 = g_value_get_double (&args->values[3]);
 
639
  y1 = g_value_get_double (&args->values[4]);
 
640
  transform_direction = g_value_get_enum (&args->values[5]);
 
641
  interpolation = g_value_get_enum (&args->values[6]);
 
642
  supersample = g_value_get_boolean (&args->values[7]);
 
643
  recursion_level = g_value_get_int (&args->values[8]);
 
644
  clip_result = g_value_get_enum (&args->values[9]);
 
645
 
 
646
  if (success)
 
647
    {
 
648
      gint x, y, width, height;
 
649
 
 
650
      success = (gimp_item_is_attached (GIMP_ITEM (drawable)) && x0 < x1 && y0 < y1);
 
651
 
 
652
      if (success &&
 
653
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
654
        {
 
655
          GimpMatrix3 matrix;
 
656
          gint        off_x, off_y;
 
657
 
 
658
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
659
 
 
660
          x += off_x;
 
661
          y += off_y;
 
662
 
 
663
          /* Assemble the transformation matrix */
 
664
          gimp_matrix3_identity (&matrix);
 
665
          gimp_transform_matrix_scale (&matrix,
 
666
                                       x, y, width, height,
 
667
                                       x0, y0, x1 - x0, y1 - y0);
 
668
 
 
669
          if (progress)
 
670
            gimp_progress_start (progress, _("Scaling"), FALSE);
 
671
 
 
672
          /* Transform the selection */
 
673
          success = gimp_drawable_transform_affine (drawable, context,
 
674
                                                    &matrix, transform_direction,
 
675
                                                    interpolation, supersample,
 
676
                                                    recursion_level,
 
677
                                                    clip_result, progress);
 
678
 
 
679
          if (progress)
 
680
            gimp_progress_end (progress);
 
681
        }
 
682
    }
 
683
 
 
684
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
685
 
 
686
  if (success)
 
687
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
688
 
 
689
  return return_vals;
 
690
}
 
691
 
 
692
static GValueArray *
 
693
drawable_transform_scale_default_invoker (GimpProcedure     *procedure,
 
694
                                          Gimp              *gimp,
 
695
                                          GimpContext       *context,
 
696
                                          GimpProgress      *progress,
 
697
                                          const GValueArray *args)
 
698
{
 
699
  gboolean success = TRUE;
 
700
  GValueArray *return_vals;
 
701
  GimpDrawable *drawable;
 
702
  gdouble x0;
 
703
  gdouble y0;
 
704
  gdouble x1;
 
705
  gdouble y1;
 
706
  gboolean interpolate;
 
707
  gint32 clip_result;
 
708
 
 
709
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
710
  x0 = g_value_get_double (&args->values[1]);
 
711
  y0 = g_value_get_double (&args->values[2]);
 
712
  x1 = g_value_get_double (&args->values[3]);
 
713
  y1 = g_value_get_double (&args->values[4]);
 
714
  interpolate = g_value_get_boolean (&args->values[5]);
 
715
  clip_result = g_value_get_enum (&args->values[6]);
 
716
 
 
717
  if (success)
 
718
    {
 
719
      gint x, y, width, height;
 
720
 
 
721
      success = (gimp_item_is_attached (GIMP_ITEM (drawable)) && x0 < x1 && y0 < y1);
 
722
 
 
723
      if (success &&
 
724
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
725
        {
 
726
          GimpMatrix3           matrix;
 
727
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
 
728
          gint                  off_x, off_y;
 
729
 
 
730
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
731
 
 
732
          x += off_x;
 
733
          y += off_y;
 
734
 
 
735
          /* Assemble the transformation matrix */
 
736
          gimp_matrix3_identity (&matrix);
 
737
          gimp_transform_matrix_scale (&matrix,
 
738
                                       x, y, width, height,
 
739
                                       x0, y0, x1 - x0, y1 - y0);
 
740
 
 
741
          if (interpolate)
 
742
            interpolation_type = gimp->config->interpolation_type;
 
743
 
 
744
          if (progress)
 
745
            gimp_progress_start (progress, _("Scaling"), FALSE);
 
746
 
 
747
          /* Transform the selection */
 
748
          success = gimp_drawable_transform_affine (drawable, context,
 
749
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
 
750
                                                    interpolation_type,
 
751
                                                    interpolate, 3,
 
752
                                                    clip_result, progress);
 
753
 
 
754
          if (progress)
 
755
            gimp_progress_end (progress);
 
756
        }
 
757
    }
 
758
 
 
759
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
760
 
 
761
  if (success)
 
762
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
763
 
 
764
  return return_vals;
 
765
}
 
766
 
 
767
static GValueArray *
 
768
drawable_transform_shear_invoker (GimpProcedure     *procedure,
 
769
                                  Gimp              *gimp,
 
770
                                  GimpContext       *context,
 
771
                                  GimpProgress      *progress,
 
772
                                  const GValueArray *args)
 
773
{
 
774
  gboolean success = TRUE;
 
775
  GValueArray *return_vals;
 
776
  GimpDrawable *drawable;
 
777
  gint32 shear_type;
 
778
  gdouble magnitude;
 
779
  gint32 transform_direction;
 
780
  gint32 interpolation;
 
781
  gboolean supersample;
 
782
  gint32 recursion_level;
 
783
  gint32 clip_result;
 
784
 
 
785
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
786
  shear_type = g_value_get_enum (&args->values[1]);
 
787
  magnitude = g_value_get_double (&args->values[2]);
 
788
  transform_direction = g_value_get_enum (&args->values[3]);
 
789
  interpolation = g_value_get_enum (&args->values[4]);
 
790
  supersample = g_value_get_boolean (&args->values[5]);
 
791
  recursion_level = g_value_get_int (&args->values[6]);
 
792
  clip_result = g_value_get_enum (&args->values[7]);
 
793
 
 
794
  if (success)
 
795
    {
 
796
      gint x, y, width, height;
 
797
 
 
798
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
799
 
 
800
      if (success &&
 
801
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
802
        {
 
803
          GimpMatrix3 matrix;
 
804
          gint        off_x, off_y;
 
805
 
 
806
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
807
 
 
808
          x += off_x;
 
809
          y += off_y;
 
810
 
 
811
          /* Assemble the transformation matrix */
 
812
          gimp_matrix3_identity (&matrix);
 
813
          gimp_transform_matrix_shear (&matrix,
 
814
                                       x, y, width, height,
 
815
                                       shear_type, magnitude);
 
816
 
 
817
          if (progress)
 
818
            gimp_progress_start (progress, _("Shearing"), FALSE);
 
819
 
 
820
          /* Transform the selection */
 
821
          success = gimp_drawable_transform_affine (drawable, context,
 
822
                                                    &matrix, transform_direction,
 
823
                                                    interpolation, supersample,
 
824
                                                    recursion_level,
 
825
                                                    clip_result, progress);
 
826
 
 
827
          if (progress)
 
828
            gimp_progress_end (progress);
 
829
        }
 
830
    }
 
831
 
 
832
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
833
 
 
834
  if (success)
 
835
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
836
 
 
837
  return return_vals;
 
838
}
 
839
 
 
840
static GValueArray *
 
841
drawable_transform_shear_default_invoker (GimpProcedure     *procedure,
 
842
                                          Gimp              *gimp,
 
843
                                          GimpContext       *context,
 
844
                                          GimpProgress      *progress,
 
845
                                          const GValueArray *args)
 
846
{
 
847
  gboolean success = TRUE;
 
848
  GValueArray *return_vals;
 
849
  GimpDrawable *drawable;
 
850
  gint32 shear_type;
 
851
  gdouble magnitude;
 
852
  gboolean interpolate;
 
853
  gint32 clip_result;
 
854
 
 
855
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
856
  shear_type = g_value_get_enum (&args->values[1]);
 
857
  magnitude = g_value_get_double (&args->values[2]);
 
858
  interpolate = g_value_get_boolean (&args->values[3]);
 
859
  clip_result = g_value_get_enum (&args->values[4]);
 
860
 
 
861
  if (success)
 
862
    {
 
863
      gint x, y, width, height;
 
864
 
 
865
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
866
 
 
867
      if (success &&
 
868
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
869
        {
 
870
          GimpMatrix3           matrix;
 
871
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
 
872
          gint                  off_x, off_y;
 
873
 
 
874
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
875
 
 
876
          x += off_x;
 
877
          y += off_y;
 
878
 
 
879
          /* Assemble the transformation matrix */
 
880
          gimp_matrix3_identity (&matrix);
 
881
          gimp_transform_matrix_shear (&matrix,
 
882
                                       x, y, width, height,
 
883
                                       shear_type, magnitude);
 
884
 
 
885
          if (interpolate)
 
886
            interpolation_type = gimp->config->interpolation_type;
 
887
 
 
888
          if (progress)
 
889
            gimp_progress_start (progress, _("Shearing"), FALSE);
 
890
 
 
891
          /* Transform the selection */
 
892
          success = gimp_drawable_transform_affine (drawable, context,
 
893
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
 
894
                                                    interpolation_type,
 
895
                                                    interpolate, 3,
 
896
                                                    clip_result, progress);
 
897
 
 
898
          if (progress)
 
899
            gimp_progress_end (progress);
 
900
        }
 
901
    }
 
902
 
 
903
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
904
 
 
905
  if (success)
 
906
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
907
 
 
908
  return return_vals;
 
909
}
 
910
 
 
911
static GValueArray *
 
912
drawable_transform_2d_invoker (GimpProcedure     *procedure,
 
913
                               Gimp              *gimp,
 
914
                               GimpContext       *context,
 
915
                               GimpProgress      *progress,
 
916
                               const GValueArray *args)
 
917
{
 
918
  gboolean success = TRUE;
 
919
  GValueArray *return_vals;
 
920
  GimpDrawable *drawable;
 
921
  gdouble source_x;
 
922
  gdouble source_y;
 
923
  gdouble scale_x;
 
924
  gdouble scale_y;
 
925
  gdouble angle;
 
926
  gdouble dest_x;
 
927
  gdouble dest_y;
 
928
  gint32 transform_direction;
 
929
  gint32 interpolation;
 
930
  gboolean supersample;
 
931
  gint32 recursion_level;
 
932
  gint32 clip_result;
 
933
 
 
934
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
935
  source_x = g_value_get_double (&args->values[1]);
 
936
  source_y = g_value_get_double (&args->values[2]);
 
937
  scale_x = g_value_get_double (&args->values[3]);
 
938
  scale_y = g_value_get_double (&args->values[4]);
 
939
  angle = g_value_get_double (&args->values[5]);
 
940
  dest_x = g_value_get_double (&args->values[6]);
 
941
  dest_y = g_value_get_double (&args->values[7]);
 
942
  transform_direction = g_value_get_enum (&args->values[8]);
 
943
  interpolation = g_value_get_enum (&args->values[9]);
 
944
  supersample = g_value_get_boolean (&args->values[10]);
 
945
  recursion_level = g_value_get_int (&args->values[11]);
 
946
  clip_result = g_value_get_enum (&args->values[12]);
 
947
 
 
948
  if (success)
 
949
    {
 
950
      gint x, y, width, height;
 
951
 
 
952
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
953
 
 
954
      if (success &&
 
955
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
956
        {
 
957
          GimpMatrix3 matrix;
 
958
          gint        off_x, off_y;
 
959
 
 
960
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
961
 
 
962
          x += off_x;
 
963
          y += off_y;
 
964
 
 
965
          /* Assemble the transformation matrix */
 
966
          gimp_matrix3_identity  (&matrix);
 
967
          gimp_matrix3_translate (&matrix, -source_x, -source_y);
 
968
          gimp_matrix3_scale     (&matrix, scale_x, scale_y);
 
969
          gimp_matrix3_rotate    (&matrix, angle);
 
970
          gimp_matrix3_translate (&matrix, dest_x, dest_y);
 
971
 
 
972
          if (progress)
 
973
            gimp_progress_start (progress, _("2D Transform"), FALSE);
 
974
 
 
975
          /* Transform the selection */
 
976
          success = gimp_drawable_transform_affine (drawable, context,
 
977
                                                    &matrix, transform_direction,
 
978
                                                    interpolation, supersample,
 
979
                                                    recursion_level,
 
980
                                                    clip_result, progress);
 
981
 
 
982
          if (progress)
 
983
            gimp_progress_end (progress);
 
984
        }
 
985
    }
 
986
 
 
987
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
988
 
 
989
  if (success)
 
990
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
991
 
 
992
  return return_vals;
 
993
}
 
994
 
 
995
static GValueArray *
 
996
drawable_transform_2d_default_invoker (GimpProcedure     *procedure,
 
997
                                       Gimp              *gimp,
 
998
                                       GimpContext       *context,
 
999
                                       GimpProgress      *progress,
 
1000
                                       const GValueArray *args)
 
1001
{
 
1002
  gboolean success = TRUE;
 
1003
  GValueArray *return_vals;
 
1004
  GimpDrawable *drawable;
 
1005
  gdouble source_x;
 
1006
  gdouble source_y;
 
1007
  gdouble scale_x;
 
1008
  gdouble scale_y;
 
1009
  gdouble angle;
 
1010
  gdouble dest_x;
 
1011
  gdouble dest_y;
 
1012
  gboolean interpolate;
 
1013
  gint32 clip_result;
 
1014
 
 
1015
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
1016
  source_x = g_value_get_double (&args->values[1]);
 
1017
  source_y = g_value_get_double (&args->values[2]);
 
1018
  scale_x = g_value_get_double (&args->values[3]);
 
1019
  scale_y = g_value_get_double (&args->values[4]);
 
1020
  angle = g_value_get_double (&args->values[5]);
 
1021
  dest_x = g_value_get_double (&args->values[6]);
 
1022
  dest_y = g_value_get_double (&args->values[7]);
 
1023
  interpolate = g_value_get_boolean (&args->values[8]);
 
1024
  clip_result = g_value_get_enum (&args->values[9]);
 
1025
 
 
1026
  if (success)
 
1027
    {
 
1028
      gint x, y, width, height;
 
1029
 
 
1030
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
1031
 
 
1032
      if (success &&
 
1033
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
1034
        {
 
1035
          GimpMatrix3           matrix;
 
1036
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
 
1037
          gint                  off_x, off_y;
 
1038
 
 
1039
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
1040
 
 
1041
          x += off_x;
 
1042
          y += off_y;
 
1043
 
 
1044
          /* Assemble the transformation matrix */
 
1045
          gimp_matrix3_identity  (&matrix);
 
1046
          gimp_matrix3_translate (&matrix, -source_x, -source_y);
 
1047
          gimp_matrix3_scale     (&matrix, scale_x, scale_y);
 
1048
          gimp_matrix3_rotate    (&matrix, angle);
 
1049
          gimp_matrix3_translate (&matrix, dest_x, dest_y);
 
1050
 
 
1051
          if (interpolate)
 
1052
            interpolation_type = gimp->config->interpolation_type;
 
1053
 
 
1054
          if (progress)
 
1055
            gimp_progress_start (progress, _("2D Transforming"), FALSE);
 
1056
 
 
1057
          /* Transform the selection */
 
1058
          success = gimp_drawable_transform_affine (drawable, context,
 
1059
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
 
1060
                                                    interpolation_type,
 
1061
                                                    interpolate, 3,
 
1062
                                                    clip_result, progress);
 
1063
 
 
1064
          if (progress)
 
1065
            gimp_progress_end (progress);
 
1066
        }
 
1067
    }
 
1068
 
 
1069
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
1070
 
 
1071
  if (success)
 
1072
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
1073
 
 
1074
  return return_vals;
 
1075
}
 
1076
 
 
1077
static GValueArray *
 
1078
drawable_transform_matrix_invoker (GimpProcedure     *procedure,
 
1079
                                   Gimp              *gimp,
 
1080
                                   GimpContext       *context,
 
1081
                                   GimpProgress      *progress,
 
1082
                                   const GValueArray *args)
 
1083
{
 
1084
  gboolean success = TRUE;
 
1085
  GValueArray *return_vals;
 
1086
  GimpDrawable *drawable;
 
1087
  gdouble coeff_0_0;
 
1088
  gdouble coeff_0_1;
 
1089
  gdouble coeff_0_2;
 
1090
  gdouble coeff_1_0;
 
1091
  gdouble coeff_1_1;
 
1092
  gdouble coeff_1_2;
 
1093
  gdouble coeff_2_0;
 
1094
  gdouble coeff_2_1;
 
1095
  gdouble coeff_2_2;
 
1096
  gint32 transform_direction;
 
1097
  gint32 interpolation;
 
1098
  gboolean supersample;
 
1099
  gint32 recursion_level;
 
1100
  gint32 clip_result;
 
1101
 
 
1102
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
1103
  coeff_0_0 = g_value_get_double (&args->values[1]);
 
1104
  coeff_0_1 = g_value_get_double (&args->values[2]);
 
1105
  coeff_0_2 = g_value_get_double (&args->values[3]);
 
1106
  coeff_1_0 = g_value_get_double (&args->values[4]);
 
1107
  coeff_1_1 = g_value_get_double (&args->values[5]);
 
1108
  coeff_1_2 = g_value_get_double (&args->values[6]);
 
1109
  coeff_2_0 = g_value_get_double (&args->values[7]);
 
1110
  coeff_2_1 = g_value_get_double (&args->values[8]);
 
1111
  coeff_2_2 = g_value_get_double (&args->values[9]);
 
1112
  transform_direction = g_value_get_enum (&args->values[10]);
 
1113
  interpolation = g_value_get_enum (&args->values[11]);
 
1114
  supersample = g_value_get_boolean (&args->values[12]);
 
1115
  recursion_level = g_value_get_int (&args->values[13]);
 
1116
  clip_result = g_value_get_enum (&args->values[14]);
 
1117
 
 
1118
  if (success)
 
1119
    {
 
1120
      gint x, y, width, height;
 
1121
 
 
1122
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
1123
 
 
1124
      if (success &&
 
1125
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
1126
        {
 
1127
          GimpMatrix3 matrix;
 
1128
          gint        off_x, off_y;
 
1129
 
 
1130
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
1131
 
 
1132
          x += off_x;
 
1133
          y += off_y;
 
1134
 
 
1135
          /* Assemble the transformation matrix */
 
1136
          matrix.coeff[0][0] = coeff_0_0;
 
1137
          matrix.coeff[0][1] = coeff_0_1;
 
1138
          matrix.coeff[0][2] = coeff_0_2;
 
1139
          matrix.coeff[1][0] = coeff_1_0;
 
1140
          matrix.coeff[1][1] = coeff_1_1;
 
1141
          matrix.coeff[1][2] = coeff_1_2;
 
1142
          matrix.coeff[2][0] = coeff_2_0;
 
1143
          matrix.coeff[2][1] = coeff_2_1;
 
1144
          matrix.coeff[2][2] = coeff_2_2;
 
1145
 
 
1146
          if (progress)
 
1147
            gimp_progress_start (progress, _("2D Transforming"), FALSE);
 
1148
 
 
1149
          /* Transform the selection */
 
1150
          success = gimp_drawable_transform_affine (drawable, context,
 
1151
                                                    &matrix, transform_direction,
 
1152
                                                    interpolation, supersample,
 
1153
                                                    recursion_level,
 
1154
                                                    clip_result, progress);
 
1155
 
 
1156
          if (progress)
 
1157
            gimp_progress_end (progress);
 
1158
        }
 
1159
    }
 
1160
 
 
1161
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
1162
 
 
1163
  if (success)
 
1164
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
1165
 
 
1166
  return return_vals;
 
1167
}
 
1168
 
 
1169
static GValueArray *
 
1170
drawable_transform_matrix_default_invoker (GimpProcedure     *procedure,
 
1171
                                           Gimp              *gimp,
 
1172
                                           GimpContext       *context,
 
1173
                                           GimpProgress      *progress,
 
1174
                                           const GValueArray *args)
 
1175
{
 
1176
  gboolean success = TRUE;
 
1177
  GValueArray *return_vals;
 
1178
  GimpDrawable *drawable;
 
1179
  gdouble coeff_0_0;
 
1180
  gdouble coeff_0_1;
 
1181
  gdouble coeff_0_2;
 
1182
  gdouble coeff_1_0;
 
1183
  gdouble coeff_1_1;
 
1184
  gdouble coeff_1_2;
 
1185
  gdouble coeff_2_0;
 
1186
  gdouble coeff_2_1;
 
1187
  gdouble coeff_2_2;
 
1188
  gboolean interpolate;
 
1189
  gint32 clip_result;
 
1190
 
 
1191
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
1192
  coeff_0_0 = g_value_get_double (&args->values[1]);
 
1193
  coeff_0_1 = g_value_get_double (&args->values[2]);
 
1194
  coeff_0_2 = g_value_get_double (&args->values[3]);
 
1195
  coeff_1_0 = g_value_get_double (&args->values[4]);
 
1196
  coeff_1_1 = g_value_get_double (&args->values[5]);
 
1197
  coeff_1_2 = g_value_get_double (&args->values[6]);
 
1198
  coeff_2_0 = g_value_get_double (&args->values[7]);
 
1199
  coeff_2_1 = g_value_get_double (&args->values[8]);
 
1200
  coeff_2_2 = g_value_get_double (&args->values[9]);
 
1201
  interpolate = g_value_get_boolean (&args->values[10]);
 
1202
  clip_result = g_value_get_enum (&args->values[11]);
 
1203
 
 
1204
  if (success)
 
1205
    {
 
1206
      gint x, y, width, height;
 
1207
 
 
1208
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
 
1209
 
 
1210
      if (success &&
 
1211
          gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
 
1212
        {
 
1213
          GimpMatrix3           matrix;
 
1214
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
 
1215
          gint                  off_x, off_y;
 
1216
 
 
1217
          gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
 
1218
 
 
1219
          x += off_x;
 
1220
          y += off_y;
 
1221
 
 
1222
          /* Assemble the transformation matrix */
 
1223
          matrix.coeff[0][0] = coeff_0_0;
 
1224
          matrix.coeff[0][1] = coeff_0_1;
 
1225
          matrix.coeff[0][2] = coeff_0_2;
 
1226
          matrix.coeff[1][0] = coeff_1_0;
 
1227
          matrix.coeff[1][1] = coeff_1_1;
 
1228
          matrix.coeff[1][2] = coeff_1_2;
 
1229
          matrix.coeff[2][0] = coeff_2_0;
 
1230
          matrix.coeff[2][1] = coeff_2_1;
 
1231
          matrix.coeff[2][2] = coeff_2_2;
 
1232
 
 
1233
          if (interpolate)
 
1234
            interpolation_type = gimp->config->interpolation_type;
 
1235
 
 
1236
          if (progress)
 
1237
            gimp_progress_start (progress, _("2D Transforming"), FALSE);
 
1238
 
 
1239
          /* Transform the selection */
 
1240
          success = gimp_drawable_transform_affine (drawable, context,
 
1241
                                                    &matrix, GIMP_TRANSFORM_FORWARD,
 
1242
                                                    interpolation_type,
 
1243
                                                    interpolate, 3,
 
1244
                                                    clip_result, progress);
 
1245
 
 
1246
          if (progress)
 
1247
            gimp_progress_end (progress);
 
1248
        }
 
1249
    }
 
1250
 
 
1251
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
1252
 
 
1253
  if (success)
 
1254
    gimp_value_set_drawable (&return_vals->values[1], drawable);
 
1255
 
 
1256
  return return_vals;
 
1257
}
 
1258
 
 
1259
void
 
1260
register_drawable_transform_procs (GimpPDB *pdb)
 
1261
{
 
1262
  GimpProcedure *procedure;
 
1263
 
 
1264
  /*
 
1265
   * gimp-drawable-transform-flip-simple
 
1266
   */
 
1267
  procedure = gimp_procedure_new (drawable_transform_flip_simple_invoker);
 
1268
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-flip-simple");
 
1269
  gimp_procedure_set_static_strings (procedure,
 
1270
                                     "gimp-drawable-transform-flip-simple",
 
1271
                                     "Flip the specified drawable either vertically or horizontally.",
 
1272
                                     "This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. If auto_center is set to TRUE, the flip is around the selection's center. Otherwise, the coordinate of the axis needs to be specified. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable.",
 
1273
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1274
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1275
                                     "2004",
 
1276
                                     NULL);
 
1277
  gimp_procedure_add_argument (procedure,
 
1278
                               gimp_param_spec_drawable_id ("drawable",
 
1279
                                                            "drawable",
 
1280
                                                            "The affected drawable",
 
1281
                                                            pdb->gimp, FALSE,
 
1282
                                                            GIMP_PARAM_READWRITE));
 
1283
  gimp_procedure_add_argument (procedure,
 
1284
                               gimp_param_spec_enum ("flip-type",
 
1285
                                                     "flip type",
 
1286
                                                     "Type of flip",
 
1287
                                                     GIMP_TYPE_ORIENTATION_TYPE,
 
1288
                                                     GIMP_ORIENTATION_HORIZONTAL,
 
1289
                                                     GIMP_PARAM_READWRITE));
 
1290
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1]),
 
1291
                                      GIMP_ORIENTATION_UNKNOWN);
 
1292
  gimp_procedure_add_argument (procedure,
 
1293
                               g_param_spec_boolean ("auto-center",
 
1294
                                                     "auto center",
 
1295
                                                     "Whether to automatically position the axis in the selection center",
 
1296
                                                     FALSE,
 
1297
                                                     GIMP_PARAM_READWRITE));
 
1298
  gimp_procedure_add_argument (procedure,
 
1299
                               g_param_spec_double ("axis",
 
1300
                                                    "axis",
 
1301
                                                    "coord. of flip axis",
 
1302
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1303
                                                    GIMP_PARAM_READWRITE));
 
1304
  gimp_procedure_add_argument (procedure,
 
1305
                               g_param_spec_boolean ("clip-result",
 
1306
                                                     "clip result",
 
1307
                                                     "Whether to clip results",
 
1308
                                                     FALSE,
 
1309
                                                     GIMP_PARAM_READWRITE));
 
1310
  gimp_procedure_add_return_value (procedure,
 
1311
                                   gimp_param_spec_drawable_id ("drawable",
 
1312
                                                                "drawable",
 
1313
                                                                "The flipped drawable",
 
1314
                                                                pdb->gimp, FALSE,
 
1315
                                                                GIMP_PARAM_READWRITE));
 
1316
  gimp_pdb_register_procedure (pdb, procedure);
 
1317
  g_object_unref (procedure);
 
1318
 
 
1319
  /*
 
1320
   * gimp-drawable-transform-flip
 
1321
   */
 
1322
  procedure = gimp_procedure_new (drawable_transform_flip_invoker);
 
1323
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-flip");
 
1324
  gimp_procedure_set_static_strings (procedure,
 
1325
                                     "gimp-drawable-transform-flip",
 
1326
                                     "Flip the specified drawable around a given line.",
 
1327
                                     "This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. The axis to flip around is specified by specifying two points from that line. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable. The clip results parameter specifies wheter current selection will affect the transform.",
 
1328
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1329
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1330
                                     "2004",
 
1331
                                     NULL);
 
1332
  gimp_procedure_add_argument (procedure,
 
1333
                               gimp_param_spec_drawable_id ("drawable",
 
1334
                                                            "drawable",
 
1335
                                                            "The affected drawable",
 
1336
                                                            pdb->gimp, FALSE,
 
1337
                                                            GIMP_PARAM_READWRITE));
 
1338
  gimp_procedure_add_argument (procedure,
 
1339
                               g_param_spec_double ("x0",
 
1340
                                                    "x0",
 
1341
                                                    "horz. coord. of one end of axis",
 
1342
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1343
                                                    GIMP_PARAM_READWRITE));
 
1344
  gimp_procedure_add_argument (procedure,
 
1345
                               g_param_spec_double ("y0",
 
1346
                                                    "y0",
 
1347
                                                    "vert. coord. of one end of axis",
 
1348
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1349
                                                    GIMP_PARAM_READWRITE));
 
1350
  gimp_procedure_add_argument (procedure,
 
1351
                               g_param_spec_double ("x1",
 
1352
                                                    "x1",
 
1353
                                                    "horz. coord. of other end of axis",
 
1354
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1355
                                                    GIMP_PARAM_READWRITE));
 
1356
  gimp_procedure_add_argument (procedure,
 
1357
                               g_param_spec_double ("y1",
 
1358
                                                    "y1",
 
1359
                                                    "vert. coord. of other end of axis",
 
1360
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1361
                                                    GIMP_PARAM_READWRITE));
 
1362
  gimp_procedure_add_argument (procedure,
 
1363
                               g_param_spec_enum ("transform-direction",
 
1364
                                                  "transform direction",
 
1365
                                                  "Direction of transformation",
 
1366
                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
 
1367
                                                  GIMP_TRANSFORM_FORWARD,
 
1368
                                                  GIMP_PARAM_READWRITE));
 
1369
  gimp_procedure_add_argument (procedure,
 
1370
                               g_param_spec_enum ("interpolation",
 
1371
                                                  "interpolation",
 
1372
                                                  "Type of interpolation",
 
1373
                                                  GIMP_TYPE_INTERPOLATION_TYPE,
 
1374
                                                  GIMP_INTERPOLATION_NONE,
 
1375
                                                  GIMP_PARAM_READWRITE));
 
1376
  gimp_procedure_add_argument (procedure,
 
1377
                               g_param_spec_boolean ("supersample",
 
1378
                                                     "supersample",
 
1379
                                                     "Whether to perform supersample",
 
1380
                                                     FALSE,
 
1381
                                                     GIMP_PARAM_READWRITE));
 
1382
  gimp_procedure_add_argument (procedure,
 
1383
                               gimp_param_spec_int32 ("recursion-level",
 
1384
                                                      "recursion level",
 
1385
                                                      "Level of recursion (3 is a nice default)",
 
1386
                                                      1, G_MAXINT32, 1,
 
1387
                                                      GIMP_PARAM_READWRITE));
 
1388
  gimp_procedure_add_argument (procedure,
 
1389
                               g_param_spec_boolean ("clip-result",
 
1390
                                                     "clip result",
 
1391
                                                     "Whether to clip results",
 
1392
                                                     FALSE,
 
1393
                                                     GIMP_PARAM_READWRITE));
 
1394
  gimp_procedure_add_return_value (procedure,
 
1395
                                   gimp_param_spec_drawable_id ("drawable",
 
1396
                                                                "drawable",
 
1397
                                                                "The flipped drawable",
 
1398
                                                                pdb->gimp, FALSE,
 
1399
                                                                GIMP_PARAM_READWRITE));
 
1400
  gimp_pdb_register_procedure (pdb, procedure);
 
1401
  g_object_unref (procedure);
 
1402
 
 
1403
  /*
 
1404
   * gimp-drawable-transform-flip-default
 
1405
   */
 
1406
  procedure = gimp_procedure_new (drawable_transform_flip_default_invoker);
 
1407
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-flip-default");
 
1408
  gimp_procedure_set_static_strings (procedure,
 
1409
                                     "gimp-drawable-transform-flip-default",
 
1410
                                     "Flip the specified drawable around a given line.",
 
1411
                                     "This procedure is a variant of 'gimp-drawable-transform-flip' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
 
1412
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1413
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1414
                                     "2004",
 
1415
                                     NULL);
 
1416
  gimp_procedure_add_argument (procedure,
 
1417
                               gimp_param_spec_drawable_id ("drawable",
 
1418
                                                            "drawable",
 
1419
                                                            "The affected drawable",
 
1420
                                                            pdb->gimp, FALSE,
 
1421
                                                            GIMP_PARAM_READWRITE));
 
1422
  gimp_procedure_add_argument (procedure,
 
1423
                               g_param_spec_double ("x0",
 
1424
                                                    "x0",
 
1425
                                                    "horz. coord. of one end of axis",
 
1426
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1427
                                                    GIMP_PARAM_READWRITE));
 
1428
  gimp_procedure_add_argument (procedure,
 
1429
                               g_param_spec_double ("y0",
 
1430
                                                    "y0",
 
1431
                                                    "vert. coord. of one end of axis",
 
1432
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1433
                                                    GIMP_PARAM_READWRITE));
 
1434
  gimp_procedure_add_argument (procedure,
 
1435
                               g_param_spec_double ("x1",
 
1436
                                                    "x1",
 
1437
                                                    "horz. coord. of other end of axis",
 
1438
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1439
                                                    GIMP_PARAM_READWRITE));
 
1440
  gimp_procedure_add_argument (procedure,
 
1441
                               g_param_spec_double ("y1",
 
1442
                                                    "y1",
 
1443
                                                    "vert. coord. of other end of axis",
 
1444
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1445
                                                    GIMP_PARAM_READWRITE));
 
1446
  gimp_procedure_add_argument (procedure,
 
1447
                               g_param_spec_boolean ("interpolate",
 
1448
                                                     "interpolate",
 
1449
                                                     "Whether to use interpolation and supersampling",
 
1450
                                                     FALSE,
 
1451
                                                     GIMP_PARAM_READWRITE));
 
1452
  gimp_procedure_add_argument (procedure,
 
1453
                               g_param_spec_boolean ("clip-result",
 
1454
                                                     "clip result",
 
1455
                                                     "Whether to clip results",
 
1456
                                                     FALSE,
 
1457
                                                     GIMP_PARAM_READWRITE));
 
1458
  gimp_procedure_add_return_value (procedure,
 
1459
                                   gimp_param_spec_drawable_id ("drawable",
 
1460
                                                                "drawable",
 
1461
                                                                "The flipped drawable",
 
1462
                                                                pdb->gimp, FALSE,
 
1463
                                                                GIMP_PARAM_READWRITE));
 
1464
  gimp_pdb_register_procedure (pdb, procedure);
 
1465
  g_object_unref (procedure);
 
1466
 
 
1467
  /*
 
1468
   * gimp-drawable-transform-perspective
 
1469
   */
 
1470
  procedure = gimp_procedure_new (drawable_transform_perspective_invoker);
 
1471
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-perspective");
 
1472
  gimp_procedure_set_static_strings (procedure,
 
1473
                                     "gimp-drawable-transform-perspective",
 
1474
                                     "Perform a possibly non-affine transformation on the specified drawable, with extra parameters.",
 
1475
                                     "This procedure performs a possibly non-affine transformation on the specified drawable by allowing the corners of the original bounding box to be arbitrarily remapped to any values. The specified drawable is remapped if no selection exists. However, if a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then remapped as specified. The return value is the ID of the remapped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and remapped drawable. The 4 coordinates specify the new locations of each corner of the original bounding box. By specifying these values, any affine transformation (rotation, scaling, translation) can be affected. Additionally, these values can be specified such that the resulting transformed drawable will appear to have been projected via a perspective transform.",
 
1476
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1477
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1478
                                     "2004",
 
1479
                                     NULL);
 
1480
  gimp_procedure_add_argument (procedure,
 
1481
                               gimp_param_spec_drawable_id ("drawable",
 
1482
                                                            "drawable",
 
1483
                                                            "The affected drawable",
 
1484
                                                            pdb->gimp, FALSE,
 
1485
                                                            GIMP_PARAM_READWRITE));
 
1486
  gimp_procedure_add_argument (procedure,
 
1487
                               g_param_spec_double ("x0",
 
1488
                                                    "x0",
 
1489
                                                    "The new x coordinate of upper-left corner of original bounding box",
 
1490
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1491
                                                    GIMP_PARAM_READWRITE));
 
1492
  gimp_procedure_add_argument (procedure,
 
1493
                               g_param_spec_double ("y0",
 
1494
                                                    "y0",
 
1495
                                                    "The new y coordinate of upper-left corner of original bounding box",
 
1496
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1497
                                                    GIMP_PARAM_READWRITE));
 
1498
  gimp_procedure_add_argument (procedure,
 
1499
                               g_param_spec_double ("x1",
 
1500
                                                    "x1",
 
1501
                                                    "The new x coordinate of upper-right corner of original bounding box",
 
1502
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1503
                                                    GIMP_PARAM_READWRITE));
 
1504
  gimp_procedure_add_argument (procedure,
 
1505
                               g_param_spec_double ("y1",
 
1506
                                                    "y1",
 
1507
                                                    "The new y coordinate of upper-right corner of original bounding box",
 
1508
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1509
                                                    GIMP_PARAM_READWRITE));
 
1510
  gimp_procedure_add_argument (procedure,
 
1511
                               g_param_spec_double ("x2",
 
1512
                                                    "x2",
 
1513
                                                    "The new x coordinate of lower-left corner of original bounding box",
 
1514
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1515
                                                    GIMP_PARAM_READWRITE));
 
1516
  gimp_procedure_add_argument (procedure,
 
1517
                               g_param_spec_double ("y2",
 
1518
                                                    "y2",
 
1519
                                                    "The new y coordinate of lower-left corner of original bounding box",
 
1520
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1521
                                                    GIMP_PARAM_READWRITE));
 
1522
  gimp_procedure_add_argument (procedure,
 
1523
                               g_param_spec_double ("x3",
 
1524
                                                    "x3",
 
1525
                                                    "The new x coordinate of lower-right corner of original bounding box",
 
1526
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1527
                                                    GIMP_PARAM_READWRITE));
 
1528
  gimp_procedure_add_argument (procedure,
 
1529
                               g_param_spec_double ("y3",
 
1530
                                                    "y3",
 
1531
                                                    "The new y coordinate of lower-right corner of original bounding box",
 
1532
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1533
                                                    GIMP_PARAM_READWRITE));
 
1534
  gimp_procedure_add_argument (procedure,
 
1535
                               g_param_spec_enum ("transform-direction",
 
1536
                                                  "transform direction",
 
1537
                                                  "Direction of transformation",
 
1538
                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
 
1539
                                                  GIMP_TRANSFORM_FORWARD,
 
1540
                                                  GIMP_PARAM_READWRITE));
 
1541
  gimp_procedure_add_argument (procedure,
 
1542
                               g_param_spec_enum ("interpolation",
 
1543
                                                  "interpolation",
 
1544
                                                  "Type of interpolation",
 
1545
                                                  GIMP_TYPE_INTERPOLATION_TYPE,
 
1546
                                                  GIMP_INTERPOLATION_NONE,
 
1547
                                                  GIMP_PARAM_READWRITE));
 
1548
  gimp_procedure_add_argument (procedure,
 
1549
                               g_param_spec_boolean ("supersample",
 
1550
                                                     "supersample",
 
1551
                                                     "Whether to perform supersample",
 
1552
                                                     FALSE,
 
1553
                                                     GIMP_PARAM_READWRITE));
 
1554
  gimp_procedure_add_argument (procedure,
 
1555
                               gimp_param_spec_int32 ("recursion-level",
 
1556
                                                      "recursion level",
 
1557
                                                      "Level of recursion (3 is a nice default)",
 
1558
                                                      1, G_MAXINT32, 1,
 
1559
                                                      GIMP_PARAM_READWRITE));
 
1560
  gimp_procedure_add_argument (procedure,
 
1561
                               g_param_spec_enum ("clip-result",
 
1562
                                                  "clip result",
 
1563
                                                  "How to clip results",
 
1564
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
1565
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
1566
                                                  GIMP_PARAM_READWRITE));
 
1567
  gimp_procedure_add_return_value (procedure,
 
1568
                                   gimp_param_spec_drawable_id ("drawable",
 
1569
                                                                "drawable",
 
1570
                                                                "The newly mapped drawable",
 
1571
                                                                pdb->gimp, FALSE,
 
1572
                                                                GIMP_PARAM_READWRITE));
 
1573
  gimp_pdb_register_procedure (pdb, procedure);
 
1574
  g_object_unref (procedure);
 
1575
 
 
1576
  /*
 
1577
   * gimp-drawable-transform-perspective-default
 
1578
   */
 
1579
  procedure = gimp_procedure_new (drawable_transform_perspective_default_invoker);
 
1580
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-perspective-default");
 
1581
  gimp_procedure_set_static_strings (procedure,
 
1582
                                     "gimp-drawable-transform-perspective-default",
 
1583
                                     "Perform a possibly non-affine transformation on the specified drawable, with extra parameters.",
 
1584
                                     "This procedure is a variant of 'gimp-drawable-transform-perspective' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
 
1585
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1586
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1587
                                     "2004",
 
1588
                                     NULL);
 
1589
  gimp_procedure_add_argument (procedure,
 
1590
                               gimp_param_spec_drawable_id ("drawable",
 
1591
                                                            "drawable",
 
1592
                                                            "The affected drawable",
 
1593
                                                            pdb->gimp, FALSE,
 
1594
                                                            GIMP_PARAM_READWRITE));
 
1595
  gimp_procedure_add_argument (procedure,
 
1596
                               g_param_spec_double ("x0",
 
1597
                                                    "x0",
 
1598
                                                    "The new x coordinate of upper-left corner of original bounding box",
 
1599
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1600
                                                    GIMP_PARAM_READWRITE));
 
1601
  gimp_procedure_add_argument (procedure,
 
1602
                               g_param_spec_double ("y0",
 
1603
                                                    "y0",
 
1604
                                                    "The new y coordinate of upper-left corner of original bounding box",
 
1605
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1606
                                                    GIMP_PARAM_READWRITE));
 
1607
  gimp_procedure_add_argument (procedure,
 
1608
                               g_param_spec_double ("x1",
 
1609
                                                    "x1",
 
1610
                                                    "The new x coordinate of upper-right corner of original bounding box",
 
1611
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1612
                                                    GIMP_PARAM_READWRITE));
 
1613
  gimp_procedure_add_argument (procedure,
 
1614
                               g_param_spec_double ("y1",
 
1615
                                                    "y1",
 
1616
                                                    "The new y coordinate of upper-right corner of original bounding box",
 
1617
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1618
                                                    GIMP_PARAM_READWRITE));
 
1619
  gimp_procedure_add_argument (procedure,
 
1620
                               g_param_spec_double ("x2",
 
1621
                                                    "x2",
 
1622
                                                    "The new x coordinate of lower-left corner of original bounding box",
 
1623
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1624
                                                    GIMP_PARAM_READWRITE));
 
1625
  gimp_procedure_add_argument (procedure,
 
1626
                               g_param_spec_double ("y2",
 
1627
                                                    "y2",
 
1628
                                                    "The new y coordinate of lower-left corner of original bounding box",
 
1629
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1630
                                                    GIMP_PARAM_READWRITE));
 
1631
  gimp_procedure_add_argument (procedure,
 
1632
                               g_param_spec_double ("x3",
 
1633
                                                    "x3",
 
1634
                                                    "The new x coordinate of lower-right corner of original bounding box",
 
1635
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1636
                                                    GIMP_PARAM_READWRITE));
 
1637
  gimp_procedure_add_argument (procedure,
 
1638
                               g_param_spec_double ("y3",
 
1639
                                                    "y3",
 
1640
                                                    "The new y coordinate of lower-right corner of original bounding box",
 
1641
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1642
                                                    GIMP_PARAM_READWRITE));
 
1643
  gimp_procedure_add_argument (procedure,
 
1644
                               g_param_spec_boolean ("interpolate",
 
1645
                                                     "interpolate",
 
1646
                                                     "Whether to use interpolation and supersampling",
 
1647
                                                     FALSE,
 
1648
                                                     GIMP_PARAM_READWRITE));
 
1649
  gimp_procedure_add_argument (procedure,
 
1650
                               g_param_spec_enum ("clip-result",
 
1651
                                                  "clip result",
 
1652
                                                  "How to clip results",
 
1653
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
1654
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
1655
                                                  GIMP_PARAM_READWRITE));
 
1656
  gimp_procedure_add_return_value (procedure,
 
1657
                                   gimp_param_spec_drawable_id ("drawable",
 
1658
                                                                "drawable",
 
1659
                                                                "The newly mapped drawable",
 
1660
                                                                pdb->gimp, FALSE,
 
1661
                                                                GIMP_PARAM_READWRITE));
 
1662
  gimp_pdb_register_procedure (pdb, procedure);
 
1663
  g_object_unref (procedure);
 
1664
 
 
1665
  /*
 
1666
   * gimp-drawable-transform-rotate-simple
 
1667
   */
 
1668
  procedure = gimp_procedure_new (drawable_transform_rotate_simple_invoker);
 
1669
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-rotate-simple");
 
1670
  gimp_procedure_set_static_strings (procedure,
 
1671
                                     "gimp-drawable-transform-rotate-simple",
 
1672
                                     "Rotate the specified drawable about given coordinates through the specified angle.",
 
1673
                                     "This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
 
1674
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1675
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1676
                                     "2004",
 
1677
                                     NULL);
 
1678
  gimp_procedure_add_argument (procedure,
 
1679
                               gimp_param_spec_drawable_id ("drawable",
 
1680
                                                            "drawable",
 
1681
                                                            "The affected drawable",
 
1682
                                                            pdb->gimp, FALSE,
 
1683
                                                            GIMP_PARAM_READWRITE));
 
1684
  gimp_procedure_add_argument (procedure,
 
1685
                               g_param_spec_enum ("rotate-type",
 
1686
                                                  "rotate type",
 
1687
                                                  "Type of rotation",
 
1688
                                                  GIMP_TYPE_ROTATION_TYPE,
 
1689
                                                  GIMP_ROTATE_90,
 
1690
                                                  GIMP_PARAM_READWRITE));
 
1691
  gimp_procedure_add_argument (procedure,
 
1692
                               g_param_spec_boolean ("auto-center",
 
1693
                                                     "auto center",
 
1694
                                                     "Whether to automatically rotate around the selection center",
 
1695
                                                     FALSE,
 
1696
                                                     GIMP_PARAM_READWRITE));
 
1697
  gimp_procedure_add_argument (procedure,
 
1698
                               gimp_param_spec_int32 ("center-x",
 
1699
                                                      "center x",
 
1700
                                                      "The hor. coordinate of the center of rotation",
 
1701
                                                      G_MININT32, G_MAXINT32, 0,
 
1702
                                                      GIMP_PARAM_READWRITE));
 
1703
  gimp_procedure_add_argument (procedure,
 
1704
                               gimp_param_spec_int32 ("center-y",
 
1705
                                                      "center y",
 
1706
                                                      "The vert. coordinate of the center of rotation",
 
1707
                                                      G_MININT32, G_MAXINT32, 0,
 
1708
                                                      GIMP_PARAM_READWRITE));
 
1709
  gimp_procedure_add_argument (procedure,
 
1710
                               g_param_spec_boolean ("clip-result",
 
1711
                                                     "clip result",
 
1712
                                                     "Whether to clip results",
 
1713
                                                     FALSE,
 
1714
                                                     GIMP_PARAM_READWRITE));
 
1715
  gimp_procedure_add_return_value (procedure,
 
1716
                                   gimp_param_spec_drawable_id ("drawable",
 
1717
                                                                "drawable",
 
1718
                                                                "The rotated drawable",
 
1719
                                                                pdb->gimp, FALSE,
 
1720
                                                                GIMP_PARAM_READWRITE));
 
1721
  gimp_pdb_register_procedure (pdb, procedure);
 
1722
  g_object_unref (procedure);
 
1723
 
 
1724
  /*
 
1725
   * gimp-drawable-transform-rotate
 
1726
   */
 
1727
  procedure = gimp_procedure_new (drawable_transform_rotate_invoker);
 
1728
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-rotate");
 
1729
  gimp_procedure_set_static_strings (procedure,
 
1730
                                     "gimp-drawable-transform-rotate",
 
1731
                                     "Rotate the specified drawable about given coordinates through the specified angle.",
 
1732
                                     "This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
 
1733
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1734
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1735
                                     "2004",
 
1736
                                     NULL);
 
1737
  gimp_procedure_add_argument (procedure,
 
1738
                               gimp_param_spec_drawable_id ("drawable",
 
1739
                                                            "drawable",
 
1740
                                                            "The affected drawable",
 
1741
                                                            pdb->gimp, FALSE,
 
1742
                                                            GIMP_PARAM_READWRITE));
 
1743
  gimp_procedure_add_argument (procedure,
 
1744
                               g_param_spec_double ("angle",
 
1745
                                                    "angle",
 
1746
                                                    "The angle of rotation (radians)",
 
1747
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1748
                                                    GIMP_PARAM_READWRITE));
 
1749
  gimp_procedure_add_argument (procedure,
 
1750
                               g_param_spec_boolean ("auto-center",
 
1751
                                                     "auto center",
 
1752
                                                     "Whether to automatically rotate around the selection center",
 
1753
                                                     FALSE,
 
1754
                                                     GIMP_PARAM_READWRITE));
 
1755
  gimp_procedure_add_argument (procedure,
 
1756
                               gimp_param_spec_int32 ("center-x",
 
1757
                                                      "center x",
 
1758
                                                      "The hor. coordinate of the center of rotation",
 
1759
                                                      G_MININT32, G_MAXINT32, 0,
 
1760
                                                      GIMP_PARAM_READWRITE));
 
1761
  gimp_procedure_add_argument (procedure,
 
1762
                               gimp_param_spec_int32 ("center-y",
 
1763
                                                      "center y",
 
1764
                                                      "The vert. coordinate of the center of rotation",
 
1765
                                                      G_MININT32, G_MAXINT32, 0,
 
1766
                                                      GIMP_PARAM_READWRITE));
 
1767
  gimp_procedure_add_argument (procedure,
 
1768
                               g_param_spec_enum ("transform-direction",
 
1769
                                                  "transform direction",
 
1770
                                                  "Direction of transformation",
 
1771
                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
 
1772
                                                  GIMP_TRANSFORM_FORWARD,
 
1773
                                                  GIMP_PARAM_READWRITE));
 
1774
  gimp_procedure_add_argument (procedure,
 
1775
                               g_param_spec_enum ("interpolation",
 
1776
                                                  "interpolation",
 
1777
                                                  "Type of interpolation",
 
1778
                                                  GIMP_TYPE_INTERPOLATION_TYPE,
 
1779
                                                  GIMP_INTERPOLATION_NONE,
 
1780
                                                  GIMP_PARAM_READWRITE));
 
1781
  gimp_procedure_add_argument (procedure,
 
1782
                               g_param_spec_boolean ("supersample",
 
1783
                                                     "supersample",
 
1784
                                                     "Whether to perform supersample",
 
1785
                                                     FALSE,
 
1786
                                                     GIMP_PARAM_READWRITE));
 
1787
  gimp_procedure_add_argument (procedure,
 
1788
                               gimp_param_spec_int32 ("recursion-level",
 
1789
                                                      "recursion level",
 
1790
                                                      "Level of recursion (3 is a nice default)",
 
1791
                                                      1, G_MAXINT32, 1,
 
1792
                                                      GIMP_PARAM_READWRITE));
 
1793
  gimp_procedure_add_argument (procedure,
 
1794
                               g_param_spec_enum ("clip-result",
 
1795
                                                  "clip result",
 
1796
                                                  "How to clip results",
 
1797
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
1798
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
1799
                                                  GIMP_PARAM_READWRITE));
 
1800
  gimp_procedure_add_return_value (procedure,
 
1801
                                   gimp_param_spec_drawable_id ("drawable",
 
1802
                                                                "drawable",
 
1803
                                                                "The rotated drawable",
 
1804
                                                                pdb->gimp, FALSE,
 
1805
                                                                GIMP_PARAM_READWRITE));
 
1806
  gimp_pdb_register_procedure (pdb, procedure);
 
1807
  g_object_unref (procedure);
 
1808
 
 
1809
  /*
 
1810
   * gimp-drawable-transform-rotate-default
 
1811
   */
 
1812
  procedure = gimp_procedure_new (drawable_transform_rotate_default_invoker);
 
1813
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-rotate-default");
 
1814
  gimp_procedure_set_static_strings (procedure,
 
1815
                                     "gimp-drawable-transform-rotate-default",
 
1816
                                     "Rotate the specified drawable about given coordinates through the specified angle.",
 
1817
                                     "This procedure is a variant of 'gimp-drawable-transform-rotate' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
 
1818
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1819
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1820
                                     "2004",
 
1821
                                     NULL);
 
1822
  gimp_procedure_add_argument (procedure,
 
1823
                               gimp_param_spec_drawable_id ("drawable",
 
1824
                                                            "drawable",
 
1825
                                                            "The affected drawable",
 
1826
                                                            pdb->gimp, FALSE,
 
1827
                                                            GIMP_PARAM_READWRITE));
 
1828
  gimp_procedure_add_argument (procedure,
 
1829
                               g_param_spec_double ("angle",
 
1830
                                                    "angle",
 
1831
                                                    "The angle of rotation (radians)",
 
1832
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1833
                                                    GIMP_PARAM_READWRITE));
 
1834
  gimp_procedure_add_argument (procedure,
 
1835
                               g_param_spec_boolean ("auto-center",
 
1836
                                                     "auto center",
 
1837
                                                     "Whether to automatically rotate around the selection center",
 
1838
                                                     FALSE,
 
1839
                                                     GIMP_PARAM_READWRITE));
 
1840
  gimp_procedure_add_argument (procedure,
 
1841
                               gimp_param_spec_int32 ("center-x",
 
1842
                                                      "center x",
 
1843
                                                      "The hor. coordinate of the center of rotation",
 
1844
                                                      G_MININT32, G_MAXINT32, 0,
 
1845
                                                      GIMP_PARAM_READWRITE));
 
1846
  gimp_procedure_add_argument (procedure,
 
1847
                               gimp_param_spec_int32 ("center-y",
 
1848
                                                      "center y",
 
1849
                                                      "The vert. coordinate of the center of rotation",
 
1850
                                                      G_MININT32, G_MAXINT32, 0,
 
1851
                                                      GIMP_PARAM_READWRITE));
 
1852
  gimp_procedure_add_argument (procedure,
 
1853
                               g_param_spec_boolean ("interpolate",
 
1854
                                                     "interpolate",
 
1855
                                                     "Whether to use interpolation and supersampling",
 
1856
                                                     FALSE,
 
1857
                                                     GIMP_PARAM_READWRITE));
 
1858
  gimp_procedure_add_argument (procedure,
 
1859
                               g_param_spec_enum ("clip-result",
 
1860
                                                  "clip result",
 
1861
                                                  "How to clip results",
 
1862
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
1863
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
1864
                                                  GIMP_PARAM_READWRITE));
 
1865
  gimp_procedure_add_return_value (procedure,
 
1866
                                   gimp_param_spec_drawable_id ("drawable",
 
1867
                                                                "drawable",
 
1868
                                                                "The rotated drawable",
 
1869
                                                                pdb->gimp, FALSE,
 
1870
                                                                GIMP_PARAM_READWRITE));
 
1871
  gimp_pdb_register_procedure (pdb, procedure);
 
1872
  g_object_unref (procedure);
 
1873
 
 
1874
  /*
 
1875
   * gimp-drawable-transform-scale
 
1876
   */
 
1877
  procedure = gimp_procedure_new (drawable_transform_scale_invoker);
 
1878
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-scale");
 
1879
  gimp_procedure_set_static_strings (procedure,
 
1880
                                     "gimp-drawable-transform-scale",
 
1881
                                     "Scale the specified drawable with extra parameters",
 
1882
                                     "This procedure scales the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then scaled by the specified amount. The return value is the ID of the scaled drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and scaled drawable.",
 
1883
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1884
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1885
                                     "2004",
 
1886
                                     NULL);
 
1887
  gimp_procedure_add_argument (procedure,
 
1888
                               gimp_param_spec_drawable_id ("drawable",
 
1889
                                                            "drawable",
 
1890
                                                            "The affected drawable",
 
1891
                                                            pdb->gimp, FALSE,
 
1892
                                                            GIMP_PARAM_READWRITE));
 
1893
  gimp_procedure_add_argument (procedure,
 
1894
                               g_param_spec_double ("x0",
 
1895
                                                    "x0",
 
1896
                                                    "The new x coordinate of the upper-left corner of the scaled region",
 
1897
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1898
                                                    GIMP_PARAM_READWRITE));
 
1899
  gimp_procedure_add_argument (procedure,
 
1900
                               g_param_spec_double ("y0",
 
1901
                                                    "y0",
 
1902
                                                    "The new y coordinate of the upper-left corner of the scaled region",
 
1903
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1904
                                                    GIMP_PARAM_READWRITE));
 
1905
  gimp_procedure_add_argument (procedure,
 
1906
                               g_param_spec_double ("x1",
 
1907
                                                    "x1",
 
1908
                                                    "The new x coordinate of the lower-right corner of the scaled region",
 
1909
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1910
                                                    GIMP_PARAM_READWRITE));
 
1911
  gimp_procedure_add_argument (procedure,
 
1912
                               g_param_spec_double ("y1",
 
1913
                                                    "y1",
 
1914
                                                    "The new y coordinate of the lower-right corner of the scaled region",
 
1915
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1916
                                                    GIMP_PARAM_READWRITE));
 
1917
  gimp_procedure_add_argument (procedure,
 
1918
                               g_param_spec_enum ("transform-direction",
 
1919
                                                  "transform direction",
 
1920
                                                  "Direction of transformation",
 
1921
                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
 
1922
                                                  GIMP_TRANSFORM_FORWARD,
 
1923
                                                  GIMP_PARAM_READWRITE));
 
1924
  gimp_procedure_add_argument (procedure,
 
1925
                               g_param_spec_enum ("interpolation",
 
1926
                                                  "interpolation",
 
1927
                                                  "Type of interpolation",
 
1928
                                                  GIMP_TYPE_INTERPOLATION_TYPE,
 
1929
                                                  GIMP_INTERPOLATION_NONE,
 
1930
                                                  GIMP_PARAM_READWRITE));
 
1931
  gimp_procedure_add_argument (procedure,
 
1932
                               g_param_spec_boolean ("supersample",
 
1933
                                                     "supersample",
 
1934
                                                     "Whether to perform supersample",
 
1935
                                                     FALSE,
 
1936
                                                     GIMP_PARAM_READWRITE));
 
1937
  gimp_procedure_add_argument (procedure,
 
1938
                               gimp_param_spec_int32 ("recursion-level",
 
1939
                                                      "recursion level",
 
1940
                                                      "Level of recursion (3 is a nice default)",
 
1941
                                                      1, G_MAXINT32, 1,
 
1942
                                                      GIMP_PARAM_READWRITE));
 
1943
  gimp_procedure_add_argument (procedure,
 
1944
                               g_param_spec_enum ("clip-result",
 
1945
                                                  "clip result",
 
1946
                                                  "How to clip results",
 
1947
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
1948
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
1949
                                                  GIMP_PARAM_READWRITE));
 
1950
  gimp_procedure_add_return_value (procedure,
 
1951
                                   gimp_param_spec_drawable_id ("drawable",
 
1952
                                                                "drawable",
 
1953
                                                                "The scaled drawable",
 
1954
                                                                pdb->gimp, FALSE,
 
1955
                                                                GIMP_PARAM_READWRITE));
 
1956
  gimp_pdb_register_procedure (pdb, procedure);
 
1957
  g_object_unref (procedure);
 
1958
 
 
1959
  /*
 
1960
   * gimp-drawable-transform-scale-default
 
1961
   */
 
1962
  procedure = gimp_procedure_new (drawable_transform_scale_default_invoker);
 
1963
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-scale-default");
 
1964
  gimp_procedure_set_static_strings (procedure,
 
1965
                                     "gimp-drawable-transform-scale-default",
 
1966
                                     "Scale the specified drawable with extra parameters",
 
1967
                                     "This procedure is a variant of 'gimp-drawable-transform-scale' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
 
1968
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1969
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
1970
                                     "2004",
 
1971
                                     NULL);
 
1972
  gimp_procedure_add_argument (procedure,
 
1973
                               gimp_param_spec_drawable_id ("drawable",
 
1974
                                                            "drawable",
 
1975
                                                            "The affected drawable",
 
1976
                                                            pdb->gimp, FALSE,
 
1977
                                                            GIMP_PARAM_READWRITE));
 
1978
  gimp_procedure_add_argument (procedure,
 
1979
                               g_param_spec_double ("x0",
 
1980
                                                    "x0",
 
1981
                                                    "The new x coordinate of the upper-left corner of the scaled region",
 
1982
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1983
                                                    GIMP_PARAM_READWRITE));
 
1984
  gimp_procedure_add_argument (procedure,
 
1985
                               g_param_spec_double ("y0",
 
1986
                                                    "y0",
 
1987
                                                    "The new y coordinate of the upper-left corner of the scaled region",
 
1988
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1989
                                                    GIMP_PARAM_READWRITE));
 
1990
  gimp_procedure_add_argument (procedure,
 
1991
                               g_param_spec_double ("x1",
 
1992
                                                    "x1",
 
1993
                                                    "The new x coordinate of the lower-right corner of the scaled region",
 
1994
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1995
                                                    GIMP_PARAM_READWRITE));
 
1996
  gimp_procedure_add_argument (procedure,
 
1997
                               g_param_spec_double ("y1",
 
1998
                                                    "y1",
 
1999
                                                    "The new y coordinate of the lower-right corner of the scaled region",
 
2000
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2001
                                                    GIMP_PARAM_READWRITE));
 
2002
  gimp_procedure_add_argument (procedure,
 
2003
                               g_param_spec_boolean ("interpolate",
 
2004
                                                     "interpolate",
 
2005
                                                     "Whether to use interpolation and supersampling",
 
2006
                                                     FALSE,
 
2007
                                                     GIMP_PARAM_READWRITE));
 
2008
  gimp_procedure_add_argument (procedure,
 
2009
                               g_param_spec_enum ("clip-result",
 
2010
                                                  "clip result",
 
2011
                                                  "How to clip results",
 
2012
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
2013
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
2014
                                                  GIMP_PARAM_READWRITE));
 
2015
  gimp_procedure_add_return_value (procedure,
 
2016
                                   gimp_param_spec_drawable_id ("drawable",
 
2017
                                                                "drawable",
 
2018
                                                                "The scaled drawable",
 
2019
                                                                pdb->gimp, FALSE,
 
2020
                                                                GIMP_PARAM_READWRITE));
 
2021
  gimp_pdb_register_procedure (pdb, procedure);
 
2022
  g_object_unref (procedure);
 
2023
 
 
2024
  /*
 
2025
   * gimp-drawable-transform-shear
 
2026
   */
 
2027
  procedure = gimp_procedure_new (drawable_transform_shear_invoker);
 
2028
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-shear");
 
2029
  gimp_procedure_set_static_strings (procedure,
 
2030
                                     "gimp-drawable-transform-shear",
 
2031
                                     "Shear the specified drawable about its center by the specified magnitude, with extra parameters.",
 
2032
                                     "This procedure shears the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then sheard by the specified amount. The return value is the ID of the sheard drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and sheard drawable. The shear type parameter indicates whether the shear will be applied horizontally or vertically. The magnitude can be either positive or negative and indicates the extent (in pixels) to shear by.",
 
2033
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2034
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2035
                                     "2004",
 
2036
                                     NULL);
 
2037
  gimp_procedure_add_argument (procedure,
 
2038
                               gimp_param_spec_drawable_id ("drawable",
 
2039
                                                            "drawable",
 
2040
                                                            "The affected drawable",
 
2041
                                                            pdb->gimp, FALSE,
 
2042
                                                            GIMP_PARAM_READWRITE));
 
2043
  gimp_procedure_add_argument (procedure,
 
2044
                               gimp_param_spec_enum ("shear-type",
 
2045
                                                     "shear type",
 
2046
                                                     "Type of shear",
 
2047
                                                     GIMP_TYPE_ORIENTATION_TYPE,
 
2048
                                                     GIMP_ORIENTATION_HORIZONTAL,
 
2049
                                                     GIMP_PARAM_READWRITE));
 
2050
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1]),
 
2051
                                      GIMP_ORIENTATION_UNKNOWN);
 
2052
  gimp_procedure_add_argument (procedure,
 
2053
                               g_param_spec_double ("magnitude",
 
2054
                                                    "magnitude",
 
2055
                                                    "The magnitude of the shear",
 
2056
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2057
                                                    GIMP_PARAM_READWRITE));
 
2058
  gimp_procedure_add_argument (procedure,
 
2059
                               g_param_spec_enum ("transform-direction",
 
2060
                                                  "transform direction",
 
2061
                                                  "Direction of transformation",
 
2062
                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
 
2063
                                                  GIMP_TRANSFORM_FORWARD,
 
2064
                                                  GIMP_PARAM_READWRITE));
 
2065
  gimp_procedure_add_argument (procedure,
 
2066
                               g_param_spec_enum ("interpolation",
 
2067
                                                  "interpolation",
 
2068
                                                  "Type of interpolation",
 
2069
                                                  GIMP_TYPE_INTERPOLATION_TYPE,
 
2070
                                                  GIMP_INTERPOLATION_NONE,
 
2071
                                                  GIMP_PARAM_READWRITE));
 
2072
  gimp_procedure_add_argument (procedure,
 
2073
                               g_param_spec_boolean ("supersample",
 
2074
                                                     "supersample",
 
2075
                                                     "Whether to perform supersample",
 
2076
                                                     FALSE,
 
2077
                                                     GIMP_PARAM_READWRITE));
 
2078
  gimp_procedure_add_argument (procedure,
 
2079
                               gimp_param_spec_int32 ("recursion-level",
 
2080
                                                      "recursion level",
 
2081
                                                      "Level of recursion (3 is a nice default)",
 
2082
                                                      1, G_MAXINT32, 1,
 
2083
                                                      GIMP_PARAM_READWRITE));
 
2084
  gimp_procedure_add_argument (procedure,
 
2085
                               g_param_spec_enum ("clip-result",
 
2086
                                                  "clip result",
 
2087
                                                  "How to clip results",
 
2088
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
2089
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
2090
                                                  GIMP_PARAM_READWRITE));
 
2091
  gimp_procedure_add_return_value (procedure,
 
2092
                                   gimp_param_spec_drawable_id ("drawable",
 
2093
                                                                "drawable",
 
2094
                                                                "The sheared drawable",
 
2095
                                                                pdb->gimp, FALSE,
 
2096
                                                                GIMP_PARAM_READWRITE));
 
2097
  gimp_pdb_register_procedure (pdb, procedure);
 
2098
  g_object_unref (procedure);
 
2099
 
 
2100
  /*
 
2101
   * gimp-drawable-transform-shear-default
 
2102
   */
 
2103
  procedure = gimp_procedure_new (drawable_transform_shear_default_invoker);
 
2104
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-shear-default");
 
2105
  gimp_procedure_set_static_strings (procedure,
 
2106
                                     "gimp-drawable-transform-shear-default",
 
2107
                                     "Shear the specified drawable about its center by the specified magnitude, with extra parameters.",
 
2108
                                     "This procedure is a variant of 'gimp-drawable-transform-shear' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
 
2109
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2110
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2111
                                     "2004",
 
2112
                                     NULL);
 
2113
  gimp_procedure_add_argument (procedure,
 
2114
                               gimp_param_spec_drawable_id ("drawable",
 
2115
                                                            "drawable",
 
2116
                                                            "The affected drawable",
 
2117
                                                            pdb->gimp, FALSE,
 
2118
                                                            GIMP_PARAM_READWRITE));
 
2119
  gimp_procedure_add_argument (procedure,
 
2120
                               gimp_param_spec_enum ("shear-type",
 
2121
                                                     "shear type",
 
2122
                                                     "Type of shear",
 
2123
                                                     GIMP_TYPE_ORIENTATION_TYPE,
 
2124
                                                     GIMP_ORIENTATION_HORIZONTAL,
 
2125
                                                     GIMP_PARAM_READWRITE));
 
2126
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1]),
 
2127
                                      GIMP_ORIENTATION_UNKNOWN);
 
2128
  gimp_procedure_add_argument (procedure,
 
2129
                               g_param_spec_double ("magnitude",
 
2130
                                                    "magnitude",
 
2131
                                                    "The magnitude of the shear",
 
2132
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2133
                                                    GIMP_PARAM_READWRITE));
 
2134
  gimp_procedure_add_argument (procedure,
 
2135
                               g_param_spec_boolean ("interpolate",
 
2136
                                                     "interpolate",
 
2137
                                                     "Whether to use interpolation and supersampling",
 
2138
                                                     FALSE,
 
2139
                                                     GIMP_PARAM_READWRITE));
 
2140
  gimp_procedure_add_argument (procedure,
 
2141
                               g_param_spec_enum ("clip-result",
 
2142
                                                  "clip result",
 
2143
                                                  "How to clip results",
 
2144
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
2145
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
2146
                                                  GIMP_PARAM_READWRITE));
 
2147
  gimp_procedure_add_return_value (procedure,
 
2148
                                   gimp_param_spec_drawable_id ("drawable",
 
2149
                                                                "drawable",
 
2150
                                                                "The sheared drawable",
 
2151
                                                                pdb->gimp, FALSE,
 
2152
                                                                GIMP_PARAM_READWRITE));
 
2153
  gimp_pdb_register_procedure (pdb, procedure);
 
2154
  g_object_unref (procedure);
 
2155
 
 
2156
  /*
 
2157
   * gimp-drawable-transform-2d
 
2158
   */
 
2159
  procedure = gimp_procedure_new (drawable_transform_2d_invoker);
 
2160
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-2d");
 
2161
  gimp_procedure_set_static_strings (procedure,
 
2162
                                     "gimp-drawable-transform-2d",
 
2163
                                     "Transform the specified drawable in 2d, with extra parameters.",
 
2164
                                     "This procedure transforms the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by scaling the image by the x and y scale factors about the point (source_x, source_y), then rotating around the same point, then translating that point to the new position (dest_x, dest_y). The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and transformed drawable.",
 
2165
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2166
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2167
                                     "2004",
 
2168
                                     NULL);
 
2169
  gimp_procedure_add_argument (procedure,
 
2170
                               gimp_param_spec_drawable_id ("drawable",
 
2171
                                                            "drawable",
 
2172
                                                            "The affected drawable",
 
2173
                                                            pdb->gimp, FALSE,
 
2174
                                                            GIMP_PARAM_READWRITE));
 
2175
  gimp_procedure_add_argument (procedure,
 
2176
                               g_param_spec_double ("source-x",
 
2177
                                                    "source x",
 
2178
                                                    "X coordinate of the transformation center",
 
2179
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2180
                                                    GIMP_PARAM_READWRITE));
 
2181
  gimp_procedure_add_argument (procedure,
 
2182
                               g_param_spec_double ("source-y",
 
2183
                                                    "source y",
 
2184
                                                    "Y coordinate of the transformation center",
 
2185
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2186
                                                    GIMP_PARAM_READWRITE));
 
2187
  gimp_procedure_add_argument (procedure,
 
2188
                               g_param_spec_double ("scale-x",
 
2189
                                                    "scale x",
 
2190
                                                    "Amount to scale in x direction",
 
2191
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2192
                                                    GIMP_PARAM_READWRITE));
 
2193
  gimp_procedure_add_argument (procedure,
 
2194
                               g_param_spec_double ("scale-y",
 
2195
                                                    "scale y",
 
2196
                                                    "Amount to scale in y direction",
 
2197
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2198
                                                    GIMP_PARAM_READWRITE));
 
2199
  gimp_procedure_add_argument (procedure,
 
2200
                               g_param_spec_double ("angle",
 
2201
                                                    "angle",
 
2202
                                                    "The angle of rotation (radians)",
 
2203
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2204
                                                    GIMP_PARAM_READWRITE));
 
2205
  gimp_procedure_add_argument (procedure,
 
2206
                               g_param_spec_double ("dest-x",
 
2207
                                                    "dest x",
 
2208
                                                    "X coordinate of where the center goes",
 
2209
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2210
                                                    GIMP_PARAM_READWRITE));
 
2211
  gimp_procedure_add_argument (procedure,
 
2212
                               g_param_spec_double ("dest-y",
 
2213
                                                    "dest y",
 
2214
                                                    "Y coordinate of where the center goes",
 
2215
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2216
                                                    GIMP_PARAM_READWRITE));
 
2217
  gimp_procedure_add_argument (procedure,
 
2218
                               g_param_spec_enum ("transform-direction",
 
2219
                                                  "transform direction",
 
2220
                                                  "Direction of transformation",
 
2221
                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
 
2222
                                                  GIMP_TRANSFORM_FORWARD,
 
2223
                                                  GIMP_PARAM_READWRITE));
 
2224
  gimp_procedure_add_argument (procedure,
 
2225
                               g_param_spec_enum ("interpolation",
 
2226
                                                  "interpolation",
 
2227
                                                  "Type of interpolation",
 
2228
                                                  GIMP_TYPE_INTERPOLATION_TYPE,
 
2229
                                                  GIMP_INTERPOLATION_NONE,
 
2230
                                                  GIMP_PARAM_READWRITE));
 
2231
  gimp_procedure_add_argument (procedure,
 
2232
                               g_param_spec_boolean ("supersample",
 
2233
                                                     "supersample",
 
2234
                                                     "Whether to perform supersample",
 
2235
                                                     FALSE,
 
2236
                                                     GIMP_PARAM_READWRITE));
 
2237
  gimp_procedure_add_argument (procedure,
 
2238
                               gimp_param_spec_int32 ("recursion-level",
 
2239
                                                      "recursion level",
 
2240
                                                      "Level of recursion (3 is a nice default)",
 
2241
                                                      1, G_MAXINT32, 1,
 
2242
                                                      GIMP_PARAM_READWRITE));
 
2243
  gimp_procedure_add_argument (procedure,
 
2244
                               g_param_spec_enum ("clip-result",
 
2245
                                                  "clip result",
 
2246
                                                  "How to clip results",
 
2247
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
2248
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
2249
                                                  GIMP_PARAM_READWRITE));
 
2250
  gimp_procedure_add_return_value (procedure,
 
2251
                                   gimp_param_spec_drawable_id ("drawable",
 
2252
                                                                "drawable",
 
2253
                                                                "The transformed drawable",
 
2254
                                                                pdb->gimp, FALSE,
 
2255
                                                                GIMP_PARAM_READWRITE));
 
2256
  gimp_pdb_register_procedure (pdb, procedure);
 
2257
  g_object_unref (procedure);
 
2258
 
 
2259
  /*
 
2260
   * gimp-drawable-transform-2d-default
 
2261
   */
 
2262
  procedure = gimp_procedure_new (drawable_transform_2d_default_invoker);
 
2263
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-2d-default");
 
2264
  gimp_procedure_set_static_strings (procedure,
 
2265
                                     "gimp-drawable-transform-2d-default",
 
2266
                                     "Transform the specified drawable in 2d, with extra parameters.",
 
2267
                                     "This procedure is a variant of 'gimp-drawable-transform-2d' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
 
2268
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2269
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2270
                                     "2004",
 
2271
                                     NULL);
 
2272
  gimp_procedure_add_argument (procedure,
 
2273
                               gimp_param_spec_drawable_id ("drawable",
 
2274
                                                            "drawable",
 
2275
                                                            "The affected drawable",
 
2276
                                                            pdb->gimp, FALSE,
 
2277
                                                            GIMP_PARAM_READWRITE));
 
2278
  gimp_procedure_add_argument (procedure,
 
2279
                               g_param_spec_double ("source-x",
 
2280
                                                    "source x",
 
2281
                                                    "X coordinate of the transformation center",
 
2282
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2283
                                                    GIMP_PARAM_READWRITE));
 
2284
  gimp_procedure_add_argument (procedure,
 
2285
                               g_param_spec_double ("source-y",
 
2286
                                                    "source y",
 
2287
                                                    "Y coordinate of the transformation center",
 
2288
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2289
                                                    GIMP_PARAM_READWRITE));
 
2290
  gimp_procedure_add_argument (procedure,
 
2291
                               g_param_spec_double ("scale-x",
 
2292
                                                    "scale x",
 
2293
                                                    "Amount to scale in x direction",
 
2294
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2295
                                                    GIMP_PARAM_READWRITE));
 
2296
  gimp_procedure_add_argument (procedure,
 
2297
                               g_param_spec_double ("scale-y",
 
2298
                                                    "scale y",
 
2299
                                                    "Amount to scale in y direction",
 
2300
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2301
                                                    GIMP_PARAM_READWRITE));
 
2302
  gimp_procedure_add_argument (procedure,
 
2303
                               g_param_spec_double ("angle",
 
2304
                                                    "angle",
 
2305
                                                    "The angle of rotation (radians)",
 
2306
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2307
                                                    GIMP_PARAM_READWRITE));
 
2308
  gimp_procedure_add_argument (procedure,
 
2309
                               g_param_spec_double ("dest-x",
 
2310
                                                    "dest x",
 
2311
                                                    "X coordinate of where the center goes",
 
2312
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2313
                                                    GIMP_PARAM_READWRITE));
 
2314
  gimp_procedure_add_argument (procedure,
 
2315
                               g_param_spec_double ("dest-y",
 
2316
                                                    "dest y",
 
2317
                                                    "Y coordinate of where the center goes",
 
2318
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2319
                                                    GIMP_PARAM_READWRITE));
 
2320
  gimp_procedure_add_argument (procedure,
 
2321
                               g_param_spec_boolean ("interpolate",
 
2322
                                                     "interpolate",
 
2323
                                                     "Whether to use interpolation and supersampling",
 
2324
                                                     FALSE,
 
2325
                                                     GIMP_PARAM_READWRITE));
 
2326
  gimp_procedure_add_argument (procedure,
 
2327
                               g_param_spec_enum ("clip-result",
 
2328
                                                  "clip result",
 
2329
                                                  "How to clip results",
 
2330
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
2331
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
2332
                                                  GIMP_PARAM_READWRITE));
 
2333
  gimp_procedure_add_return_value (procedure,
 
2334
                                   gimp_param_spec_drawable_id ("drawable",
 
2335
                                                                "drawable",
 
2336
                                                                "The transformed drawable",
 
2337
                                                                pdb->gimp, FALSE,
 
2338
                                                                GIMP_PARAM_READWRITE));
 
2339
  gimp_pdb_register_procedure (pdb, procedure);
 
2340
  g_object_unref (procedure);
 
2341
 
 
2342
  /*
 
2343
   * gimp-drawable-transform-matrix
 
2344
   */
 
2345
  procedure = gimp_procedure_new (drawable_transform_matrix_invoker);
 
2346
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-matrix");
 
2347
  gimp_procedure_set_static_strings (procedure,
 
2348
                                     "gimp-drawable-transform-matrix",
 
2349
                                     "Transform the specified drawable in 2d, with extra parameters.",
 
2350
                                     "This procedure transforms the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by assembling a 3x3 matrix from the coefficients passed. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and transformed drawable.",
 
2351
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2352
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2353
                                     "2004",
 
2354
                                     NULL);
 
2355
  gimp_procedure_add_argument (procedure,
 
2356
                               gimp_param_spec_drawable_id ("drawable",
 
2357
                                                            "drawable",
 
2358
                                                            "The affected drawable",
 
2359
                                                            pdb->gimp, FALSE,
 
2360
                                                            GIMP_PARAM_READWRITE));
 
2361
  gimp_procedure_add_argument (procedure,
 
2362
                               g_param_spec_double ("coeff-0-0",
 
2363
                                                    "coeff 0 0",
 
2364
                                                    "coefficient (0,0) of the transformation matrix",
 
2365
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2366
                                                    GIMP_PARAM_READWRITE));
 
2367
  gimp_procedure_add_argument (procedure,
 
2368
                               g_param_spec_double ("coeff-0-1",
 
2369
                                                    "coeff 0 1",
 
2370
                                                    "coefficient (0,1) of the transformation matrix",
 
2371
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2372
                                                    GIMP_PARAM_READWRITE));
 
2373
  gimp_procedure_add_argument (procedure,
 
2374
                               g_param_spec_double ("coeff-0-2",
 
2375
                                                    "coeff 0 2",
 
2376
                                                    "coefficient (0,2) of the transformation matrix",
 
2377
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2378
                                                    GIMP_PARAM_READWRITE));
 
2379
  gimp_procedure_add_argument (procedure,
 
2380
                               g_param_spec_double ("coeff-1-0",
 
2381
                                                    "coeff 1 0",
 
2382
                                                    "coefficient (1,0) of the transformation matrix",
 
2383
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2384
                                                    GIMP_PARAM_READWRITE));
 
2385
  gimp_procedure_add_argument (procedure,
 
2386
                               g_param_spec_double ("coeff-1-1",
 
2387
                                                    "coeff 1 1",
 
2388
                                                    "coefficient (1,1) of the transformation matrix",
 
2389
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2390
                                                    GIMP_PARAM_READWRITE));
 
2391
  gimp_procedure_add_argument (procedure,
 
2392
                               g_param_spec_double ("coeff-1-2",
 
2393
                                                    "coeff 1 2",
 
2394
                                                    "coefficient (1,2) of the transformation matrix",
 
2395
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2396
                                                    GIMP_PARAM_READWRITE));
 
2397
  gimp_procedure_add_argument (procedure,
 
2398
                               g_param_spec_double ("coeff-2-0",
 
2399
                                                    "coeff 2 0",
 
2400
                                                    "coefficient (2,0) of the transformation matrix",
 
2401
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2402
                                                    GIMP_PARAM_READWRITE));
 
2403
  gimp_procedure_add_argument (procedure,
 
2404
                               g_param_spec_double ("coeff-2-1",
 
2405
                                                    "coeff 2 1",
 
2406
                                                    "coefficient (2,1) of the transformation matrix",
 
2407
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2408
                                                    GIMP_PARAM_READWRITE));
 
2409
  gimp_procedure_add_argument (procedure,
 
2410
                               g_param_spec_double ("coeff-2-2",
 
2411
                                                    "coeff 2 2",
 
2412
                                                    "coefficient (2,2) of the transformation matrix",
 
2413
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2414
                                                    GIMP_PARAM_READWRITE));
 
2415
  gimp_procedure_add_argument (procedure,
 
2416
                               g_param_spec_enum ("transform-direction",
 
2417
                                                  "transform direction",
 
2418
                                                  "Direction of transformation",
 
2419
                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
 
2420
                                                  GIMP_TRANSFORM_FORWARD,
 
2421
                                                  GIMP_PARAM_READWRITE));
 
2422
  gimp_procedure_add_argument (procedure,
 
2423
                               g_param_spec_enum ("interpolation",
 
2424
                                                  "interpolation",
 
2425
                                                  "Type of interpolation",
 
2426
                                                  GIMP_TYPE_INTERPOLATION_TYPE,
 
2427
                                                  GIMP_INTERPOLATION_NONE,
 
2428
                                                  GIMP_PARAM_READWRITE));
 
2429
  gimp_procedure_add_argument (procedure,
 
2430
                               g_param_spec_boolean ("supersample",
 
2431
                                                     "supersample",
 
2432
                                                     "Whether to perform supersample",
 
2433
                                                     FALSE,
 
2434
                                                     GIMP_PARAM_READWRITE));
 
2435
  gimp_procedure_add_argument (procedure,
 
2436
                               gimp_param_spec_int32 ("recursion-level",
 
2437
                                                      "recursion level",
 
2438
                                                      "Level of recursion (3 is a nice default)",
 
2439
                                                      1, G_MAXINT32, 1,
 
2440
                                                      GIMP_PARAM_READWRITE));
 
2441
  gimp_procedure_add_argument (procedure,
 
2442
                               g_param_spec_enum ("clip-result",
 
2443
                                                  "clip result",
 
2444
                                                  "How to clip results",
 
2445
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
2446
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
2447
                                                  GIMP_PARAM_READWRITE));
 
2448
  gimp_procedure_add_return_value (procedure,
 
2449
                                   gimp_param_spec_drawable_id ("drawable",
 
2450
                                                                "drawable",
 
2451
                                                                "The transformed drawable",
 
2452
                                                                pdb->gimp, FALSE,
 
2453
                                                                GIMP_PARAM_READWRITE));
 
2454
  gimp_pdb_register_procedure (pdb, procedure);
 
2455
  g_object_unref (procedure);
 
2456
 
 
2457
  /*
 
2458
   * gimp-drawable-transform-matrix-default
 
2459
   */
 
2460
  procedure = gimp_procedure_new (drawable_transform_matrix_default_invoker);
 
2461
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-drawable-transform-matrix-default");
 
2462
  gimp_procedure_set_static_strings (procedure,
 
2463
                                     "gimp-drawable-transform-matrix-default",
 
2464
                                     "Transform the specified drawable in 2d, with extra parameters.",
 
2465
                                     "This procedure is a variant of 'gimp-drawable-transform-matrix' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
 
2466
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2467
                                     "Jo\xc3\xa3o S. O. Bueno Calligaris",
 
2468
                                     "2004",
 
2469
                                     NULL);
 
2470
  gimp_procedure_add_argument (procedure,
 
2471
                               gimp_param_spec_drawable_id ("drawable",
 
2472
                                                            "drawable",
 
2473
                                                            "The affected drawable",
 
2474
                                                            pdb->gimp, FALSE,
 
2475
                                                            GIMP_PARAM_READWRITE));
 
2476
  gimp_procedure_add_argument (procedure,
 
2477
                               g_param_spec_double ("coeff-0-0",
 
2478
                                                    "coeff 0 0",
 
2479
                                                    "coefficient (0,0) of the transformation matrix",
 
2480
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2481
                                                    GIMP_PARAM_READWRITE));
 
2482
  gimp_procedure_add_argument (procedure,
 
2483
                               g_param_spec_double ("coeff-0-1",
 
2484
                                                    "coeff 0 1",
 
2485
                                                    "coefficient (0,1) of the transformation matrix",
 
2486
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2487
                                                    GIMP_PARAM_READWRITE));
 
2488
  gimp_procedure_add_argument (procedure,
 
2489
                               g_param_spec_double ("coeff-0-2",
 
2490
                                                    "coeff 0 2",
 
2491
                                                    "coefficient (0,2) of the transformation matrix",
 
2492
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2493
                                                    GIMP_PARAM_READWRITE));
 
2494
  gimp_procedure_add_argument (procedure,
 
2495
                               g_param_spec_double ("coeff-1-0",
 
2496
                                                    "coeff 1 0",
 
2497
                                                    "coefficient (1,0) of the transformation matrix",
 
2498
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2499
                                                    GIMP_PARAM_READWRITE));
 
2500
  gimp_procedure_add_argument (procedure,
 
2501
                               g_param_spec_double ("coeff-1-1",
 
2502
                                                    "coeff 1 1",
 
2503
                                                    "coefficient (1,1) of the transformation matrix",
 
2504
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2505
                                                    GIMP_PARAM_READWRITE));
 
2506
  gimp_procedure_add_argument (procedure,
 
2507
                               g_param_spec_double ("coeff-1-2",
 
2508
                                                    "coeff 1 2",
 
2509
                                                    "coefficient (1,2) of the transformation matrix",
 
2510
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2511
                                                    GIMP_PARAM_READWRITE));
 
2512
  gimp_procedure_add_argument (procedure,
 
2513
                               g_param_spec_double ("coeff-2-0",
 
2514
                                                    "coeff 2 0",
 
2515
                                                    "coefficient (2,0) of the transformation matrix",
 
2516
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2517
                                                    GIMP_PARAM_READWRITE));
 
2518
  gimp_procedure_add_argument (procedure,
 
2519
                               g_param_spec_double ("coeff-2-1",
 
2520
                                                    "coeff 2 1",
 
2521
                                                    "coefficient (2,1) of the transformation matrix",
 
2522
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2523
                                                    GIMP_PARAM_READWRITE));
 
2524
  gimp_procedure_add_argument (procedure,
 
2525
                               g_param_spec_double ("coeff-2-2",
 
2526
                                                    "coeff 2 2",
 
2527
                                                    "coefficient (2,2) of the transformation matrix",
 
2528
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
2529
                                                    GIMP_PARAM_READWRITE));
 
2530
  gimp_procedure_add_argument (procedure,
 
2531
                               g_param_spec_boolean ("interpolate",
 
2532
                                                     "interpolate",
 
2533
                                                     "Whether to use interpolation and supersampling",
 
2534
                                                     FALSE,
 
2535
                                                     GIMP_PARAM_READWRITE));
 
2536
  gimp_procedure_add_argument (procedure,
 
2537
                               g_param_spec_enum ("clip-result",
 
2538
                                                  "clip result",
 
2539
                                                  "How to clip results",
 
2540
                                                  GIMP_TYPE_TRANSFORM_RESIZE,
 
2541
                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
 
2542
                                                  GIMP_PARAM_READWRITE));
 
2543
  gimp_procedure_add_return_value (procedure,
 
2544
                                   gimp_param_spec_drawable_id ("drawable",
 
2545
                                                                "drawable",
 
2546
                                                                "The transformed drawable",
 
2547
                                                                pdb->gimp, FALSE,
 
2548
                                                                GIMP_PARAM_READWRITE));
 
2549
  gimp_pdb_register_procedure (pdb, procedure);
 
2550
  g_object_unref (procedure);
 
2551
}