hexagram/py/hexagram/cluster_c.pyx

41 lines
1 KiB
Cython

from cpython.ref cimport PyObject, PyTypeObject, Py_INCREF
from hexagram.cluster import Cluster
cdef extern from "linux/can.h":
cdef struct can_frame:
pass
cdef extern from "cairo.h":
ctypedef struct cairo_t:
pass
cdef extern from "py3cairo.h":
cdef PyObject *PycairoContext_FromContext(cairo_t *ctx, PyTypeObject *type, PyObject *base)
ctypedef struct Pycairo_CAPI_t:
pass
cdef extern Pycairo_CAPI_t *Pycairo_CAPI
cdef extern from *:
"""
#define ctx_type (Pycairo_CAPI->Context_Type)
"""
cdef extern PyTypeObject *ctx_type
cdef class hexagram_cluster_py:
cdef object _obj
def __cinit__(self, double rpm_min, double rpm_redline, double rpm_max):
self._obj = <object>Cluster(rpm_min, rpm_redline, rpm_max)
cdef draw_bg(self, cairo_t *cr):
ctx = <object>PycairoContext_FromContext(cr, ctx_type, NULL)
self._obj.draw_bg(ctx)
cdef draw_fg(self, cairo_t *cr):
ctx = <object>PycairoContext_FromContext(cr, ctx_type, NULL)
self._obj.draw_fg(ctx)