def CreateQuadraticSpline(self, controlPoints): path = self.CreatePath() if len(controlPoints) != 3: raise ValueError('controlPoints needs to be of length 3, got %d' % len(controlPoints)) path.MoveToPoint(controlPoints[0][0], controlPoints[0][1]) path.AddQuadCurveToPoint(controlPoints[1][0], controlPoints[1][1], controlPoints[2][0], controlPoints[2][1]) return GCRenderObjectPath(self, path)
def CreateLinesList(self, lines_list, close=False): path = self.CreatePath() for line in lines_list: points = line if len(points) > 0: path.MoveToPoint(points[0][0], points[0][1]) for pnt in points[1:]: path.AddLineToPoint(pnt[0], pnt[1]) if close: path.CloseSubpath() return GCRenderObjectPath(self, path)
def CreateCompositeRenderObject(self, subobjects): # if all subobjects are path object, then merge the pathes into one for subobject in subobjects: if not isinstance(subobject, GCRenderObjectPath): raise ValueError( 'All composite subobjects must be path objects!') path = self.CreatePath() for subobject in subobjects: path.AddPath(subobject.path.path) return GCRenderObjectPath(self, path)
def CreateLineSegmentsSeparate(self, startPoints, endPoints): path = self.CreatePath() if len(startPoints) != len(endPoints): raise ValueError( 'number of start and end points must be equal (%s %s)' % (startPoints, endPoints)) for startPoint, endPoint in zip(startPoints, endPoints): path.MoveToPoint(startPoint[0], startPoint[1]) path.AddLineToPoint(endPoint[0], endPoint[1]) return GCRenderObjectPath(self, path)
def CreateCircularArc(self, center, radius, startAngle, endAngle, clockwise): path = self.CreatePath() path.AddArc(center[0], center[1], radius, startAngle, endAngle, clockwise) return GCRenderObjectPath(self, path)
def CreateEllipse(self, corner, size): path = self.CreatePath() path.AddEllipse(corner[0], corner[1], size[0], size[1]) return GCRenderObjectPath(self, path)
def CreateRoundedRectangle(self, corner, size, radius): path = self.CreatePath() path.AddRoundedRectangle(corner[0], corner[1], size[0], size[1], radius) return GCRenderObjectPath(self, path)