コード例 #1
0
def test_splitQuadratic():
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=150,
        isHorizontal=False) == [((0, 0), (50, 100), (100, 0))]
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=50,
        isHorizontal=False) == [((0, 0), (25, 50), (50, 50)),
                                ((50, 50), (75, 50), (100, 0))]
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=25,
        isHorizontal=False) == [((0, 0), (12.5, 25), (25, 37.5)),
                                ((25, 37.5), (62.5, 75), (100, 0))]
    assert_curves_approx_equal(
        splitQuadratic((0, 0), (50, 100), (100, 0),
                       where=25,
                       isHorizontal=True),
        [((0, 0), (7.32233, 14.64466), (14.64466, 25)),
         ((14.64466, 25), (50, 75), (85.3553, 25)),
         ((85.3553, 25), (92.6777, 14.64466), (100, -7.10543e-15))])
    # XXX I'm not at all sure if the following behavior is desirable
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=50,
        isHorizontal=True) == [((0, 0), (25, 50), (50, 50)),
                               ((50, 50), (50, 50), (50, 50)),
                               ((50, 50), (75, 50), (100, 0))]
コード例 #2
0
def test_splitQuadratic():
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=150, isHorizontal=False
    ) == [((0, 0), (50, 100), (100, 0))]
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=50, isHorizontal=False
    ) == [((0, 0), (25, 50), (50, 50)),
          ((50, 50), (75, 50), (100, 0))]
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=25, isHorizontal=False
    ) == [((0, 0), (12.5, 25), (25, 37.5)),
          ((25, 37.5), (62.5, 75), (100, 0))]
    assert_curves_approx_equal(
        splitQuadratic(
            (0, 0), (50, 100), (100, 0), where=25, isHorizontal=True),
        [((0, 0), (7.32233, 14.64466), (14.64466, 25)),
         ((14.64466, 25), (50, 75), (85.3553, 25)),
         ((85.3553, 25), (92.6777, 14.64466), (100, -7.10543e-15))])
    # XXX I'm not at all sure if the following behavior is desirable
    assert splitQuadratic(
        (0, 0), (50, 100), (100, 0), where=50, isHorizontal=True
    ) == [((0, 0), (25, 50), (50, 50)),
          ((50, 50), (50, 50), (50, 50)),
          ((50, 50), (75, 50), (100, 0))]