本文整理汇总了Python中canoepaddle.pen.Pen.last_segment方法的典型用法代码示例。如果您正苦于以下问题:Python Pen.last_segment方法的具体用法?Python Pen.last_segment怎么用?Python Pen.last_segment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canoepaddle.pen.Pen
的用法示例。
在下文中一共展示了Pen.last_segment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_cap
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_segment [as 别名]
def test_custom_cap():
def circle_cap(pen, end):
pen.arc_to(end)
p = Pen()
p.stroke_mode(2.0)
p.move_to((0, 0))
p.turn_to(0)
p.line_forward(5)
p.last_segment().end_cap = circle_cap
assert_path_data(
p, 0,
'M0,-1 L0,1 L5,1 A 1,1 0 0 0 5,-1 L0,-1 z'
)
p = Pen()
p.stroke_mode(2.0)
p.move_to((0, 0))
p.turn_to(0)
p.line_forward(5)
p.last_segment().start_cap = circle_cap
assert_path_data(
p, 0,
'M0,-1 A 1,1 0 1 0 0,1 L5,1 L5,-1 L0,-1 z'
)
示例2: test_arc_angle_error
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_segment [as 别名]
def test_arc_angle_error():
# Endpoints with certain angles do not go all the way across the
# stroke, and are disallowed.
p = Pen()
p.stroke_mode(1.0)
p.arc_left(90, 10, start_slant=0)
seg = p.last_segment()
assert seg.start_joint_illegal
assert not seg.end_joint_illegal
p = Pen()
p.stroke_mode(1.0)
p.arc_left(90, 10, end_slant=90)
seg = p.last_segment()
assert not seg.start_joint_illegal
assert seg.end_joint_illegal
p = Pen()
p.stroke_mode(1.0)
p.move_to((0, 0))
p.turn_to(0)
p.arc_left(90, radius=5, start_slant=25)
seg = p.last_segment()
assert seg.start_joint_illegal
assert not seg.end_joint_illegal
# A combination of angles can also create a degenerate arc.
p = Pen()
p.stroke_mode(1.0)
p.turn_toward((1, 0))
p.turn_left(1)
p.arc_to((1, 0), start_slant=40, end_slant=-40)
seg = p.last_segment()
assert seg.start_joint_illegal
assert seg.end_joint_illegal
示例3: test_arc_start_slant_bug
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_segment [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)
示例4: test_slant_error
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_segment [as 别名]
def test_slant_error():
# Creating a slant angle close to 0 is not allowed.
p = Pen()
p.stroke_mode(1.0)
p.line_forward(10, start_slant=0)
seg = p.last_segment()
assert seg.start_joint_illegal
assert not seg.end_joint_illegal
p = Pen()
p.stroke_mode(1.0)
p.line_forward(10, end_slant=0)
seg = p.last_segment()
assert not seg.start_joint_illegal
assert seg.end_joint_illegal
# A combination of angles can also create a degenerate segment.
p = Pen()
p.stroke_mode(1.0)
p.line_forward(1, start_slant=40, end_slant=-40)
seg = p.last_segment()
assert seg.start_joint_illegal
assert seg.end_joint_illegal
示例5: test_degenerate_arc
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_segment [as 别名]
def test_degenerate_arc():
p = Pen()
p.stroke_mode(2.0)
p.move_to((-5, 0))
p.turn_to(0)
p.arc_to(
(5, 0),
center=(0, -200),
start_slant=-5,
end_slant=5,
)
seg = p.last_segment()
assert seg.start_joint_illegal
assert seg.end_joint_illegal
示例6: test_close_loop_joint_error
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import last_segment [as 别名]
def test_close_loop_joint_error():
p = Pen()
p.stroke_mode(1.0)
p.move_to((0, 0))
p.turn_to(0)
p.line_forward(10)
p.turn_right(90)
p.line_forward(10)
p.turn_right(180)
p.arc_left(90, 10)
arc = p.last_segment()
assert arc.start_joint_illegal
assert arc.end_joint_illegal
assert_path_data(
p, 2,
(
'M4.47,0.50 L9.50,0.50 L9.50,5.53 A 10.50,10.50 0 0 0 4.47,0.50 z '
'M0.00,-0.50 L0.00,0.50 A 9.50,9.50 0 0 1 9.50,10.00 '
'L10.50,10.00 L10.50,-0.50 L0.00,-0.50 z'
)
)