当前位置: 首页>>代码示例>>Python>>正文


Python Pen.last_path方法代码示例

本文整理汇总了Python中canoepaddle.pen.Pen.last_path方法的典型用法代码示例。如果您正苦于以下问题:Python Pen.last_path方法的具体用法?Python Pen.last_path怎么用?Python Pen.last_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在canoepaddle.pen.Pen的用法示例。


在下文中一共展示了Pen.last_path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_arc_no_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_path [as 别名]
def test_arc_no_joint():
    # Try to create an impossible joint between arcs of different widths.
    # It doesn't join.
    p = Pen()
    p.move_to((0, -5))
    p.turn_to(0)

    p.stroke_mode(1.0)
    p.arc_to((5, 0), center=(0, 0))
    p.stroke_mode(2.0)
    p.arc_to((0, 5), center=(0, 0))

    arc1, arc2 = p.last_path().segments
    assert arc1.end_joint_illegal
    assert arc2.start_joint_illegal

    assert_path_data(
        p, 1,
        (
            'M0.0,4.5 L0.0,5.5 A 5.5,5.5 0 0 0 5.5,0.0 L6.0,0.0 '
            'A 6.0,6.0 0 0 0 0.0,-6.0 L0.0,-4.0 '
            'A 4.0,4.0 0 0 1 4.0,0.0 L4.5,0.0 '
            'A 4.5,4.5 0 0 1 0.0,4.5 z'
        )
    )

    # Join two arcs together illegally, but don't make them concentric.
    p = Pen()
    p.move_to((0, -5))
    p.turn_to(0)

    p.stroke_mode(1.0)
    p.arc_to((5, 0), center=(0, 0))
    p.stroke_mode(2.0)
    p.arc_to((0, 5), center=(0, 0.1))

    arc1, arc2 = p.last_path().segments
    assert arc1.end_joint_illegal
    assert arc2.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M0.00,4.50 L0.00,5.50 A 5.50,5.50 0 0 0 5.50,0.00 L6.00,0.02 '
            'A 6.00,6.00 0 0 0 0.00,-6.10 L0.00,-4.10 '
            'A 4.00,4.00 0 0 1 4.00,-0.02 L4.50,0.00 '
            'A 4.50,4.50 0 0 1 0.00,4.50 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:51,代码来源:test_segment.py

示例2: test_line_segments

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_path [as 别名]
def test_line_segments():
    p = Pen()
    p.fill_mode()

    p.move_to((0, 0))
    p.turn_to(45)
    p.line_forward(2.0)

    assert_points_equal(p.position, (sqrt2, sqrt2))
    assert_equal(len(p.paper.paths), 1)
    segments = p.last_path().segments
    for actual, target in zip(segments, [
        ((0, 0), (sqrt2, sqrt2)),
    ]):
        assert_segments_equal(actual, target)
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:17,代码来源:test_segment.py

示例3: test_turn_back_no_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_path [as 别名]
def test_turn_back_no_joint():
    # Make a line turn back on itself, and it doesn't join.
    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(10)
    p.turn_right(180)
    p.line_forward(5)

    line1, line2 = p.last_path().segments
    assert line1.end_joint_illegal
    assert line2.start_joint_illegal

    assert_path_data(
        p, 1,
        (
            'M0.0,-0.5 L0.0,0.5 L10.0,0.5 L10.0,-0.5 '
            'L5.0,-0.5 L5.0,0.5 L10.0,0.5 L10.0,-0.5 L0.0,-0.5 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:23,代码来源:test_segment.py

示例4: test_straight_offwidth_no_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_path [as 别名]
def test_straight_offwidth_no_joint():
    p = Pen()
    p.move_to((0, 0))
    p.turn_to(0)

    p.stroke_mode(2.0)
    p.line_forward(3)
    p.stroke_mode(1.0)
    p.line_forward(3)

    line1, line2 = p.last_path().segments
    assert line1.end_joint_illegal
    assert line2.start_joint_illegal

    assert_path_data(
        p, 1,
        (
            'M0.0,-1.0 L0.0,1.0 L3.0,1.0 L3.0,0.5 L6.0,0.5 '
            'L6.0,-0.5 L3.0,-0.5 L3.0,-1.0 L0.0,-1.0 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:23,代码来源:test_segment.py

示例5: test_arc_line_half_illegal_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_path [as 别名]
def test_arc_line_half_illegal_joint():
    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.line_to((1, 0))
    p.turn_to(180 - 15)
    p.arc_to((-1, 0))

    line, arc = p.last_path().segments
    assert line.end_joint_illegal
    assert arc.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M0.00,-0.50 L0.00,0.50 L2.93,0.50 '
            'A 4.36,4.36 0 0 0 -1.13,-0.48 L-0.87,0.48 '
            'A 3.36,3.36 0 0 1 0.87,0.48 L1.00,-0.50 L0.00,-0.50 z'
        )
    )

    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((-1, 0))
    p.turn_to(15)
    p.arc_to((1, 0))
    p.line_to((0, 0))

    arc, line = p.paper.paths[0].segments
    assert arc.end_joint_illegal
    assert line.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M-1.13,-0.48 L-0.87,0.48 A 3.36,3.36 0 0 1 0.87,0.48 '
            'L1.00,-0.50 L0.00,-0.50 L0.00,0.50 L2.93,0.50 '
            'A 4.36,4.36 0 0 0 -1.13,-0.48 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:42,代码来源:test_segment.py

示例6: test_arc_arc_half_illegal_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_path [as 别名]
def test_arc_arc_half_illegal_joint():
    p = Pen()
    p.move_to((0, -5))
    p.turn_to(0)

    p.stroke_mode(1.0)
    p.arc_to((5, 0), center=(0, 0))
    p.stroke_mode(2.0)
    p.arc_to((10, 5), center=(10, 0))

    arc1, arc2 = p.last_path().segments
    assert arc1.end_joint_illegal
    assert arc2.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M0.00,4.50 L0.00,5.50 A 5.50,5.50 0 0 0 5.50,0.00 L6.00,0.00 '
            'A 4.00,4.00 0 0 1 10.00,-4.00 L10.00,-6.00 '
            'A 6.00,6.00 0 0 0 4.21,1.58 '
            'A 4.50,4.50 0 0 1 0.00,4.50 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:25,代码来源:test_segment.py

示例7: test_too_sharp_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_path [as 别名]
def test_too_sharp_joint():
    # Joint is considered too sharp, so the joint is not made.
    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(10)
    p.turn_left(175)
    p.line_forward(10)

    line1, line2 = p.last_path().segments
    assert line1.end_joint_illegal
    assert line2.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M0.00,-0.50 L0.00,0.50 L10.00,0.50 L10.04,-0.50 L0.08,-1.37 '
            'L-0.01,-0.37 L9.96,0.50 L10.00,-0.50 L0.00,-0.50 z'
        )
    )

    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(10)
    p.turn_right(175)
    p.line_forward(10)

    line1, line2 = p.last_path().segments
    assert line1.end_joint_illegal
    assert line2.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M0.00,-0.50 L0.00,0.50 L10.00,0.50 L9.96,-0.50 L-0.01,0.37 '
            'L0.08,1.37 L10.04,0.50 L10.00,-0.50 L0.00,-0.50 z'
        )
    )

    # Joint is considered too sharp, so the outside is not drawn, but the
    # inside joint works.
    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(20)
    p.turn_left(175)
    p.line_forward(20)

    line1, line2 = p.last_path().segments
    assert line1.end_joint_illegal
    assert line2.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M0.00,-0.50 L0.00,0.50 L20.00,0.50 L20.04,-0.50 '
            'L0.12,-2.24 L0.03,-1.25 L8.55,-0.50 L0.00,-0.50 z'
        )
    )

    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(20)
    p.turn_right(175)
    p.line_forward(20)

    line1, line2 = p.last_path().segments
    assert line1.end_joint_illegal
    assert line2.start_joint_illegal

    assert_path_data(
        p, 2,
        (
            'M0.00,-0.50 L0.00,0.50 L8.55,0.50 L0.03,1.25 '
            'L0.12,2.24 L20.04,0.50 L20.00,-0.50 L0.00,-0.50 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:85,代码来源:test_segment.py


注:本文中的canoepaddle.pen.Pen.last_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。