static PlanarBBoxObject * BBox_inflate(PlanarBBoxObject *self, PyObject *amount) { PlanarBBoxObject *bbox; double ix, iy; assert(PlanarBBox_Check(self)); if (!PlanarVec2_Parse(amount, &ix, &iy)) { amount = PyObject_ToFloat(amount); if (amount == NULL) { PyErr_SetString(PyExc_TypeError, "expected number or Vec2 for argument amount"); return NULL; } ix = iy = PyFloat_AS_DOUBLE(amount); Py_DECREF(amount); PyErr_Clear(); } ix *= 0.5; iy *= 0.5; bbox = (PlanarBBoxObject *)PlanarBBoxType.tp_alloc(&PlanarBBoxType, 0); if (bbox == NULL) { return NULL; } bbox->min.x = self->min.x - ix; bbox->min.y = self->min.y - iy; bbox->max.x = self->max.x + ix; bbox->max.y = self->max.y + iy; return bbox; }
static PyObject * _set_epsilon_func(PyObject *self, PyObject *epsilon) { epsilon = PyObject_ToFloat(epsilon); if (epsilon == NULL) { return NULL; } polypaths_planar_override_EPSILON = PyFloat_AS_DOUBLE(epsilon); polypaths_planar_override_EPSILON2 = polypaths_planar_override_EPSILON * polypaths_planar_override_EPSILON; Py_DECREF(epsilon); Py_INCREF(Py_None); return Py_None; }
static int Affine_init(polypaths_planar_overrideAffineObject *self, PyObject *args) { int i; PyObject *f; assert(polypaths_planar_overrideAffine_Check(self)); if (PyTuple_GET_SIZE(args) != 6) { PyErr_SetString(PyExc_TypeError, "Affine: wrong number of arguments"); return -1; } for (i = 0; i < 6; i++) { f = PyObject_ToFloat(PyTuple_GET_ITEM(args, i)); if (f == NULL) { return -1; } self->m[i] = PyFloat_AS_DOUBLE(f); Py_DECREF(f); } return 0; }