~ubuntu-branches/debian/squeeze/python-imaging/squeeze

« back to all changes in this revision

Viewing changes to path.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-08-28 23:14:10 UTC
  • mfrom: (2.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20060828231410-lca9enmne3ecmkup
Tags: 1.1.5-11
* python-imaging-sane: Depend on python-numarray. Closes: #382190.
* Add dependencies on ${shlibs:Depends}, lost in -6. Closes: #378596.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * The Python Imaging Library.
3
 
 * $Id: //modules/pil/path.c#4 $
 
3
 * $Id: path.c 2079 2004-09-19 12:22:31Z fredrik $
4
4
 *
5
5
 * 2D path utilities
6
6
 *
14
14
 * 1999-01-10 fl   Fixed IndexError test for 1.5 (from Fred Drake)
15
15
 * 2000-10-12 fl   Added special cases for tuples and lists
16
16
 * 2002-10-27 fl   Added clipping boilerplate
 
17
 * 2004-09-19 fl   Added tolist(flat) variant
17
18
 *
18
19
 * notes:
19
20
 * FIXME: fill in remaining slots in the sequence api
25
26
 */
26
27
 
27
28
 
 
29
#include "Python.h"
 
30
 
28
31
#include <math.h>
29
32
 
30
 
#include "Python.h"
31
 
 
32
33
#if PY_VERSION_HEX < 0x01060000
33
34
#define PyObject_DEL(op) PyMem_DEL((op))
34
35
#endif
222
223
    int count;
223
224
    double *xy;
224
225
 
225
 
    if (PyArg_ParseTuple(args, "i", &count)) {
 
226
    if (PyArg_ParseTuple(args, "i:Path", &count)) {
226
227
 
227
228
        /* number of vertices */
228
229
        xy = malloc(2 * count * sizeof(double));
262
263
 
263
264
    double cityblock = 2.0;
264
265
 
265
 
    if (!PyArg_ParseTuple(args, "|d", &cityblock))
 
266
    if (!PyArg_ParseTuple(args, "|d:compact", &cityblock))
266
267
        return NULL;
267
268
 
268
269
    xy = self->xy;
309
310
    double *xy;
310
311
    double x0, y0, x1, y1;
311
312
 
 
313
    if (!PyArg_ParseTuple(args, ":getbbox"))
 
314
        return NULL;
 
315
 
312
316
    xy = self->xy;
313
317
 
314
318
    x0 = x1 = xy[0];
371
375
    double *xy;
372
376
    PyObject* function;
373
377
 
374
 
    if (!PyArg_ParseTuple(args, "O", &function))
 
378
    if (!PyArg_ParseTuple(args, "O:map", &function))
375
379
        return NULL;
376
380
 
377
381
    xy = self->xy;
425
429
    PyObject *list;
426
430
    int i;
427
431
 
428
 
    list = PyList_New(self->count);
 
432
    int flat = 0;
 
433
    if (!PyArg_ParseTuple(args, "|i:tolist", &flat))
 
434
        return NULL;
429
435
 
430
 
    for (i = 0; i < self->count; i++) {
431
 
        PyObject* item;
432
 
        item = Py_BuildValue("dd", self->xy[i+i], self->xy[i+i+1]);
433
 
        if (!item) {
434
 
            Py_DECREF(list);
435
 
            list = NULL;
436
 
            break;
437
 
        }
438
 
        PyList_SetItem(list, i, item);
 
436
    if (flat) {
 
437
        list = PyList_New(self->count*2);
 
438
        for (i = 0; i < self->count*2; i++) {
 
439
            PyObject* item;
 
440
            item = PyFloat_FromDouble(self->xy[i]);
 
441
            if (!item)
 
442
                goto error;
 
443
            PyList_SetItem(list, i, item);
 
444
        }
 
445
    } else {
 
446
        list = PyList_New(self->count);
 
447
        for (i = 0; i < self->count; i++) {
 
448
            PyObject* item;
 
449
            item = Py_BuildValue("dd", self->xy[i+i], self->xy[i+i+1]);
 
450
            if (!item)
 
451
                goto error;
 
452
            PyList_SetItem(list, i, item);
 
453
        }
439
454
    }
440
455
 
441
456
    return list;
 
457
 
 
458
error:
 
459
    Py_DECREF(list);
 
460
    return NULL;
442
461
}
443
462
 
444
463
static PyObject*
451
470
 
452
471
    double wrap = 0.0;
453
472
 
454
 
    if (!PyArg_ParseTuple(args, "(dddddd)|d",
 
473
    if (!PyArg_ParseTuple(args, "(dddddd)|d:transform",
455
474
                          &a, &b, &c, &d, &e, &f,
456
475
                          &wrap))
457
476
        return NULL;