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


Python Pen.break_stroke方法代码示例

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


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

示例1: test_fuse_with_joint

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
def test_fuse_with_joint():
    p = Pen()
    p.stroke_mode(2.0)

    p.move_to((0, 0))
    p.turn_to(180)
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)

    p.break_stroke()

    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(5)

    assert_path_data(
        p, 0,
        [
            'M0,1 L0,-1 L-6,-1 L-6,5 L-4,5 L-4,1 L0,1 z',
            'M0,-1 L0,1 L5,1 L5,-1 L0,-1 z',
        ]
    )

    p.paper.join_paths()
    p.paper.fuse_paths()

    assert_path_data(
        p, 0,
        'M-6,5 L-4,5 L-4,1 L5,1 L5,-1 L-6,-1 L-6,5 z'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:33,代码来源:test_join_paths.py

示例2: test_join_paths_loop

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
def test_join_paths_loop():
    # Already looped paths should not be affected by join_paths.
    p = Pen()
    p.fill_mode()

    p.move_to((0, 0))
    p.square(2)

    target = 'M-1,1 L1,1 L1,-1 L-1,-1 L-1,1 z'
    assert_path_data(p, 0, target)
    p.paper.join_paths()
    assert_path_data(p, 0, target)

    # Loops can also be created by joining paths.
    p = Pen()
    p.fill_mode()

    p.move_to((0, 0))
    p.line_to((1, 0))
    p.line_to((1, 1))
    p.break_stroke()
    p.line_to((0, 1))
    p.line_to((0, 0))

    p.paper.join_paths()
    assert_path_data(
        p, 0,
        'M1,-1 L1,0 L0,0 L0,-1 L1,-1 z'
    )

    # The joins can get complicated.
    p = Pen()
    p.fill_mode()

    p.move_to((3, 0))
    p.line_to((2, 0))
    p.break_stroke()
    p.move_to((1, 0))
    p.line_to((2, 2))
    p.break_stroke()
    p.move_to((4, 0))
    p.line_to((3, 0))
    p.break_stroke()
    p.move_to((1, 0))
    p.line_to((2, 0))
    p.break_stroke()
    p.move_to((4, 0))
    p.line_to((2, 2))

    p.paper.join_paths()

    assert_path_data(
        p, 0,
        'M1,0 L2,-2 L4,0 L3,0 L2,0 L1,0 z',
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:57,代码来源:test_join_paths.py

示例3: test_join_paths_reference

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
def test_join_paths_reference():
    # Join paths in such a way that a single path object must be
    # used as both the "left" and "right" path in different joins.
    p = Pen()
    p.fill_mode()

    p.move_to((3, 0))
    p.line_to((2, 0))
    p.break_stroke()
    p.move_to((1, 0))
    p.line_to((0, 0))
    p.break_stroke()
    p.move_to((4, 0))
    p.line_to((3, 0))
    p.break_stroke()
    p.move_to((1, 0))
    p.line_to((2, 0))
    p.break_stroke()
    p.move_to((4, 0))
    p.line_to((5, 0))

    p.paper.join_paths()

    assert_path_data(
        p, 0,
        'M5,0 L4,0 L3,0 L2,0 L1,0 L0,0'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:29,代码来源:test_join_paths.py

示例4: test_join_paths_thick

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
def test_join_paths_thick():
    # Segments join together if possible when join_paths is called.
    p = Pen()
    p.stroke_mode(2.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(5)
    p.break_stroke()
    p.turn_left(90)
    p.line_forward(5)
    p.paper.join_paths()
    assert_path_data(
        p, 0,
        'M0,-1 L0,1 L6,1 L6,-5 L4,-5 L4,-1 L0,-1 z'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:17,代码来源:test_join_paths.py

示例5: test_join_paths_turn_back_no_joint

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
def test_join_paths_turn_back_no_joint():
    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.break_stroke()
    p.line_forward(5)
    p.paper.join_paths()

    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,代码行数:24,代码来源:test_join_paths.py

示例6: test_join_and_fuse_simple

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
def test_join_and_fuse_simple():
    # Create two halves of a stroke in separate directions.
    p = Pen()
    p.stroke_mode(sqrt2)

    p.move_to((0, 0))
    p.turn_to(-45)
    p.line_forward(3 * sqrt2, end_slant=0)

    p.break_stroke()

    p.move_to((0, 0))
    p.turn_to(-45 + 180)
    p.line_forward(3 * sqrt2, end_slant=0)

    p.paper.join_paths()
    p.paper.fuse_paths()

    assert_path_data(
        p, 1,
        'M2.0,3.0 L4.0,3.0 L-2.0,-3.0 L-4.0,-3.0 L2.0,3.0 z'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:24,代码来源:test_join_paths.py

示例7: test_join_paths

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
def test_join_paths():
    # Join two paths starting from the same point.
    p = Pen()
    p.fill_mode()

    p.move_to((1, 0))
    p.line_to((0, 0))
    p.break_stroke()
    p.move_to((1, 0))
    p.line_to((2, 0))

    p.paper.join_paths()

    assert_path_data(
        p, 0,
        'M0,0 L1,0 L2,0',
    )

    # Join two paths that end in the same point.
    p = Pen()
    p.fill_mode()

    p.move_to((1, 0))
    p.line_to((0, 0))
    p.break_stroke()
    p.move_to((2, 0))
    p.line_to((1, 0))

    p.paper.join_paths()

    assert_path_data(
        p, 0,
        'M0,0 L1,0 L2,0',
    )

    # Join three paths going left in normal order.
    p = Pen()
    p.fill_mode()

    p.move_to((3, 0))
    p.line_to((2, 0))
    p.break_stroke()
    p.move_to((2, 0))
    p.line_to((1, 0))
    p.break_stroke()
    p.move_to((1, 0))
    p.line_to((0, 0))

    p.paper.join_paths()

    assert_path_data(
        p, 0,
        'M3,0 L2,0 L1,0 L0,0',
    )

    # Join three paths going right in normal order.
    p = Pen()
    p.fill_mode()

    p.move_to((0, 0))
    p.line_to((1, 0))
    p.break_stroke()
    p.move_to((1, 0))
    p.line_to((2, 0))
    p.break_stroke()
    p.move_to((2, 0))
    p.line_to((3, 0))

    p.paper.join_paths()

    assert_path_data(
        p, 0,
        'M0,0 L1,0 L2,0 L3,0',
    )

    # Join three paths going left in reverse order.
    p = Pen()
    p.fill_mode()

    p.move_to((1, 0))
    p.line_to((0, 0))
    p.break_stroke()
    p.move_to((2, 0))
    p.line_to((1, 0))
    p.break_stroke()
    p.move_to((3, 0))
    p.line_to((2, 0))

    p.paper.join_paths()

    assert_path_data(
        p, 0,
        'M0,0 L1,0 L2,0 L3,0',
    )

    # Join three paths going right in reverse order.
    p = Pen()
    p.fill_mode()

    p.move_to((2, 0))
#.........这里部分代码省略.........
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:103,代码来源:test_join_paths.py

示例8: Pen

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import break_stroke [as 别名]
            continue
        else:
            point_occupancy[a] += 1

        b = random.choice(points)
        if point_occupancy[b] >= 2:
            continue
        else:
            point_occupancy[b] += 1

        yield a, b


if __name__ == '__main__':
    while True:
        p = Pen()
        p.stroke_mode(0.01)
        for a, b in gen_lines(200, 100):
            p.move_to(a)
            p.line_to(b)
            p.break_stroke()

        try:
            p.paper.join_paths()
        except AssertionError:
            print(p.log())
            break
        else:
            print(p.paper.format_svg(6, resolution=1000))
            break
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:32,代码来源:random_lines.py


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