def _convert_polyline_to_path(polyline): aspath = shape.Path(style=polyline.get_style()) points = [p.split(",") for p in polyline.get_points().split(" ")] aspath.appendMoveToPath(points[0][0], points[0][1], relative=False) for p in points[1:]: aspath.appendLineToPath(p[0], p[1], relative=False) return aspath
def _convert_line_to_path(line): aspath = shape.Path(style=line.get_style()) aspath.appendMoveToPath(float(line.get_x1()), float(line.get_y1()), relative=False) aspath.appendLineToPath(float(line.get_x2()), float(line.get_y2()), relative=False) return aspath
def _cubic_approx_ellipse(cx, cy, rx, ry): control_offsetx = rx * 0.55228 control_offsety = ry * 0.55228 aspath = shape.Path() aspath.appendMoveToPath(cx - rx, cy, relative=False) aspath.appendCubicCurveToPath(cx - rx, cy - control_offsety, cx - control_offsetx, cy - ry, cx, cy - ry, relative=False) aspath.appendCubicCurveToPath(cx + control_offsetx, cy - ry, cx + rx, cy - control_offsety, cx + rx, cy, relative=False) aspath.appendCubicCurveToPath(cx + rx, cy + control_offsety, cx + control_offsetx, cy + ry, cx, cy + ry, relative=False) aspath.appendCubicCurveToPath(cx - control_offsetx, cy + ry, cx - rx, cy + control_offsety, cx - rx, cy, relative=False) return aspath
def _convert_rect_to_path(rect): if not rect.get_x(): rect.set_x(0) if not rect.get_y(): rect.set_y(0) aspath = shape.Path(style=rect.get_style()) edgePoints = rect.getEdgePoints() aspath.appendMoveToPath( edgePoints[-1][0], edgePoints[-1][1], relative=False) for p in rect.getEdgePoints(): aspath.appendLineToPath(p[0], p[1], relative=False) return aspath