mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Both kinds of bounding box for arc, chord and pieslice.
This commit is contained in:
parent
8f92562ec3
commit
ae37743ac7
|
@ -62,7 +62,7 @@ def helper_arc(bbox):
|
|||
|
||||
|
||||
def test_arc1():
|
||||
assert_exception(TypeError, lambda: helper_arc(bbox1))
|
||||
helper_arc(bbox1)
|
||||
|
||||
|
||||
def test_arc2():
|
||||
|
@ -97,7 +97,7 @@ def helper_chord(bbox):
|
|||
|
||||
|
||||
def test_chord1():
|
||||
assert_exception(TypeError, lambda: helper_chord(bbox1))
|
||||
helper_chord(bbox1)
|
||||
|
||||
|
||||
def test_chord2():
|
||||
|
@ -160,7 +160,7 @@ def helper_pieslice(bbox):
|
|||
|
||||
|
||||
def test_pieslice1():
|
||||
assert_exception(TypeError, lambda: helper_pieslice(bbox1))
|
||||
helper_pieslice(bbox1)
|
||||
|
||||
|
||||
def test_pieslice2():
|
||||
|
|
89
_imaging.c
89
_imaging.c
|
@ -2399,17 +2399,35 @@ _draw_ink(ImagingDrawObject* self, PyObject* args)
|
|||
static PyObject*
|
||||
_draw_arc(ImagingDrawObject* self, PyObject* args)
|
||||
{
|
||||
int x0, y0, x1, y1;
|
||||
double* xy;
|
||||
int n;
|
||||
|
||||
PyObject* data;
|
||||
int ink;
|
||||
int start, end;
|
||||
int op = 0;
|
||||
if (!PyArg_ParseTuple(args, "(iiii)iii|i",
|
||||
&x0, &y0, &x1, &y1,
|
||||
&start, &end, &ink))
|
||||
if (!PyArg_ParseTuple(args, "Oiii|i", &data, &start, &end, &ink))
|
||||
return NULL;
|
||||
|
||||
if (ImagingDrawArc(self->image->image, x0, y0, x1, y1, start, end,
|
||||
&ink, op) < 0)
|
||||
n = PyPath_Flatten(data, &xy);
|
||||
if (n < 0)
|
||||
return NULL;
|
||||
if (n != 2) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"coordinate list must contain exactly 2 coordinates"
|
||||
);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
n = ImagingDrawArc(self->image->image,
|
||||
(int) xy[0], (int) xy[1],
|
||||
(int) xy[2], (int) xy[3],
|
||||
start, end, &ink, op
|
||||
);
|
||||
|
||||
free(xy);
|
||||
|
||||
if (n < 0)
|
||||
return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -2455,15 +2473,35 @@ _draw_bitmap(ImagingDrawObject* self, PyObject* args)
|
|||
static PyObject*
|
||||
_draw_chord(ImagingDrawObject* self, PyObject* args)
|
||||
{
|
||||
int x0, y0, x1, y1;
|
||||
double* xy;
|
||||
int n;
|
||||
|
||||
PyObject* data;
|
||||
int ink, fill;
|
||||
int start, end;
|
||||
if (!PyArg_ParseTuple(args, "(iiii)iiii",
|
||||
&x0, &y0, &x1, &y1, &start, &end, &ink, &fill))
|
||||
if (!PyArg_ParseTuple(args, "Oiiii",
|
||||
&data, &start, &end, &ink, &fill))
|
||||
return NULL;
|
||||
|
||||
if (ImagingDrawChord(self->image->image, x0, y0, x1, y1,
|
||||
start, end, &ink, fill, self->blend) < 0)
|
||||
n = PyPath_Flatten(data, &xy);
|
||||
if (n < 0)
|
||||
return NULL;
|
||||
if (n != 2) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"coordinate list must contain exactly 2 coordinates"
|
||||
);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
n = ImagingDrawChord(self->image->image,
|
||||
(int) xy[0], (int) xy[1],
|
||||
(int) xy[2], (int) xy[3],
|
||||
start, end, &ink, fill, self->blend
|
||||
);
|
||||
|
||||
free(xy);
|
||||
|
||||
if (n < 0)
|
||||
return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -2656,15 +2694,34 @@ _draw_outline(ImagingDrawObject* self, PyObject* args)
|
|||
static PyObject*
|
||||
_draw_pieslice(ImagingDrawObject* self, PyObject* args)
|
||||
{
|
||||
int x0, y0, x1, y1;
|
||||
double* xy;
|
||||
int n;
|
||||
|
||||
PyObject* data;
|
||||
int ink, fill;
|
||||
int start, end;
|
||||
if (!PyArg_ParseTuple(args, "(iiii)iiii",
|
||||
&x0, &y0, &x1, &y1, &start, &end, &ink, &fill))
|
||||
if (!PyArg_ParseTuple(args, "Oiiii", &data, &start, &end, &ink, &fill))
|
||||
return NULL;
|
||||
|
||||
if (ImagingDrawPieslice(self->image->image, x0, y0, x1, y1,
|
||||
start, end, &ink, fill, self->blend) < 0)
|
||||
n = PyPath_Flatten(data, &xy);
|
||||
if (n < 0)
|
||||
return NULL;
|
||||
if (n != 2) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"coordinate list must contain exactly 2 coordinates"
|
||||
);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
n = ImagingDrawPieslice(self->image->image,
|
||||
(int) xy[0], (int) xy[1],
|
||||
(int) xy[2], (int) xy[3],
|
||||
start, end, &ink, fill, self->blend
|
||||
);
|
||||
|
||||
free(xy);
|
||||
|
||||
if (n < 0)
|
||||
return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
|
|
Loading…
Reference in New Issue
Block a user