當前位置: 首頁>>代碼示例>>Python>>正文


Python Pen.fill_mode方法代碼示例

本文整理匯總了Python中canoepaddle.Pen.fill_mode方法的典型用法代碼示例。如果您正苦於以下問題:Python Pen.fill_mode方法的具體用法?Python Pen.fill_mode怎麽用?Python Pen.fill_mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在canoepaddle.Pen的用法示例。


在下文中一共展示了Pen.fill_mode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_translate

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [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_translate_override_bounds

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_translate_override_bounds():
    # Translate a paper that has overridden bounds. The bounds update as well.
    paper = Paper()
    paper.override_bounds(0, 0, 1, 1)
    paper.translate((3, 4))
    assert_equal(
        paper.bounds(),
        Bounds(3, 4, 4, 5)
    )

    # When bounds=False is passed, then the bounds do not update.
    paper = Paper()
    paper.override_bounds(0, 0, 1, 1)
    paper.translate((3, 4), bounds=False)
    assert_equal(paper.bounds(), Bounds(0, 0, 1, 1))

    # This also works if the bounds are not overridden.
    p = Pen()
    p.fill_mode()
    p.move_to((0.5, 0.5))
    p.circle(0.5)
    assert_equal(p.paper.bounds(), Bounds(0, 0, 1, 1))

    p.paper.translate((3, 4), bounds=False)

    assert_equal(p.paper.bounds(), Bounds(0, 0, 1, 1))
    assert_equal(p.last_path().bounds(), Bounds(3, 4, 4, 5))
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:29,代碼來源:test_paper.py

示例3: test_paper_merge

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [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

示例4: test_override_bounds_copy

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_override_bounds_copy():
    # Get the bounds of a Paper, modify them, then set them back changed.
    paper = Paper()
    paper.override_bounds(0, 0, 1, 1)

    bounds = paper.bounds()
    bounds.right = 5

    assert_equal(paper.bounds(), Bounds(0, 0, 1, 1))
    paper.override_bounds(bounds)
    assert_equal(paper.bounds(), Bounds(0, 0, 5, 1))

    # This works on non-overridden Papers as well.
    paper = Paper()

    p = Pen()
    p.fill_mode()
    p.move_to((0.5, 0.5))
    p.circle(0.5)

    bounds = p.paper.bounds()
    bounds.right = 5

    assert_equal(p.paper.bounds(), Bounds(0, 0, 1, 1))
    p.paper.override_bounds(bounds)
    assert_equal(p.paper.bounds(), Bounds(0, 0, 5, 1))
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:28,代碼來源:test_paper.py

示例5: test_copy_log

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_copy_log():
    p1 = Pen()
    p1.fill_mode()
    p1.move_to((0, 0))
    p1.turn_to(0)
    p1.line_forward(5)
    p2 = p1.copy(paper=True)
    p2.line_forward(5)

    assert_equal(
        p1.log(),
        [
            'fill_mode()', 'move_to((0, 0))', 'turn_to(0)', 'line_forward(5)',
        ]
    )
    assert_path_data(
        p1, 0,
        'M0,0 L5,0'
    )
    assert_equal(
        p2.log(),
        [
            'fill_mode()', 'move_to((0, 0))', 'turn_to(0)', 'line_forward(5)',
            'line_forward(5)',
        ]
    )
    assert_path_data(
        p2, 0,
        'M0,0 L5,0 L10,0'
    )
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:32,代碼來源:test_copy.py

示例6: draw_letter

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def draw_letter(
    letter,
    mode,
    fixed_width=None,
    show_template=False,
    show_bounds=False,
    fuse=True,
):
    """
    Draw the given letter and return a Paper.

    The letter is located centered on x=0, and with y=0 as the
    character baseline.

    If `fixed_width` is specified, use that for the paper width.
    """
    if DEBUG_OUTPUT:
        print(str(letter), file=sys.stderr)

    try:
        character_paper = letter.draw_character(mode, fuse=fuse)
    except Exception:
        if DEBUG_OUTPUT:
            traceback.print_exc()
            # Return an error pattern.
            pen = Pen()
            pen.fill_mode()
            pen.square(1)
            character_paper = pen.paper
        else:
            raise

    if fixed_width is not None:
        bounds = character_paper.bounds()
        bounds.left = -fixed_width / 2
        bounds.right = +fixed_width / 2
        character_paper.override_bounds(bounds)

    template_paper = Paper()
    if show_template:
        template_paper = draw_template_path()
    else:
        template_paper = Paper()

    letter_paper = Paper()
    letter_paper.merge(template_paper)
    letter_paper.merge(character_paper)

    # Set proper bounds for typesetting. Use the character bounds as our basis
    # so the template doesn't increase the size.
    bounds = character_paper.bounds()
    letter_paper.override_bounds(bounds)

    if show_bounds:
        pen = Pen()
        pen.fill_mode('#aaa')
        bounds.draw(pen)
        letter_paper.merge_under(pen.paper)

    return letter_paper
開發者ID:christian-oudard,項目名稱:ithkuil,代碼行數:62,代碼來源:typeset.py

示例7: test_join_paths_reference

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [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

示例8: test_draw_bounds

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_draw_bounds():
    p = Pen()
    p.fill_mode()
    Bounds(-2, -3, 1, 2).draw(p)

    assert_path_data(
        p, 0,
        'M-2,3 L1,3 L1,-2 L-2,-2 L-2,3 z'
    )
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:11,代碼來源:test_bounds.py

示例9: test_circle_bounds

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_circle_bounds():
    p = Pen()
    p.fill_mode()
    p.move_to((1, 1))
    p.circle(1.5)

    assert_equal(
        p.paper.bounds(),
        Bounds(-0.5, -0.5, 2.5, 2.5)
    )
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:12,代碼來源:test_bounds.py

示例10: test_square_bounds

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_square_bounds():
    p = Pen()
    p.fill_mode()
    p.move_to((1, 1))
    p.square(4)

    assert_equal(
        p.paper.bounds(),
        Bounds(-1, -1, 3, 3)
    )
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:12,代碼來源:test_bounds.py

示例11: test_copy_arc_to

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_copy_arc_to():
    p = Pen()
    p.fill_mode()
    p.move_to((0, 0))
    p.turn_to(0)
    p.arc_to((5, 5))
    p = p.copy(paper=True)

    assert_path_data(
        p, 0,
        'M0,0 A 5,5 0 0 0 5,-5'
    )
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:14,代碼來源:test_copy.py

示例12: draw

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
    def draw():
        p = Pen()
        p.fill_mode()
        p.move_to((0, 0))
        p.circle(2)
        paper1 = p.paper

        p = Pen()
        p.fill_mode()
        p.move_to((3, 0))
        p.circle(1)
        paper2 = p.paper

        return paper1, paper2
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:16,代碼來源:test_paper.py

示例13: test_two_pens_one_paper

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [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

示例14: test_copy_no_paper

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [as 別名]
def test_copy_no_paper():
    p1 = Pen()
    p1.fill_mode()
    p1.move_to((0, 0))
    p1.turn_to(0)
    p1.line_forward(5)
    p2 = p1.copy()
    p2.line_forward(5)

    assert_path_data(
        p1, 0,
        'M0,0 L5,0'
    )
    assert_path_data(
        p2, 0,
        'M5,0 L10,0'
    )
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:19,代碼來源:test_copy.py

示例15: test_copy_arc

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import fill_mode [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


注:本文中的canoepaddle.Pen.fill_mode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。