Ejemplo n.º 1
0
 def test_cf1(self):
     nodes = [
         Point(122, 102),
         Point(35, 200),
         Point(228, 145),
         Point(190, 46)
     ]
     t = CurveFit._leftTangent(nodes)
     self.assertAlmostEqual(t.x, -0.663890062102)
     self.assertAlmostEqual(t.y, 0.747830184896)
     t = CurveFit._rightTangent(nodes)
     self.assertAlmostEqual(t.x, -0.3583470773350791)
     self.assertAlmostEqual(t.y, -0.9335884383203376)
Ejemplo n.º 2
0
    def fromPoints(self,
                   points,
                   error=50.0,
                   cornerTolerance=20.0,
                   maxSegments=20):
        """Fit a poly-bezier curve to the points given. This operation should be familiar
    from 'pencil' tools in a vector drawing application: the application samples points
    where your mouse pointer has been dragged, and then turns the sketch into a Bezier
    path. The goodness of fit can be controlled by tuning the `error` parameter. Corner
    detection can be controlled with `cornerTolerance`.

    Here are some points fit with `error=100.0`:

..  figure:: curvefit1.png
    :scale: 75 %
    :alt: curvefit1


    And with `error=10.0`:

..  figure:: curvefit2.png
    :scale: 75 %
    :alt: curvefit1

    """
        from beziers.utils.curvefitter import CurveFit
        segs = CurveFit.fitCurve(points, error, cornerTolerance, maxSegments)
        path = BezierPath()
        path.closed = False
        path.activeRepresentation = SegmentRepresentation(path, segs)
        return path
Ejemplo n.º 3
0
  def fromPoints(self, points, error = 50.0, cornerTolerance = 20.0, maxSegments = 20):
    """Fit a poly-bezier curve to the points given. This operation should be familiar
    from 'pencil' tools in a vector drawing application: the application samples points
    where your mouse pointer has been dragged, and then turns the sketch into a Bezier
    path. The goodness of fit can be controlled by tuning the `error` parameter. Corner
    detection can be controlled with `cornerTolerance`.

    Here are some points fit with `error=100.0`:

..  figure:: curvefit1.png
    :scale: 75 %
    :alt: curvefit1


    And with `error=10.0`:

..  figure:: curvefit2.png
    :scale: 75 %
    :alt: curvefit1

    """
    from beziers.utils.curvefitter import CurveFit
    segs = CurveFit.fitCurve(points, error, cornerTolerance, maxSegments)
    path = BezierPath()
    path.closed = False
    path.activeRepresentation = SegmentRepresentation(path,segs)
    return path