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


Python Pen.turn_left方法代码示例

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


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

示例1: test_offwidth_arc_joins

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_offwidth_arc_joins():
    # Join arcs and lines of different widths.
    p = Pen()
    p.move_to((0, 0))
    p.turn_to(0)

    p.stroke_mode(0.8)
    p.line_forward(5)
    p.turn_left(45)
    p.stroke_mode(3.0)
    p.arc_left(90, 5)

    p.turn_to(-180)
    p.line_forward(5)
    p.turn_left(45)
    p.stroke_mode(0.8)
    p.arc_left(45, 5)

    p.turn_right(90)
    p.stroke_mode(3.0)
    p.arc_right(90, 4)

    assert_svg_file(
        p, 3,
        'test_offwidth_arc_joins.svg'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:28,代码来源:test_pen.py

示例2: test_outliner_mode

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_outliner_mode():
    # We can set up a pattern in one mode,
    p = Pen()
    p.set_mode(StrokeOutlineMode(sqrt3, 0.2 * sqrt3, 'blue', 'black'))

    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(5, end_slant=60)

    # Then continue it in another mode without caring what the first mode was.
    old_mode = p.mode
    p.set_mode(p.mode.outliner_mode())

    p.turn_to(60)
    p.move_forward(1.0)

    p.turn_left(60)
    p.line_forward(2.0)
    p.turn_right(120)
    p.line_forward(2.0)
    p.turn_right(120)
    p.line_forward(2.0)

    p.turn_to(60)
    p.move_forward(3.0)
    p.turn_to(120)

    p.set_mode(old_mode)

    p.line_forward(5, start_slant=60)

    assert_svg_file(
        p, 3,
        'test_outliner_mode.svg'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:37,代码来源:test_pen.py

示例3: test_arc_angle_error

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_arc_angle_error():
    # Endpoints with certain angles do not go all the way across the
    # stroke, and are disallowed.
    p = Pen()
    p.stroke_mode(1.0)
    p.arc_left(90, 10, start_slant=0)
    seg = p.last_segment()
    assert seg.start_joint_illegal
    assert not seg.end_joint_illegal

    p = Pen()
    p.stroke_mode(1.0)
    p.arc_left(90, 10, end_slant=90)
    seg = p.last_segment()
    assert not seg.start_joint_illegal
    assert seg.end_joint_illegal

    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)
    p.arc_left(90, radius=5, start_slant=25)
    seg = p.last_segment()
    assert seg.start_joint_illegal
    assert not seg.end_joint_illegal

    # A combination of angles can also create a degenerate arc.
    p = Pen()
    p.stroke_mode(1.0)
    p.turn_toward((1, 0))
    p.turn_left(1)
    p.arc_to((1, 0), start_slant=40, end_slant=-40)
    seg = p.last_segment()
    assert seg.start_joint_illegal
    assert seg.end_joint_illegal
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:37,代码来源:test_segment.py

示例4: test_line_line_half_illegal_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_line_line_half_illegal_joint():
    # The outside edge meets, but the inside is too short to meet.
    p = Pen()
    p.stroke_mode(1.0)
    p.move_to((0, 0))
    p.turn_to(0)

    p.line_forward(2)
    p.turn_left(165)
    p.line_forward(2)

    assert_path_data(
        p, 2,
        (
            'M0.00,-0.50 L0.00,0.50 L5.80,0.50 L0.20,-1.00 '
            'L-0.06,-0.03 L1.87,0.48 L2.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(2)
    p.turn_right(165)
    p.line_forward(2)

    assert_path_data(
        p, 2,
        (
            'M0.00,-0.50 L0.00,0.50 L2.00,0.50 L1.87,-0.48 '
            'L-0.06,0.03 L0.20,1.00 L5.80,-0.50 L0.00,-0.50 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:37,代码来源:test_segment.py

示例5: test_start_slant_legal_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_start_slant_legal_joint():
    # Create a joint that is only legal because of the start slant.
    p = Pen()
    p.outline_mode(1.0, 0.1)
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(0.8, start_slant=-45)
    p.turn_left(90)
    p.outline_mode(2.0, 0.1)
    p.line_forward(5)
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:12,代码来源:test_pen.py

示例6: test_long_line_thick

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_long_line_thick():
    p = Pen()
    p.stroke_mode(2.0)
    p.move_to((0, 0))
    p.turn_to(0)
    for _ in range(2):
        p.line_forward(5)
        p.turn_right(90)
        p.line_forward(5)
        p.turn_left(90)

    assert_path_data(
        p, 0,
        'M0,-1 L0,1 L4,1 L4,6 L9,6 L9,10 L11,10 L11,4 L6,4 L6,-1 L0,-1 z'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:17,代码来源:test_pen.py

示例7: test_offwidth_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_offwidth_joint():
    p = Pen()
    p.stroke_mode(1.0)
    p.turn_to(0)
    p.move_forward(-3)
    p.line_forward(3)
    p.stroke_mode(0.5)
    p.turn_left(90)
    p.line_forward(3)

    assert_path_data(
        p, 2,
        (
            'M-3.00,-0.50 L-3.00,0.50 L0.25,0.50 L0.25,-3.00 '
            'L-0.25,-3.00 L-0.25,-0.50 L-3.00,-0.50 z'
        ),
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:19,代码来源:test_pen.py

示例8: test_arc_line_joint

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

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

    assert_path_data(
        p, 3,
        (
            'M0.000,-0.500 L0.000,0.500 L3.464,0.500 '
            'A 3.500,3.500 0 1 0 -3.500,0.000 L-2.500,0.000 '
            'A 2.500,2.500 0 0 1 2.449,-0.500 L0.000,-0.500 z'
        ),
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:20,代码来源:test_pen.py

示例9: test_various_joins

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_various_joins():
    p = Pen()
    p.stroke_mode(0.5)
    p.move_to((-2, 0))
    p.turn_to(0)
    p.line_forward(1)
    p.turn_left(90)
    p.line_forward(1)
    p.turn_right(90)
    p.arc_right(90, 1)
    p.arc_left(90, 1)
    p.turn_left(90)
    p.line_forward(1)

    p.paper.override_bounds(-3, -3, 3, 3)

    assert_svg_file(
        p, 2,
        'test_various_joins.svg',
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:22,代码来源:test_pen.py

示例10: test_arc_start_slant_bug

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_arc_start_slant_bug():
    # Some arcs are not reporting their start and end slants correctly.

    # Set up positions on a circle at angles -120 and 30
    p = Pen()
    p.fill_mode()

    p.move_to((0, 0))
    p.turn_to(30)
    p.move_forward(3)
    p1 = p.position
    p.turn_left(90)
    h1 = p.heading

    p.move_to((0, 0))
    p.turn_to(-120)
    p.move_forward(3)
    p2 = p.position

    # Create an arc using arc_left.
    p = Pen()
    p.fill_mode()

    p.move_to(p1)
    p.turn_to(h1)
    p.arc_left(210, 3)
    arc = p.last_segment()
    assert_almost_equal(arc.start_heading, 120)
    assert_almost_equal(arc.end_heading, 330)

    # Create the same arc using arc_to.
    p = Pen()
    p.fill_mode()

    p.move_to(p1)
    p.turn_to(h1)
    p.arc_to(p2)
    arc = p.last_segment()
    assert_almost_equal(arc.start_heading.theta, 120)
    assert_almost_equal(arc.end_heading.theta, 330)
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:42,代码来源:test_pen.py

示例11: test_joint_loop_color

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

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

    # Draw a square with one side a different color. It joins to the
    # beginning correctly.
    p.stroke_mode(2.0, color='black')
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)
    p.turn_left(90)
    p.stroke_mode(2.0, color='red')
    p.line_forward(5)

    assert_equal(len(p.paper.paths), 1)

    assert_path_data(
        p, 0,
        [
            'M1,-1 L-1,1 L6,1 L6,-6 L-1,-6 L1,-4 L4,-4 L4,-1 L1,-1 z',
            'M1,-4 L-1,-6 L-1,1 L1,-1 L1,-4 z',
        ]
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:29,代码来源:test_pen.py

示例12: test_mode

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_mode():
    # Fill mode square.
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)

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

示例13: test_joint_loop

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

    p.stroke_mode(2.0)
    p.move_to((0, 0))
    p.turn_to(0)

    # Draw a square.
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)
    p.turn_left(90)
    p.line_forward(5)

    assert_path_data(
        p, 0,
        (
            'M-1,1 L6,1 L6,-6 L-1,-6 L-1,1 z '
            'M1,-1 L1,-4 L4,-4 L4,-1 L1,-1 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:25,代码来源:test_pen.py

示例14: test_arc_arc_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [as 别名]
def test_arc_arc_joint():
    top = (0, 5)
    left = (-2, 0)
    right = (2, 0)

    # Convex-convex.
    p = Pen()
    p.stroke_mode(1.0)

    p.move_to(left)
    p.turn_toward(top)
    p.turn_left(5)
    p.arc_to(top, start_slant=0)
    p.turn_toward(right)
    p.turn_left(5)
    p.arc_to(right, end_slant=0)

    assert_path_data(
        p, 3,
        (
            'M-2.522,0.000 L-1.477,0.000 '
            'A 30.394,30.394 0 0 1 0.000,-3.853 '
            'A 30.394,30.394 0 0 1 1.477,0.000 '
            'L2.522,0.000 '
            'A 31.394,31.394 0 0 0 0.000,-6.076 '
            'A 31.394,31.394 0 0 0 -2.522,0.000 z'
        )
    )

    # Concave-concave.
    p = Pen()
    p.stroke_mode(1.0)

    p.move_to(left)
    p.turn_toward(top)
    p.turn_right(5)
    p.arc_to(top, start_slant=0)
    p.turn_toward(right)
    p.turn_right(5)
    p.arc_to(right, end_slant=0)

    assert_path_data(
        p, 3,
        (
            'M-2.561,0.000 L-1.441,0.000 '
            'A 31.394,31.394 0 0 0 0.000,-3.400 '
            'A 31.394,31.394 0 0 0 1.441,0.000 '
            'L2.561,0.000 '
            'A 30.394,30.394 0 0 1 0.000,-6.923 '
            'A 30.394,30.394 0 0 1 -2.561,0.000 z'
        )
    )

    # Convex-concave.
    p = Pen()
    p.stroke_mode(1.0)

    p.move_to(left)
    p.turn_toward(top)
    p.turn_left(5)
    p.arc_to(top, start_slant=0)
    p.turn_toward(right)
    p.turn_right(5)
    p.arc_to(right, end_slant=0)

    assert_path_data(
        p, 3,
        (
            'M-2.522,0.000 L-1.477,0.000 '
            'A 30.394,30.394 0 0 1 -0.090,-3.656 '
            'A 31.394,31.394 0 0 0 1.441,0.000 '
            'L2.561,0.000 '
            'A 30.394,30.394 0 0 1 0.144,-6.339 '
            'A 31.394,31.394 0 0 0 -2.522,0.000 z'
        )
    )

    # Concave-convex.
    p = Pen()
    p.stroke_mode(1.0)

    p.move_to(left)
    p.turn_toward(top)
    p.turn_right(5)
    p.arc_to(top, start_slant=0)
    p.turn_toward(right)
    p.turn_left(5)
    p.arc_to(right, end_slant=0)

    assert_path_data(
        p, 3,
        (
            'M-2.561,0.000 L-1.441,0.000 '
            'A 31.394,31.394 0 0 0 0.090,-3.656 '
            'A 30.394,30.394 0 0 1 1.477,0.000 '
            'L2.522,0.000 '
            'A 31.394,31.394 0 0 0 -0.144,-6.339 '
            'A 30.394,30.394 0 0 1 -2.561,0.000 z'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:102,代码来源:test_pen.py

示例15: test_too_sharp_joint

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_left [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.turn_left方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。