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


Python Pen.line_to方法代码示例

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


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

示例1: test_join_paths_reference

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import line_to [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

示例2: test_two_pens_one_paper

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import line_to [as 别名]
def test_two_pens_one_paper():
    paper = Paper()
    p1 = Pen(paper)
    p2 = Pen(paper)
    p1.fill_mode()
    p2.fill_mode()
    p1.move_to((0, 0))
    p2.move_to((0, 0))
    p1.line_to((0, 1))
    p2.line_to((2, 0))

    assert_path_data(
        paper, 0,
        ['M0,0 L0,-1', 'M0,0 L2,0']
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:17,代码来源:test_paper.py

示例3: test_line_segment_bounds

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import line_to [as 别名]
def test_line_segment_bounds():
    # Fill mode segment.
    p = Pen()
    p.fill_mode()
    p.move_to((1, 0))
    p.line_to((2, 3))

    line = p.last_segment()
    assert_equal(
        line.bounds(),
        Bounds(1, 0, 2, 3)
    )

    # Stroke mode segment.
    p = Pen()
    p.stroke_mode(sqrt2)
    p.move_to((0, 0))
    p.line_to((5, 5))

    line = p.last_segment()
    assert_equal(
        line.bounds(),
        Bounds(-0.5, -0.5, 5.5, 5.5)
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:26,代码来源:test_bounds.py

示例4: test_join_paths

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import line_to [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

示例5: test_join_paths_loop

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import line_to [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

示例6: Pen

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import line_to [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

示例7: draw

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import line_to [as 别名]
def draw():

    p = Pen()

    center_radius = 3.0
    start_radius = radius = 100
    start_width = width = 3.0
    ratio = (1 / 2) ** (1/5)


    series = []
    while radius > center_radius / sqrt2:
        series.append((radius, width))
        radius *= ratio
        width *= ratio

    p.move_to((0, 0))
    for radius, width in series:
        p.stroke_mode(width, 'black')
        p.circle(radius)

    # Parametric conic spirals.
    p.move_to((0, 0))

    def spiral(theta):
        b = (1 / 2) ** (-2 / math.pi)
        r = start_radius * (b ** (-theta))
        x = r * math.cos(theta)
        y = r * math.sin(theta)
        z = start_radius - r
        return (x, y, z)

    def spiral_top1(t):
        x, y, z = spiral(t)
        return x, y

    def spiral_top2(t):
        x, y, z = spiral(t)
        x = -x
        y = -y
        return x, y

    # Top spirals.
    p.stroke_mode(start_width, 'black')
    p.parametric(spiral_top1, 0, 4*math.pi, .1)
    p.parametric(spiral_top2, 0, 4*math.pi, .1)

    # Blank out the bottom triangle.
    p.fill_mode('white')
    p.move_to((0, 0))
    s = start_radius + start_width
    p.line_to((-s, -s))
    p.line_to((+s, -s))
    p.line_to((0, 0))

    # Horizontal lines for the bottom triangle.
    for radius, width in series:
        p.stroke_mode(width, 'black')
        p.move_to((-radius, -radius))
        p.line_to(
            (+radius, -radius),
            start_slant=45,
            end_slant=-45,
        )

    # Front spirals.
    def spiral_front1(t):
        x, y, z = spiral(t)
        return (x, z - start_radius)

    def spiral_front2(t):
        x, y, z = spiral(t)
        x = -x
        y = -y
        return (x, z - start_radius)

    p.move_to((0, 0))
    p.stroke_mode(start_width, 'black')
    p.parametric(spiral_front1, 0, math.pi, .1)
    p.parametric(spiral_front2, math.pi, 2*math.pi, .1)
    p.parametric(spiral_front1, 2*math.pi, 3*math.pi, .1)

    # Fill in the center.
    p.move_to((0, 0))
    p.fill_mode('black')
    p.circle(center_radius)

    return p.paper
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:90,代码来源:mountain.py


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