def to_svg_path(self): points = [ Point(x, 255 - y) for x, y in zip(self.points[::2], self.points[1::2]) ] commands = [SVGCommandMove(points[0])] + [ SVGCommandLine(p1, p2) for p1, p2 in zip(points[:-1], points[1:]) ] svg_path = SVGPath.from_commands(commands).path return svg_path
def to_svg_path(self): path_commands = [] for segment in self.children: if segment.is_curved: command = SVGCommandBezier(Point(*flip_vertical(segment.p1)), Point(*flip_vertical(segment.q1)), Point(*flip_vertical(segment.q2)), Point(*flip_vertical(segment.p2))) else: command = SVGCommandLine(Point(*flip_vertical(segment.p1)), Point(*flip_vertical(segment.p2))) path_commands.append(command) svg_path = SVGPath(path_commands) return svg_path
def _augment(svg, mean=False): dx, dy = (0, 0) if mean else (5 * random.random() - 2.5, 5 * random.random() - 2.5) factor = 0.7 if mean else 0.2 * random.random() + 0.6 return svg.zoom(factor).translate(Point(dx, dy))