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


Python Pen.arc_left方法代码示例

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


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

示例1: test_translate

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

    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(3)
    p.arc_left(90, 3)
    p.turn_left(90)
    p.move_forward(3)
    p.fill_mode()
    p.circle(0.5)
    p.move_forward(3)
    p.square(1)

    p.paper.translate((1, 1))

    assert_equal(
        p.paper.svg_elements(1),
        [
            (
                '<path d="M1.0,-1.5 L1.0,-0.5 L4.0,-0.5 A 3.5,3.5 0 0 0 '
                '7.5,-4.0 L6.5,-4.0 A 2.5,2.5 0 0 1 4.0,-1.5 L1.0,-1.5 z" '
                'fill="#000000" />'
            ),
            (
                '<path d="M4.5,-4.0 A 0.5,0.5 0 0 0 3.5,-4.0 '
                'A 0.5,0.5 0 0 0 4.5,-4.0 z" fill="#000000" />'
            ),
            (
                '<path d="M0.5,-3.5 L1.5,-3.5 L1.5,-4.5 L0.5,-4.5 L0.5,-3.5 z" '
                'fill="#000000" />'
            ),
        ]
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:37,代码来源:test_paper.py

示例2: test_paper_merge

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import arc_left [as 别名]
def test_paper_merge():
    # Merge two drawings together.
    paper = Paper()

    p = Pen()
    p.fill_mode()
    p.turn_to(0)
    p.arc_left(180, 5)
    p.paper.center_on_x(0)
    paper.merge(p.paper)

    p = Pen()
    p.fill_mode()
    p.turn_to(180)
    p.arc_left(180, 5)
    p.paper.center_on_x(0)
    paper.merge(p.paper)

    assert_path_data(
        paper, 1,
        [
            'M-2.5,0.0 A 5.0,5.0 0 0 0 -2.5,-10.0',
            'M2.5,0.0 A 5.0,5.0 0 0 0 2.5,10.0',
        ]
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:27,代码来源:test_paper.py

示例3: test_copy_arc

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import arc_left [as 别名]
def test_copy_arc():
    p1 = Pen()
    p1.fill_mode()

    p1.move_to((0, 0))
    p1.turn_to(0)
    p1.arc_left(90, radius=5)

    p2 = p1.copy(paper=True)
    p2.arc_left(90, radius=5)

    assert_path_data(
        p1, 0,
        'M0,0 A 5,5 0 0 0 5,-5'
    )
    assert_path_data(
        p2, 0,
        'M0,0 A 5,5 0 0 0 5,-5 A 5,5 0 0 0 0,-10'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:21,代码来源:test_copy.py

示例4: test_arc_segment_bounds

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import arc_left [as 别名]
def test_arc_segment_bounds():
    # Arc which occupies its entire circle.
    p = Pen()
    p.fill_mode()
    p.move_to((1, 0))
    p.turn_to(90)
    p.arc_left(359, 1)

    arc = p.last_segment()
    assert_equal(
        arc.bounds(),
        Bounds(-1, -1, 1, 1)
    )

    # Arc which pushes the boundary only with the endpoints.
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(30)
    p.move_forward(1)
    p.turn_left(90)
    p.arc_left(30, center=(0, 0))

    arc = p.last_segment()
    assert_equal(
        arc.bounds(),
        Bounds(0.5, 0.5, sqrt3 / 2, sqrt3 / 2)
    )

    # Arc which pushes the boundary with the middle in one spot.
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(-45)
    p.move_forward(1)
    p.turn_left(90)
    p.arc_left(90, center=(0, 0))

    arc = p.last_segment()
    assert_equal(
        arc.bounds(),
        Bounds(sqrt2 / 2, -sqrt2 / 2, 1, sqrt2 / 2)
    )

    # Arc which goes right.
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(45)
    p.arc_right(90, 3)

    arc = p.last_segment()
    assert_equal(
        arc.bounds(),
        Bounds(0, 0, 3 * sqrt2, 3 - 1.5 * sqrt2)
    )

    # Arc which pushes the boundary with the middle in two spots.
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(-45)
    p.move_forward(1)
    p.turn_left(90)
    p.arc_left(180, center=(0, 0))

    arc = p.last_segment()
    assert_equal(
        arc.bounds(),
        Bounds(-sqrt2 / 2, -sqrt2 / 2, 1, 1)
    )

    # Half circle, right side
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(0)
    p.arc_right(180, 5)

    arc = p.last_segment()
    assert_equal(
        arc.bounds(),
        Bounds(0, -10, 5, 0)
    )

    # Thick circle,
    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.move_forward(5)
    p.turn_left(90)
    p.arc_left(180, 5, start_slant=45)

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

示例5: return

# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import arc_left [as 别名]
    a = 12
    b = 0.03
    c = 0.2
    d = 1.5
    e = 0.5
    wobble = a * math.exp(-b * n) * math.sin(c * n + d * n**e)
    return (
        Angle(-24 + wobble),
        Angle(24 + wobble),
    )

center_heading = Heading(90)
center = p.position

p.turn_to(center_heading)

num_layers = 26
for layer in range(num_layers):
    lo, hi = f(layer)
    lo = center_heading + lo
    hi = center_heading + hi

    p.arc_right((p.heading - lo) + 90, center=center)
    p.arc_left(180, 1)

    p.arc_left((hi - p.heading) + 90, center=center)
    if layer < (num_layers - 1):
        p.arc_right(180, 1)

print(p.paper.format_svg(resolution=720 / p.paper.bounds().width))
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:32,代码来源:spaghetti.py


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