47
59
if (!PyArg_ParseTuple(args, "iiii:update", &x, &y, &w, &h))
49
gimp_drawable_update(self->ID, x, y, w, h);
56
drw_merge_shadow(PyGimpDrawable *self, PyObject *args)
59
if (!PyArg_ParseTuple(args, "i:merge_shadow", &u))
61
gimp_drawable_merge_shadow(self->ID, u);
68
drw_fill(PyGimpDrawable *self, PyObject *args)
71
if (!PyArg_ParseTuple(args, "i:fill", &f))
73
gimp_drawable_fill(self->ID, f);
80
drw_get_tile(PyGimpDrawable *self, PyObject *args)
62
if (!gimp_drawable_update(self->ID, x, y, w, h)) {
63
PyErr_Format(pygimp_error,
64
"could not update drawable (ID %d): "
65
"x=%d, y=%d, w=%d, h=%d",
66
self->ID, x, y, (int)w, (int)h);
76
drw_merge_shadow(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
78
gboolean undo = FALSE;
80
static char *kwlist[] = { "undo", NULL };
82
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:merge_shadow", kwlist,
86
if (!gimp_drawable_merge_shadow(self->ID, undo)) {
87
PyErr_Format(pygimp_error,
88
"could not merge the shadow buffer on drawable (ID %d)",
99
drw_fill(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
101
int fill = GIMP_FOREGROUND_FILL;
103
static char *kwlist[] = { "fill", NULL };
105
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:fill", kwlist, &fill))
108
if (!gimp_drawable_fill(self->ID, fill)) {
109
PyErr_Format(pygimp_error,
110
"could not fill drawable (ID %d) with fill mode %d",
121
drw_get_tile(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
84
if (!PyArg_ParseTuple(args, "iii:get_tile", &shadow, &r, &c))
124
int shadow, row, col;
126
static char *kwlist[] = { "shadow", "row", "col", NULL };
128
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii:get_tile", kwlist,
129
&shadow, &row, &col))
86
132
ensure_drawable(self);
87
t = gimp_drawable_get_tile(self->drawable, shadow, r, c);
134
t = gimp_drawable_get_tile(self->drawable, shadow, row, col);
88
135
return pygimp_tile_new(t, self);
92
drw_get_tile2(PyGimpDrawable *self, PyObject *args)
139
drw_get_tile2(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
96
if (!PyArg_ParseTuple(args, "iii:get_tile2", &shadow, &x ,&y))
144
static char *kwlist[] = { "shadow", "x", "y", NULL };
146
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii:get_tile2", kwlist,
98
150
ensure_drawable(self);
99
152
t = gimp_drawable_get_tile2(self->drawable, shadow, x, y);
100
153
return pygimp_tile_new(t, self);
103
156
static PyObject *
104
drw_get_pixel_rgn(PyGimpDrawable *self, PyObject *args)
157
drw_get_pixel_rgn(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
106
int x, y, w, h, dirty = 1, shadow = 0;
107
if (!PyArg_ParseTuple(args, "iiii|ii:get_pixel_rgn", &x,&y,
108
&w,&h, &dirty,&shadow))
159
int x, y, width, height, dirty = 1, shadow = 0;
161
static char *kwlist[] = { "x", "y", "width", "height", "dirty", "shadow",
164
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
165
"iiii|ii:get_pixel_rgn", kwlist,
166
&x, &y, &width, &height, &dirty, &shadow))
110
169
ensure_drawable(self);
111
return pygimp_pixel_rgn_new(self, x, y, w, h, dirty, shadow);
171
return pygimp_pixel_rgn_new(self, x, y, width, height, dirty, shadow);
114
174
static PyObject *
115
drw_offset(PyGimpDrawable *self, PyObject *args)
175
drw_offset(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
117
gboolean wrap_around;
118
178
GimpOffsetType fill_type;
119
gint offset_x, offset_y;
121
if (!PyArg_ParseTuple(args, "iiii:offset", &wrap_around, &fill_type,
122
&offset_x, &offset_y))
124
return PyInt_FromLong(gimp_drawable_offset(self->ID, wrap_around,
125
fill_type, offset_x, offset_y));
179
int offset_x, offset_y;
181
static char *kwlist[] = { "wrap_around", "fill_type",
182
"offset_x", "offset_y",
185
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iiii:offset", kwlist,
186
&wrap_around, &fill_type,
187
&offset_x, &offset_y))
190
if (!gimp_drawable_offset(self->ID, wrap_around, fill_type,
191
offset_x, offset_y)) {
192
PyErr_Format(pygimp_error,
193
"could not offset drawable (ID %d) by x: %d, y: %d",
194
self->ID, offset_x, offset_y);
128
202
static PyObject *
129
203
drw_parasite_find(PyGimpDrawable *self, PyObject *args)
132
207
if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
134
210
return pygimp_parasite_new(gimp_drawable_parasite_find(self->ID, name));
183
286
ret = PyTuple_New(num_parasites);
184
288
for (i = 0; i < num_parasites; i++) {
185
289
PyTuple_SetItem(ret, i, PyString_FromString(parasites[i]));
186
290
g_free(parasites[i]);
188
293
g_free(parasites);
191
PyErr_SetString(pygimp_error, "could not list parasites");
297
PyErr_Format(pygimp_error, "could not list parasites on drawable (ID %d)",
303
drw_get_pixel(PyGimpDrawable *self, PyObject *args)
310
if (!PyArg_ParseTuple(args, "(ii):get_pixel", &x, &y)) {
312
if (!PyArg_ParseTuple(args, "ii:get_pixel", &x, &y))
316
pixel = gimp_drawable_get_pixel(self->ID, x, y, &num_channels);
319
PyErr_Format(pygimp_error,
320
"could not get pixel (%d, %d) on drawable (ID %d)",
325
ret = PyTuple_New(num_channels);
327
for (i = 0; i < num_channels; i++)
328
PyTuple_SetItem(ret, i, PyInt_FromLong(pixel[i]));
336
drw_set_pixel(PyGimpDrawable *self, PyObject *args)
339
int num_channels, i, val;
341
PyObject *seq, *item;
342
gboolean is_string, error = TRUE;
344
if (!PyArg_ParseTuple(args, "(ii)O:set_pixel", &x, &y, &seq)) {
346
if (!PyArg_ParseTuple(args, "iiO:set_pixel", &x, &y, &seq))
350
if (!PyString_Check(seq)) {
351
if (!PySequence_Check(seq)) {
352
PyErr_SetString(PyExc_TypeError,
353
"pixel values must be a sequence");
359
num_channels = PySequence_Length(seq);
360
pixel = g_new(guint8, num_channels);
362
for (i = 0; i < num_channels; i++) {
363
item = PySequence_GetItem(seq, i);
365
if (!PyInt_Check(item)) {
366
PyErr_SetString(PyExc_TypeError,
367
"pixel values must be a sequence of ints");
371
val = PyInt_AsLong(item);
373
if (val < 0 || val > 255) {
374
PyErr_SetString(PyExc_TypeError,
375
"pixel values must be between 0 and 255");
384
num_channels = PyString_Size(seq);
385
pixel = PyString_AsString(seq);
388
error = !gimp_drawable_set_pixel(self->ID, x, y, num_channels, pixel);
391
PyErr_Format(pygimp_error,
392
"could not set %d-element pixel (%d, %d) on "
394
num_channels, x, y, self->ID);
408
drw_mask_intersect(PyGimpDrawable *self)
410
int x, y, width, height;
412
if (!gimp_drawable_mask_intersect(self->ID, &x, &y, &width, &height)) {
413
PyErr_Format(pygimp_error,
414
"could not get selection bounds of drawable (ID %d)",
419
return Py_BuildValue("(iiii)", x, y, width, height);
423
transform_result(PyGimpDrawable *self, gint32 id, const char *err_desc)
425
if (id == self->ID) {
427
return (PyObject *)self;
428
} else if (id != -1) {
429
return pygimp_drawable_new(NULL, id);
431
PyErr_Format(pygimp_error, "could not %s drawable (ID %d)",
438
drw_transform_flip(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
440
double x0, y0, x1, y1;
441
int transform_direction, interpolation, recursion_level = 3;
442
gboolean supersample = FALSE, clip_result = FALSE;
445
static char *kwlist[] = { "x0", "y0", "x1", "y1",
446
"transform_direction", "interpolation",
447
"supersample", "recursion_level",
448
"clip_result", NULL };
450
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
451
"ddddii|iii:transform_flip", kwlist,
452
&x0, &y0, &x1, &y1, &transform_direction,
453
&interpolation, &supersample,
454
&recursion_level, &clip_result))
457
id = gimp_drawable_transform_flip(self->ID, x0, y0, x1, y1,
458
transform_direction, interpolation,
459
supersample, recursion_level,
462
return transform_result(self, id, "flip");
466
drw_transform_flip_simple(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
469
gboolean auto_center, clip_result = FALSE;
473
static char *kwlist[] = { "flip_type", "auto_center", "axis",
474
"clip_result", NULL };
476
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
477
"iid|:transform_flip_simple", kwlist,
478
&flip_type, &auto_center, &axis,
482
id = gimp_drawable_transform_flip_simple(self->ID, flip_type, auto_center,
485
return transform_result(self, id, "flip");
489
drw_transform_flip_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
491
double x0, y0, x1, y1;
492
gboolean interpolate = FALSE, clip_result = FALSE;
495
static char *kwlist[] = { "x0", "y0", "x1", "y1", "interpolate",
496
"clip_result", NULL };
498
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
499
"dddd|ii:transform_flip_default", kwlist,
500
&x0, &y0, &x1, &y1, &interpolate,
504
id = gimp_drawable_transform_flip_default(self->ID, x0, y0, x1, y1,
505
interpolate, clip_result);
507
return transform_result(self, id, "flip");
511
drw_transform_perspective(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
513
double x0, y0, x1, y1, x2, y2, x3, y3;
514
int transform_direction, interpolation, recursion_level = 3;
515
gboolean supersample = FALSE, clip_result = FALSE;
518
static char *kwlist[] = { "x0", "y0", "x1", "y1", "x2", "y2", "x3", "y3",
519
"transform_direction", "interpolation",
520
"supersample", "recursion_level",
521
"clip_result", NULL };
523
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
524
"ddddddddii|iii:transform_perspective",
526
&x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3,
527
&transform_direction, &interpolation,
528
&supersample, &recursion_level,
532
id = gimp_drawable_transform_perspective(self->ID,
533
x0, y0, x1, y1, x2, y2, x3, y3,
534
transform_direction, interpolation,
535
supersample, recursion_level,
538
return transform_result(self, id, "apply perspective transform to");
542
drw_transform_perspective_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
544
double x0, y0, x1, y1, x2, y2, x3, y3;
545
gboolean interpolate = FALSE, clip_result = FALSE;
548
static char *kwlist[] = { "x0", "y0", "x1", "y1", "x2", "y2", "x3", "y3",
549
"interpolate", "clip_result", NULL };
551
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
552
"dddddddd|ii:transform_perspective_default",
554
&x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3,
555
&interpolate, &clip_result))
558
id = gimp_drawable_transform_perspective_default(self->ID,
561
interpolate, clip_result);
563
return transform_result(self, id, "apply perspective transform to");
567
drw_transform_rotate(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
570
gboolean auto_center, supersample = FALSE, clip_result = FALSE;
571
int center_x, center_y, transform_direction, interpolation,
575
static char *kwlist[] = { "angle", "auto_center", "center_x", "center_y",
576
"transform_direction", "interpolation",
577
"supersample", "recursion_level",
578
"clip_result", NULL };
580
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
581
"diiii|iii:transform_rotate", kwlist,
582
&angle, &auto_center, ¢er_x, ¢er_y,
583
&transform_direction, &interpolation,
584
&supersample, &recursion_level,
588
id = gimp_drawable_transform_rotate(self->ID, angle, auto_center,
590
transform_direction, interpolation,
591
supersample, recursion_level,
594
return transform_result(self, id, "rotate");
598
drw_transform_rotate_simple(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
600
int rotate_type, center_x, center_y;
601
gboolean auto_center, clip_result = FALSE;
604
static char *kwlist[] = { "rotate_type", "auto_center",
605
"center_x", "center_y",
606
"clip_result", NULL };
608
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
609
"iiii|i:transform_rotate_simple", kwlist,
610
&rotate_type, &auto_center,
611
¢er_x, ¢er_y,
615
id = gimp_drawable_transform_rotate_simple(self->ID, rotate_type,
620
return transform_result(self, id, "rotate");
624
drw_transform_rotate_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
627
gboolean auto_center, interpolate = FALSE, clip_result = FALSE;
628
int center_x, center_y;
631
static char *kwlist[] = { "angle", "auto_center", "center_x", "center_y",
632
"interpolate", "clip_result", NULL };
634
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
635
"dddd|ii:transform_rotate_default", kwlist,
636
&angle, &auto_center, ¢er_x, ¢er_y,
637
&interpolate, &clip_result))
640
id = gimp_drawable_transform_rotate_default(self->ID, angle, auto_center,
642
interpolate, clip_result);
644
return transform_result(self, id, "rotate");
648
drw_transform_scale(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
650
double x0, y0, x1, y1;
651
int transform_direction, interpolation, recursion_level = 3;
652
gboolean supersample = FALSE, clip_result = FALSE;
655
static char *kwlist[] = { "x0", "y0", "x1", "y1",
656
"transform_direction", "interpolation",
657
"supersample", "recursion_level",
658
"clip_result", NULL };
660
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
661
"ddddii|iii:transform_scale", kwlist,
662
&x0, &y0, &x1, &y1, &transform_direction,
663
&interpolation, &supersample,
664
&recursion_level, &clip_result))
667
id = gimp_drawable_transform_scale(self->ID, x0, y0, x1, y1,
668
transform_direction, interpolation,
669
supersample, recursion_level,
672
return transform_result(self, id, "scale");
676
drw_transform_scale_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
678
double x0, y0, x1, y1;
679
gboolean interpolate = FALSE, clip_result = FALSE;
682
static char *kwlist[] = { "x0", "y0", "x1", "y1", "interpolate",
683
"clip_result", NULL };
685
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
686
"dddd|ii:transform_scale_default", kwlist,
687
&x0, &y0, &x1, &y1, &interpolate,
691
id = gimp_drawable_transform_scale_default(self->ID, x0, y0, x1, y1,
692
interpolate, clip_result);
694
return transform_result(self, id, "scale");
698
drw_transform_shear(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
700
int shear_type, transform_direction, interpolation, recursion_level = 3;
702
gboolean supersample = FALSE, clip_result = FALSE;
705
static char *kwlist[] = { "shear_type", "magnitude",
706
"transform_direction", "interpolation",
707
"supersample", "recursion_level",
708
"clip_result", NULL };
710
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
711
"idii|iii:transform_shear", kwlist,
712
&shear_type, &magnitude,
713
&transform_direction, &interpolation,
714
&supersample, &recursion_level,
718
id = gimp_drawable_transform_shear(self->ID, shear_type, magnitude,
719
transform_direction, interpolation,
720
supersample, recursion_level,
723
return transform_result(self, id, "shear");
727
drw_transform_shear_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
731
gboolean interpolate = FALSE, clip_result = FALSE;
734
static char *kwlist[] = { "shear_type", "magnitude", "interpolate",
735
"clip_result", NULL };
737
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
738
"id|ii:transform_shear_default", kwlist,
739
&shear_type, &magnitude, &interpolate,
743
id = gimp_drawable_transform_shear_default(self->ID, shear_type,
744
magnitude, interpolate,
747
return transform_result(self, id, "shear");
751
drw_transform_2d(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
753
double source_x, source_y, scale_x, scale_y, angle, dest_x, dest_y;
754
int transform_direction, interpolation, recursion_level = 3;
755
gboolean supersample = FALSE, clip_result = FALSE;
758
static char *kwlist[] = { "source_x", "source_y", "scale_x", "scale_y",
759
"angle", "dest_x", "dest_y",
760
"transform_direction", "interpolation",
761
"supersample", "recursion_level",
762
"clip_result", NULL };
764
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
765
"dddddddii|iii:transform_2d", kwlist,
766
&source_x, &source_y, &scale_x, &scale_y,
767
&angle, &dest_x, &dest_y,
768
&transform_direction, &interpolation,
769
&supersample, &recursion_level,
773
id = gimp_drawable_transform_2d(self->ID, source_x, source_y,
774
scale_x, scale_y, angle, dest_x, dest_y,
775
transform_direction, interpolation,
776
supersample, recursion_level, clip_result);
778
return transform_result(self, id, "apply 2d transform to");
782
drw_transform_2d_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
784
double source_x, source_y, scale_x, scale_y, angle, dest_x, dest_y;
785
gboolean interpolate = FALSE, clip_result = FALSE;
788
static char *kwlist[] = { "source_x", "source_y", "scale_x", "scale_y",
789
"angle", "dest_x", "dest_y", "interpolate",
790
"clip_result", NULL };
792
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
793
"ddddddd|ii:transform_2d_default", kwlist,
794
&source_x, &source_y, &scale_x, &scale_y,
795
&angle, &dest_x, &dest_y, &interpolate,
799
id = gimp_drawable_transform_2d_default(self->ID, source_x, source_y,
800
scale_x, scale_y, angle,
801
dest_x, dest_y, interpolate,
804
return transform_result(self, id, "apply 2d transform to");
808
drw_transform_matrix(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
810
double coeff_0_0, coeff_0_1, coeff_0_2,
811
coeff_1_0, coeff_1_1, coeff_1_2,
812
coeff_2_0, coeff_2_1, coeff_2_2;
813
int transform_direction, interpolation, recursion_level = 3;
814
gboolean supersample = FALSE, clip_result = FALSE;
817
static char *kwlist[] = { "coeff_0_0", "coeff_0_1", "coeff_0_2",
818
"coeff_1_0", "coeff_1_1", "coeff_1_2",
819
"coeff_2_0", "coeff_2_1", "coeff_2_2",
820
"transform_direction", "interpolation",
821
"supersample", "recursion_level",
822
"clip_result", NULL };
824
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
825
"dddddddddii|iii:transform_matrix", kwlist,
826
&coeff_0_0, &coeff_0_1, &coeff_0_2,
827
&coeff_1_0, &coeff_1_1, &coeff_1_2,
828
&coeff_2_0, &coeff_2_1, &coeff_2_2,
829
&transform_direction, &interpolation,
830
&supersample, &recursion_level,
834
id = gimp_drawable_transform_matrix(self->ID,
835
coeff_0_0, coeff_0_1, coeff_0_2,
836
coeff_1_0, coeff_1_1, coeff_1_2,
837
coeff_2_0, coeff_2_1, coeff_2_2,
838
transform_direction, interpolation,
839
supersample, recursion_level,
842
return transform_result(self, id, "apply 2d matrix transform to");
846
drw_transform_matrix_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
848
double coeff_0_0, coeff_0_1, coeff_0_2,
849
coeff_1_0, coeff_1_1, coeff_1_2,
850
coeff_2_0, coeff_2_1, coeff_2_2;
851
gboolean interpolate = FALSE, clip_result = FALSE;
854
static char *kwlist[] = { "coeff_0_0", "coeff_0_1", "coeff_0_2",
855
"coeff_1_0", "coeff_1_1", "coeff_1_2",
856
"coeff_2_0", "coeff_2_1", "coeff_2_2",
857
"interpolate", "clip_result", NULL };
859
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
860
"ddddddddd|ii:transform_matrix_default",
862
&coeff_0_0, &coeff_0_1, &coeff_0_2,
863
&coeff_1_0, &coeff_1_1, &coeff_1_2,
864
&coeff_2_0, &coeff_2_1, &coeff_2_2,
865
&interpolate, &clip_result))
868
id = gimp_drawable_transform_matrix_default(self->ID,
869
coeff_0_0, coeff_0_1, coeff_0_2,
870
coeff_1_0, coeff_1_1, coeff_1_2,
871
coeff_2_0, coeff_2_1, coeff_2_2,
872
interpolate, clip_result);
874
return transform_result(self, id, "apply 2d matrix transform to");
195
877
/* for inclusion with the methods of layer and channel objects */
196
878
static PyMethodDef drw_methods[] = {
197
879
{"flush", (PyCFunction)drw_flush, METH_NOARGS},
198
880
{"update", (PyCFunction)drw_update, METH_VARARGS},
199
{"merge_shadow", (PyCFunction)drw_merge_shadow, METH_VARARGS},
200
{"fill", (PyCFunction)drw_fill, METH_VARARGS},
201
{"get_tile", (PyCFunction)drw_get_tile, METH_VARARGS},
202
{"get_tile2", (PyCFunction)drw_get_tile2, METH_VARARGS},
203
{"get_pixel_rgn", (PyCFunction)drw_get_pixel_rgn, METH_VARARGS},
204
{"offset", (PyCFunction)drw_offset, METH_VARARGS},
881
{"merge_shadow", (PyCFunction)drw_merge_shadow, METH_VARARGS | METH_KEYWORDS},
882
{"fill", (PyCFunction)drw_fill, METH_VARARGS | METH_KEYWORDS},
883
{"get_tile", (PyCFunction)drw_get_tile, METH_VARARGS | METH_KEYWORDS},
884
{"get_tile2", (PyCFunction)drw_get_tile2, METH_VARARGS | METH_KEYWORDS},
885
{"get_pixel_rgn", (PyCFunction)drw_get_pixel_rgn, METH_VARARGS | METH_KEYWORDS},
886
{"offset", (PyCFunction)drw_offset, METH_VARARGS | METH_KEYWORDS},
205
887
{"parasite_find", (PyCFunction)drw_parasite_find, METH_VARARGS},
206
888
{"parasite_attach", (PyCFunction)drw_parasite_attach, METH_VARARGS},
207
{"attach_new_parasite",(PyCFunction)drw_attach_new_parasite,METH_VARARGS},
889
{"attach_new_parasite",(PyCFunction)drw_attach_new_parasite,METH_VARARGS | METH_KEYWORDS},
208
890
{"parasite_detach", (PyCFunction)drw_parasite_detach, METH_VARARGS},
209
891
{"parasite_list", (PyCFunction)drw_parasite_list, METH_VARARGS},
892
{"get_pixel", (PyCFunction)drw_get_pixel, METH_VARARGS},
893
{"set_pixel", (PyCFunction)drw_set_pixel, METH_VARARGS},
894
{"mask_intersect", (PyCFunction)drw_mask_intersect, METH_NOARGS},
895
{"transform_flip", (PyCFunction)drw_transform_flip, METH_VARARGS | METH_KEYWORDS},
896
{"transform_flip_simple", (PyCFunction)drw_transform_flip_simple, METH_VARARGS | METH_KEYWORDS},
897
{"transform_flip_default", (PyCFunction)drw_transform_flip_default, METH_VARARGS | METH_KEYWORDS},
898
{"transform_perspective", (PyCFunction)drw_transform_perspective, METH_VARARGS | METH_KEYWORDS},
899
{"transform_perspective_default", (PyCFunction)drw_transform_perspective_default, METH_VARARGS | METH_KEYWORDS},
900
{"transform_rotate", (PyCFunction)drw_transform_rotate, METH_VARARGS | METH_KEYWORDS},
901
{"transform_rotate_simple", (PyCFunction)drw_transform_rotate_simple, METH_VARARGS | METH_KEYWORDS},
902
{"transform_rotate_default", (PyCFunction)drw_transform_rotate_default, METH_VARARGS | METH_KEYWORDS},
903
{"transform_scale", (PyCFunction)drw_transform_scale, METH_VARARGS | METH_KEYWORDS},
904
{"transform_scale_default", (PyCFunction)drw_transform_scale_default, METH_VARARGS | METH_KEYWORDS},
905
{"transform_shear", (PyCFunction)drw_transform_shear, METH_VARARGS | METH_KEYWORDS},
906
{"transform_shear_default", (PyCFunction)drw_transform_shear_default, METH_VARARGS | METH_KEYWORDS},
907
{"transform_2d", (PyCFunction)drw_transform_2d, METH_VARARGS | METH_KEYWORDS},
908
{"transform_2d_default", (PyCFunction)drw_transform_2d_default, METH_VARARGS | METH_KEYWORDS},
909
{"transform_matrix", (PyCFunction)drw_transform_matrix, METH_VARARGS | METH_KEYWORDS},
910
{"transform_matrix_default", (PyCFunction)drw_transform_matrix_default, METH_VARARGS | METH_KEYWORDS},
574
1323
if (!PyArg_ParseTuple(args, "i:remove_mask", &mode))
576
return PyInt_FromLong(gimp_layer_remove_mask(self->ID, mode));
1326
if (!gimp_layer_remove_mask(self->ID, mode)) {
1327
PyErr_Format(pygimp_error,
1328
"could not remove mask from layer (ID %d) with mode %d",
580
1338
static PyObject *
581
lay_resize(PyGimpLayer *self, PyObject *args)
1339
lay_resize(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
583
1341
unsigned int new_h, new_w;
585
if (!PyArg_ParseTuple(args, "iiii:resize", &new_w, &new_h,
588
gimp_layer_resize(self->ID, new_w, new_h, offs_x, offs_y);
595
lay_scale(PyGimpLayer *self, PyObject *args)
1342
int offs_x = 0, offs_y = 0;
1344
static char *kwlist[] = { "width", "height", "offset_x", "offset_y", NULL };
1346
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:resize", kwlist,
1347
&new_w, &new_h, &offs_x, &offs_y))
1350
if (!gimp_layer_resize(self->ID, new_w, new_h, offs_x, offs_y)) {
1351
PyErr_Format(pygimp_error,
1352
"could not resize layer (ID %d) to size %dx%d "
1354
self->ID, new_w, new_h, offs_x, offs_y);
1363
lay_resize_to_image_size(PyGimpLayer *self)
1365
if (!gimp_layer_resize_to_image_size(self->ID)) {
1366
PyErr_Format(pygimp_error,
1367
"could not resize layer (ID %d) to image size",
1377
lay_scale(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
597
1379
unsigned int new_w, new_h;
599
if (!PyArg_ParseTuple(args, "iii:scale", &new_w, &new_h,
602
gimp_layer_scale(self->ID, new_w, new_h, local_origin);
609
lay_translate(PyGimpLayer *self, PyObject *args)
612
if (!PyArg_ParseTuple(args, "ii:translate", &offs_x, &offs_y))
614
gimp_layer_translate(self->ID, offs_x, offs_y);
621
lay_set_offsets(PyGimpLayer *self, PyObject *args)
624
if (!PyArg_ParseTuple(args, "ii:set_offsets", &offs_x, &offs_y))
626
gimp_layer_set_offsets(self->ID, offs_x, offs_y);
1380
gboolean local_origin = FALSE;
1382
static char *kwlist[] = { "width", "height", "local_origin", NULL };
1384
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i:scale", kwlist,
1385
&new_w, &new_h, &local_origin))
1388
if (!gimp_layer_scale(self->ID, new_w, new_h, local_origin)) {
1389
PyErr_Format(pygimp_error,
1390
"could not scale layer (ID %d) to size %dx%d",
1391
self->ID, new_w, new_h);
1401
lay_translate(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
1405
static char *kwlist[] = { "offset_x", "offset_y", NULL };
1407
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:translate", kwlist,
1411
if (!gimp_layer_translate(self->ID, offs_x, offs_y)) {
1412
PyErr_Format(pygimp_error,
1413
"could not translate layer (ID %d) to offset %d, %d",
1414
self->ID, offs_x, offs_y);
1424
lay_set_offsets(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
1428
static char *kwlist[] = { "offset_x", "offset_y", NULL };
1430
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_offsets", kwlist,
1434
if (!gimp_layer_set_offsets(self->ID, offs_x, offs_y)) {
1435
PyErr_Format(pygimp_error,
1436
"could not set offset %d, %d on layer (ID %d)",
1437
offs_x, offs_y, self->ID);
627
1441
Py_INCREF(Py_None);
631
1445
static PyMethodDef lay_methods[] = {
632
{"copy", (PyCFunction)lay_copy, METH_VARARGS},
1446
{"copy", (PyCFunction)lay_copy, METH_VARARGS | METH_KEYWORDS},
633
1447
{"add_alpha", (PyCFunction)lay_add_alpha, METH_NOARGS},
634
1448
{"add_mask", (PyCFunction)lay_add_mask, METH_VARARGS},
635
1449
{"create_mask", (PyCFunction)lay_create_mask, METH_VARARGS},
636
1450
{"remove_mask", (PyCFunction)lay_remove_mask, METH_VARARGS},
637
{"resize", (PyCFunction)lay_resize, METH_VARARGS},
638
{"scale", (PyCFunction)lay_scale, METH_VARARGS},
639
{"translate", (PyCFunction)lay_translate, METH_VARARGS},
640
{"set_offsets", (PyCFunction)lay_set_offsets, METH_VARARGS},
1451
{"resize", (PyCFunction)lay_resize, METH_VARARGS | METH_KEYWORDS},
1452
{"resize_to_image_size", (PyCFunction)lay_resize_to_image_size, METH_NOARGS},
1453
{"scale", (PyCFunction)lay_scale, METH_VARARGS | METH_KEYWORDS},
1454
{"translate", (PyCFunction)lay_translate, METH_VARARGS | METH_KEYWORDS},
1455
{"set_offsets", (PyCFunction)lay_set_offsets, METH_VARARGS | METH_KEYWORDS},
641
1456
{NULL, NULL} /* sentinel */
644
1459
static PyObject *
645
1460
lay_get_is_floating_sel(PyGimpLayer *self, void *closure)
647
return PyInt_FromLong(gimp_layer_is_floating_sel(self->ID));
1462
return PyBool_FromLong(gimp_layer_is_floating_sel(self->ID));
650
1465
static PyObject *
651
1466
lay_get_mask(PyGimpLayer *self, void *closure)
653
1468
gint32 id = gimp_layer_get_mask(self->ID);
655
1471
Py_INCREF(Py_None);
658
1475
return pygimp_channel_new(id);
661
1478
static PyObject *
662
1479
lay_get_apply_mask(PyGimpLayer *self, void *closure)
664
return PyInt_FromLong(gimp_layer_get_apply_mask(self->ID));
1481
return PyBool_FromLong(gimp_layer_get_apply_mask(self->ID));