def test_calcCubicBounds(): assert calcCubicBounds((0, 0), (25, 100), (75, 100), (100, 0)) == ((0, 0, 100, 75.0)) assert calcCubicBounds((0, 0), (50, 0), (100, 50), (100, 100)) == (0.0, 0.0, 100, 100) assert calcCubicBounds((50, 0), (0, 100), (100, 100), (50, 0)) == pytest.approx( (35.566243, 0.000000, 64.433757, 75.000000))
def test_calcCubicBounds(): assert calcCubicBounds( (0, 0), (25, 100), (75, 100), (100, 0)) == ((0, 0, 100, 75.0)) assert calcCubicBounds( (0, 0), (50, 0), (100, 50), (100, 100)) == (0.0, 0.0, 100, 100) assert calcCubicBounds( (50, 0), (0, 100), (100, 100), (50, 0) ) == pytest.approx((35.566243, 0.000000, 64.433757, 75.000000))
def _curveToOne(self, bcp1, bcp2, pt): bounds = self.bounds bounds = updateBounds(bounds, pt) if not pointInRect(bcp1, bounds) or not pointInRect(bcp2, bounds): bounds = unionRect(bounds, calcCubicBounds( self._getCurrentPoint(), bcp1, bcp2, pt)) self.bounds = bounds
def _curveToOne(self, bcp1, bcp2, pt): bounds = self.bounds bounds = updateBounds(bounds, pt) if not pointInRect(bcp1, bounds) or not pointInRect(bcp2, bounds): bounds = unionRect(bounds, calcCubicBounds( self._getCurrentPoint(), bcp1, bcp2, pt)) self.bounds = bounds
for i in range(c): arrayTools.pointsInRect( [pt1, pt2, pt3, pt1, pt2, pt3, pt1, pt2, pt3, pt1, pt2, pt3, pt4], rect) print time.time() - n print "calcQuadraticBounds\t\t", n = time.time() for i in range(c): bezierTools.calcQuadraticBounds(pt1, pt2, pt3) print time.time() - n print "calcCubicBounds\t\t\t", n = time.time() for i in range(c): bezierTools.calcCubicBounds(pt1, pt2, pt3, pt4) print time.time() - n print ############## print "no-numpy" print "calcQuadraticParameters\t\t", n = time.time() for i in range(c): noNumpyBezierTools.calcQuadraticParameters(pt1, pt2, pt3) print time.time() - n print "calcBounds\t\t\t", n = time.time() for i in range(c):
print "pointsInRect\t\t\t", n = time.time() for i in range(c): arrayTools.pointsInRect([pt1, pt2, pt3, pt1, pt2, pt3, pt1, pt2, pt3, pt1, pt2, pt3, pt4], rect) print time.time() - n print "calcQuadraticBounds\t\t", n = time.time() for i in range(c): bezierTools.calcQuadraticBounds(pt1, pt2, pt3) print time.time() - n print "calcCubicBounds\t\t\t", n = time.time() for i in range(c): bezierTools.calcCubicBounds(pt1, pt2, pt3, pt4) print time.time() - n print ############## print "no-numpy" print "calcQuadraticParameters\t\t", n = time.time() for i in range(c): noNumpyBezierTools.calcQuadraticParameters(pt1, pt2, pt3) print time.time() - n print "calcBounds\t\t\t", n = time.time() for i in range(c):