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


Python Pen.text方法代碼示例

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


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

示例1: handle_letter

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import text [as 別名]
def handle_letter(letter, mode):
    letter_paper = draw_letter(
        letter,
        mode,
        fixed_width=30.0,
        show_template=True,
        fuse=False,
    )
    letter_paper.translate((5, 0), bounds=False)

    p = Pen()
    p.move_to((-8, 3))
    p.text(
        letter.case,
        6.0,
        font,
        gray,
        centered=True,
    )
    p.move_to((-8, -3))
    p.text(
        ', '.join(lookup(letter.case)),
        6.0,
        font,
        gray,
        centered=True,
    )
    letter_paper.merge(p.paper)

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

示例2: test_text

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import text [as 別名]
def test_text():
    p = Pen()
    p.move_to((0, 0))
    p.text('abcd', 1, 'sans-serif')
    svg_data = p.paper.format_svg(0)
    assert (
        '<text x="0" y="0" font-family="sans-serif" font-size="1" '
        'fill="#000000">abcd</text>'
    ) in svg_data
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:11,代碼來源:test_text.py

示例3: test_text_centered

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import text [as 別名]
def test_text_centered():
    p = Pen()
    p.move_to((0, 0))
    p.text('abcd', 1, 'sans-serif', centered=True)
    svg_data = p.paper.format_svg(0)
    assert (
        '<text x="0" y="0" font-family="sans-serif" font-size="1" '
        'fill="#000000" text-anchor="middle">abcd</text>'
    ) in svg_data
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:11,代碼來源:test_text.py

示例4: test_text_translate

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import text [as 別名]
def test_text_translate():
    p = Pen()
    p.move_to((0, 0))
    p.text('abcd', 1)
    paper = p.paper

    paper.translate((2, 3))
    svg_data = paper.format_svg(0)
    assert (
        '<text x="2" y="-3" font-family="sans-serif" font-size="1" '
        'fill="#000000">abcd</text>'
    ) in svg_data
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:14,代碼來源:test_text.py

示例5: test_text_merge

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import text [as 別名]
def test_text_merge():
    p = Pen()
    p.move_to((0, 0))
    p.text('abcd', 1)
    paper1 = p.paper
    assert '<text' in paper1.format_svg(0)

    paper2 = Paper()
    paper2.merge(paper1)
    assert '<text' in paper2.format_svg(0)

    paper3 = Paper()
    paper3.merge_under(paper1)
    assert '<text' in paper3.format_svg(0)
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:16,代碼來源:test_text.py

示例6: StrokeOutlineMode

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import text [as 別名]
from canoepaddle import Pen, StrokeOutlineMode

from ithkuil.writing.consonant import consonants
from ithkuil.writing.typeset import draw_letter, typeset
from ithkuil.phonology import convert_ascii_to_html
import ithkuil.writing.side_ending as se
import ithkuil.writing.bottom_ending as be

font = "Caudex"
font_size = 8
red = "#d6041a"
black = "#260003"
gray = "#233042"
mode = StrokeOutlineMode(1.0, 0.2, red, black)

papers = []
for consonant_class in consonants:
    letter = consonant_class(se.Normal, be.Normal)
    letter_paper = draw_letter(letter, mode, fixed_width=27.0, show_template=True)
    letter_paper.translate((5, 0), bounds=False)

    p = Pen()
    p.move_to((-5, 0))
    p.text(convert_ascii_to_html(consonant_class.pronunciation), 8.0, "Caudex", "#233042", centered=True)
    letter_paper.merge(p.paper)
    papers.append(letter_paper)

page = typeset(papers, letter_spacing=1.0, letters_per_line=6, line_spacing=3.5, page_margin=5.0)

print(page.format_svg(4, resolution=1000 / page.bounds().width))
開發者ID:christian-oudard,項目名稱:ithkuil,代碼行數:32,代碼來源:consonant_characters.py

示例7: Pen

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import text [as 別名]
    paper.override_bounds(bounds)
    paper.translate((-0.5, 0))

    # Generate text indicating pattern and stem.
    pen = Pen()
    pen.paper = paper
    if letter.side_ending_class.relation == 'UNFRAMED':
        pen.move_to((2, 9.5))
    else:
        pen.move_to((2, 11.5))

    text = '{} {}'.format(
        letter.side_ending_class.pattern,
        letter.side_ending_class.stem,
    )
    pen.text(text, font_size, font, gray, centered=True)

    papers.append(paper)


page = typeset(
    papers,
    letter_spacing=4.0,
    letters_per_line=9,
    line_spacing=5.0,
    page_margin=5.0,
)

# Add row text.
page_bounds = page.bounds()
pen = Pen()
開發者ID:christian-oudard,項目名稱:ithkuil,代碼行數:33,代碼來源:side_ending_chart.py


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