How to use the svgpathtools.CubicBezier function in svgpathtools

To help you get started, we’ve selected a few svgpathtools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yangyanli / PointCNN / data_conversions / prepare_tu_berlin_data.py View on Github external
x, y = p[idx]
            q[idx] = (x + random.gauss(0, x_range), y + y_range * random.gauss(0, y_range))

        path_deformed = Path()
        for segment in path:
            points = []
            for v in segment.bpoints():
                real, imag = moving_least_square_with_rigid_transformation(p, q, np.array([v.real, v.imag]),
                                                                           max(x_range, y_range))
                point_xformed = complex(real, imag)
                points.append(point_xformed)
            if len(segment.bpoints()) == 2:
                line = Line(points[0], points[1])
                path_deformed.append(line)
            else:
                cubic_bezier = CubicBezier(points[0], points[1], points[2], points[3])
                path_deformed.append(cubic_bezier)

        path_list.append(path_deformed)

    return path_list
github ipfs-shipyard / ipfs-ui-style-guide / fonts / inter / misc / svgsync2.py View on Github external
currentPos = 0j
    controlPoints = []

    for x in range(len(points)):
      p = points[x]
      # print 'p#' + str(x) + '.type = ' + repr(p.type)

      if p.type == 'move':
        currentPos = vec2(p.x, (p.y + yOffs) * yMul)
      elif p.type == 'offcurve':
        controlPoints.append(p)
      elif p.type == 'curve':
        pos = vec2(p.x, (p.y + yOffs) * yMul)
        if len(controlPoints) == 2:
          cp1, cp2 = controlPoints
          path.append(CubicBezier(
            currentPos,
            vec2(cp1.x, (cp1.y + yOffs) * yMul),
            vec2(cp2.x, (cp2.y + yOffs) * yMul),
            pos))
        else:
          if len(controlPoints) != 1:
            raise Exception('unexpected number of control points for curve')
          cp = controlPoints[0]
          path.append(QuadraticBezier(currentPos, vec2(cp.x, (cp.y + yOffs) * yMul), pos))
        currentPos = pos
        controlPoints = []
      elif p.type == 'line':
        pos = vec2(p.x, (p.y + yOffs) * yMul)
        path.append(Line(currentPos, pos))
        currentPos = pos