本文整理汇总了Python中canoepaddle.pen.Pen.set_mode方法的典型用法代码示例。如果您正苦于以下问题:Python Pen.set_mode方法的具体用法?Python Pen.set_mode怎么用?Python Pen.set_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canoepaddle.pen.Pen
的用法示例。
在下文中一共展示了Pen.set_mode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stroke_fill_mode
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import set_mode [as 别名]
def test_stroke_fill_mode():
p = Pen()
p.set_mode(StrokeFillMode(0.2, 'black', 'red'))
p.move_to((0, 0))
p.turn_to(0)
p.arc_left(180, 5)
assert_equal(
p.paper.svg_elements(1)[0],
(
'<path d="M0.0,0.0 A 5.0,5.0 0 0 0 0.0,-10.0" fill="#ff0000" />'
'<path d="M0.0,-0.1 L0.0,0.1 A 5.1,5.1 0 0 0 0.0,-10.1 '
'L0.0,-9.9 A 4.9,4.9 0 0 1 0.0,-0.1 z" fill="#000000" />'
)
)
示例2: test_stroke_outline_mode
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import set_mode [as 别名]
def test_stroke_outline_mode():
p = Pen()
p.set_mode(StrokeOutlineMode(1.0, 0.2, 'red', 'black'))
p.move_to((0, 0))
p.turn_to(0)
p.line_forward(5)
assert_equal(
p.paper.svg_elements(1)[0],
(
'<path d="M0.0,-0.5 L0.0,0.5 L5.0,0.5 L5.0,-0.5 L0.0,-0.5 z" '
'fill="#ff0000" />'
'<path d="M-0.1,-0.6 L-0.1,0.6 L5.1,0.6 L5.1,-0.6 L-0.1,-0.6 z '
'M0.1,-0.4 L4.9,-0.4 L4.9,0.4 L0.1,0.4 L0.1,-0.4 z" '
'fill="#000000" />'
)
)
示例3: test_save_mode
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import set_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',
]
)
示例4: test_outliner_mode
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import set_mode [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'
)