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


Python Pen.fill_mode方法代码示例

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


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

示例1: test_line_to_coordinate

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_line_to_coordinate():
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(45)
    p.line_to_y(3)
    assert_points_equal(p.position, (3, 3))

    for x, y in [
        (2, 1),
        (3, -4),
        (-7, -5),
        (-6, 6),
    ]:
        p = Pen()
        p.fill_mode()

        p.move_to((0, 0))
        p.turn_toward((x, y))
        p.line_to_y(y * 2)
        assert_points_equal(p.position, (x * 2, y * 2))

        p.move_to((0, 0))
        p.turn_toward((x, y))
        p.line_to_x(x * 3)
        assert_points_equal(p.position, (x * 3, y * 3))
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:28,代码来源:test_pen.py

示例2: test_circle_line_overlap

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_circle_line_overlap():
    # Draw a circle that is above one line but below the other line.
    p = Pen()

    p.stroke_mode(1.0, color=(1.0, 0.0, 0.0))
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(4)

    p.fill_mode(color=(0.0, 1.0, 0.0))
    p.move_to((2, 2))
    p.circle(2)

    p.stroke_mode(1.0, color=(0.0, 0.0, 1.0))
    p.move_to((0, 4))
    p.turn_to(0)
    p.line_forward(4)

    assert_equal(
        p.paper.svg_elements(1),
        [
            (
                '<path d="M0.0,-0.5 L0.0,0.5 L4.0,0.5 L4.0,-0.5 L0.0,-0.5 z" '
                'fill="#ff0000" />'
            ),
            (
                '<path d="M4.0,-2.0 A 2.0,2.0 0 0 0 0.0,-2.0 '
                'A 2.0,2.0 0 0 0 4.0,-2.0 z" fill="#00ff00" />'
            ),
            (
                '<path d="M0.0,-4.5 L0.0,-3.5 L4.0,-3.5 L4.0,-4.5 L0.0,-4.5 z" '
                'fill="#0000ff" />'
            ),
        ]
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:37,代码来源:test_pen.py

示例3: test_circle

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_circle():
    p = Pen()
    p.fill_mode()
    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="#000000" />']
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:11,代码来源:test_pen.py

示例4: test_line

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

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

示例5: test_arc_normalize

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_arc_normalize():
    # Arc angles larger than 360 behave correctly.
    p = Pen()
    p.fill_mode()
    p.move_to((-5, 0))
    p.turn_to(0)
    p.arc_left(360 + 90, radius=5)

    assert_path_data(
        p, 0,
        'M-5,0 A 5,5 0 0 0 0,-5'
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:14,代码来源:test_pen.py

示例6: test_line_segments

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

    p.move_to((0, 0))
    p.turn_to(45)
    p.line_forward(2.0)

    assert_points_equal(p.position, (sqrt2, sqrt2))
    assert_equal(len(p.paper.paths), 1)
    segments = p.last_path().segments
    for actual, target in zip(segments, [
        ((0, 0), (sqrt2, sqrt2)),
    ]):
        assert_segments_equal(actual, target)
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:17,代码来源:test_segment.py

示例7: test_save_mode

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_save_mode():
    p = Pen()
    p.stroke_mode(2.0, 'red')
    old_mode = p.mode
    p.line_forward(5)
    p.fill_mode('blue')
    p.square(2)
    p.set_mode(old_mode)
    p.line_forward(5)

    assert_path_data(
        p, 0,
        [
            'M0,-1 L0,1 L5,1 L5,-1 L0,-1 z',
            'M4,1 L6,1 L6,-1 L4,-1 L4,1 z',
            'M5,-1 L5,1 L10,1 L10,-1 L5,-1 z',
        ]
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:20,代码来源:test_pen.py

示例8: test_change_mode

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_change_mode():
    # Change mode but don't change colors. It starts a new path.
    p = Pen()
    p.move_to((0, 0))
    p.turn_to(0)

    p.stroke_mode(2.0, 'black')
    p.line_forward(5)
    p.fill_mode('black')
    p.line_forward(5)

    assert_equal(
        p.paper.svg_elements(0),
        [
            '<path d="M0,-1 L0,1 L5,1 L5,-1 L0,-1 z" fill="#000000" />',
            '<path d="M5,0 L10,0" fill="#000000" />',
        ]
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:20,代码来源:test_pen.py

示例9: test_mode

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

示例10: test_repr

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_repr():
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(1)
    p.arc_left(90, 1)

    path = p.paper.paths[0]
    line, arc = path.segments
    assert_equal(
        repr(line),
        'LineSegment(a=Point(x=0, y=0), b=Point(x=1.0, y=0.0))'
    )
    assert_equal(
        repr(arc),
        (
            'ArcSegment(a=Point(x=1.0, y=0.0), b=Point(x=2.0, y=0.9999999999999999), '
            'center=Point(x=1.0, y=1.0), radius=1, start_heading=0, end_heading=90)'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:23,代码来源:test_pen.py

示例11: test_arc_center

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_arc_center():
    # Draw the same arcs as in test_arc, but using centers instead of radii.
    p = Pen()
    p.fill_mode()

    p.move_to((-5, 0))
    p.turn_to(0)
    p.arc_left(90, center=(-5, 5))
    p.arc_right(270, center=(5, 5))

    p.move_to((-5, 0))
    p.turn_to(0)
    p.arc_right(90, center=(-5, -5))
    p.arc_left(270, center=(5, -5))

    assert_path_data(
        p, 0,
        (
            'M-5,0 A 5,5 0 0 0 0,-5 A 5,5 0 1 1 5,0 '
            'M-5,0 A 5,5 0 0 1 0,5 A 5,5 0 1 0 5,0'
        ),
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:24,代码来源:test_pen.py

示例12: test_arc

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_arc():
    # Draw arcs with all four combinations of sweep and direction flags.
    p = Pen()
    p.fill_mode()

    p.move_to((-5, 0))
    p.turn_to(0)
    p.arc_left(90, radius=5)
    p.arc_right(270, radius=5)

    p.move_to((-5, 0))
    p.turn_to(0)
    p.arc_right(90, radius=5)
    p.arc_left(270, radius=5)

    assert_path_data(
        p, 0,
        (
            'M-5,0 A 5,5 0 0 0 0,-5 A 5,5 0 1 1 5,0 '
            'M-5,0 A 5,5 0 0 1 0,5 A 5,5 0 1 0 5,0'
        )
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:24,代码来源:test_pen.py

示例13: test_arc_to

# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import fill_mode [as 别名]
def test_arc_to():
    # Make the same arcs as test_arc, but using the destination points instead
    # of the angles.
    p = Pen()
    p.fill_mode()

    p.move_to((-5, 0))
    p.turn_to(0)
    p.arc_to((0, 5))
    p.arc_to((5, 0))

    p.move_to((-5, 0))
    p.turn_to(0)
    p.arc_to((0, -5))
    p.arc_to((5, 0))

    assert_path_data(
        p, 0,
        (
            'M-5,0 A 5,5 0 0 0 0,-5 A 5,5 0 1 1 5,0 '
            'M-5,0 A 5,5 0 0 1 0,5 A 5,5 0 1 0 5,0'
        ),
    )
开发者ID:christian-oudard,项目名称:canoepaddle,代码行数:25,代码来源:test_pen.py

示例14: test_arc_start_slant_bug

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

示例15: test_circle_color

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