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


Python Pen.move_forward方法代码示例

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


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

示例1: test_outliner_mode

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

示例2: test_offwidth_joint

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

示例3: test_arc_start_slant_bug

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

示例4: test_circle_color

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

    p.turn_to(0)
    p.fill_mode((1.0, 0.0, 0.0))
    p.circle(1)
    p.move_forward(2)
    p.fill_mode((0.0, 1.0, 0.0))
    p.circle(1)
    p.move_forward(2)
    p.fill_mode((0.0, 0.0, 1.0))
    p.circle(1)

    assert_equal(
        p.paper.svg_elements(0),
        [
            '<path d="M1,0 A 1,1 0 0 0 -1,0 A 1,1 0 0 0 1,0 z" fill="#ff0000" />',
            '<path d="M3,0 A 1,1 0 0 0 1,0 A 1,1 0 0 0 3,0 z" fill="#00ff00" />',
            '<path d="M5,0 A 1,1 0 0 0 3,0 A 1,1 0 0 0 5,0 z" fill="#0000ff" />',
        ]
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:24,代码来源:test_pen.py


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