-// global color allocator/deallocator
-typedef struct RGB {
- PyObject_HEAD
- int screen;
- int r, g, b;
-} RGB;
-
-static void rgb_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-static int rgb_compare(PyObject *py1, PyObject *py2)
-{
- long result;
- unsigned long p1, p2;
- RGB *r1, *r2;
-
- r1 = (RGB*) r1;
- r2 = (RGB*) r2;
- p1 = (r1->screen << 24 | r1->r << 16 | r1->g << 8 | r1->b) & 0x00ffffff;
- p2 = (r2->screen << 24 | r2->r << 16 | r2->g << 8 | r2->b) & 0x00ffffff;
-
- if (p1 < p2)
- result = -1;
- else if (p1 > p2)
- result = 1;
- else
- result = 0;
- return result;
-}
-
-static PyTypeObject RGB_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "RGB",
- sizeof(RGB),
- 0,
- rgb_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- rgb_compare, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-static PyObject *RGB_New(int screen, int r, int g, int b) {
- RGB *self = (RGB*) PyObject_New(RGB, &RGB_Type);
- self->screen = screen;
- self->r = r;
- self->g = g;
- self->b = b;
- return (PyObject*)self;
-}
-
-typedef struct PixelRef {
- unsigned long p;
- unsigned int count;
-} PixelRef;
-
-static PixelRef *PixelRef_New(unsigned long p) {
- PixelRef* self = malloc(sizeof(PixelRef));
- self->p = p;
- self->count = 1;
- return self;
-}
-
-static void OtkColor_ParseColorName(OtkColor *self) {