def __init__(self, ctx): ctx.set_fill_rule(FILL_RULE_EVEN_ODD) self._gtk_ctx = ctx self._gstack = [] self._state = GState() GCanvas.__init__(self) GCanvasPaths.__init__(self)
def __init__(self): self._ns_path = NSBezierPath.bezierPath() self._ns_path.setWindingRule_(NSEvenOddWindingRule) self._stack = [] ctx = NSGraphicsContext.currentContext() ctx.setCompositingOperation_(NSCompositeSourceOver) GCanvas.__init__(self) self._printing = not ctx.isDrawingToScreen() self.initgraphics()
def lines(self, points): # Due to a memory leak in PyObjC 2.3, we need to be very careful # about the type of object that we pass to appendBezierPathWithPoints_count_. # If 'points' is a numpy array, we convert it to an array.array of type 'f', # else we fall back on iterating over the points in Python. # ns = self._ns_path # ns.moveToPoint_(points[0]) # ns.appendBezierPathWithPoints_count_(points, len(points)) try: p = points.flat except AttributeError: GCanvas.lines(self, points) else: a = array('f', p) ns = self._ns_path ns.moveToPoint_(points[0]) ns.appendBezierPathWithPoints_count_(a, len(points))