本文整理匯總了Python中canoepaddle.Pen.copy方法的典型用法代碼示例。如果您正苦於以下問題:Python Pen.copy方法的具體用法?Python Pen.copy怎麽用?Python Pen.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類canoepaddle.Pen
的用法示例。
在下文中一共展示了Pen.copy方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_copy_log
# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import copy [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'
)
示例2: test_copy_loop
# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import copy [as 別名]
def test_copy_loop():
p = Pen()
p.stroke_mode(0.2)
def square():
p.turn_to(180)
p.line_forward(1)
p.turn_left(90)
p.line_forward(1)
p.turn_left(90)
p.line_forward(1)
p.turn_left(90)
p.line_forward(1)
p.move_to((0, 0))
square()
p = p.copy(paper=True)
p.move_to((2, 0))
square()
assert_path_data(
p, 1,
(
'M0.1,-0.1 L-1.1,-0.1 L-1.1,1.1 L0.1,1.1 L0.1,-0.1 z '
'M-0.1,0.1 L-0.1,0.9 L-0.9,0.9 L-0.9,0.1 L-0.1,0.1 z '
'M2.1,-0.1 L0.9,-0.1 L0.9,1.1 L2.1,1.1 L2.1,-0.1 z '
'M1.9,0.1 L1.9,0.9 L1.1,0.9 L1.1,0.1 L1.9,0.1 z'
)
)
示例3: test_copy_text
# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import copy [as 別名]
def test_copy_text():
p = Pen()
p.move_to((0, 0))
p.text('abcd', 1, 'sans-serif')
p = p.copy(paper=True)
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
示例4: test_copy_no_mode
# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import copy [as 別名]
def test_copy_no_mode():
p = Pen()
assert_raises(
AttributeError,
lambda: p.mode
)
p = p.copy()
assert_raises(
AttributeError,
lambda: p.mode
)
示例5: test_copy_arc_to
# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import copy [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'
)
示例6: test_copy_no_paper
# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import copy [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'
)
示例7: test_copy_arc
# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import copy [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'
)