本文整理汇总了Python中canoepaddle.Pen.last_segment方法的典型用法代码示例。如果您正苦于以下问题:Python Pen.last_segment方法的具体用法?Python Pen.last_segment怎么用?Python Pen.last_segment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canoepaddle.Pen
的用法示例。
在下文中一共展示了Pen.last_segment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_character
# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import last_segment [as 别名]
def draw_character(self, mode, **kwargs):
side_ending = self.side_ending_class(
self,
self.side_flipped,
)
paper = Paper()
pen = Pen()
pen.set_mode(mode)
pen.move_to((0, TOP - mode.width / 2))
pen.turn_to(0)
pen.line_forward(2.0)
pen.last_segment().start_cap = stub_cap
side_ending.draw(pen)
paper.merge(pen.paper)
bounds = paper.bounds()
bounds.top = OVER
bounds.bottom = MIDDLE
bounds.left = 0
paper.override_bounds(bounds)
return paper
示例2: test_line_segment_bounds
# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import last_segment [as 别名]
def test_line_segment_bounds():
# Fill mode segment.
p = Pen()
p.fill_mode()
p.move_to((1, 0))
p.line_to((2, 3))
line = p.last_segment()
assert_equal(
line.bounds(),
Bounds(1, 0, 2, 3)
)
# Stroke mode segment.
p = Pen()
p.stroke_mode(sqrt2)
p.move_to((0, 0))
p.line_to((5, 5))
line = p.last_segment()
assert_equal(
line.bounds(),
Bounds(-0.5, -0.5, 5.5, 5.5)
)
示例3: test_copy_custom_cap
# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import last_segment [as 别名]
def test_copy_custom_cap():
# Regression test for a bug where doing pen.copy() in a cap function would
# break outline drawing.
p = Pen()
p.stroke_mode(2.0)
p.move_to((0, 0))
p.turn_to(0)
p.line_forward(5)
p.turn_left(90)
p.line_forward(5)
def copy_cap(pen, end):
pen.copy()
pen.line_to(end)
p.last_segment().end_cap = copy_cap
assert_path_data(
p, 0,
'M0,-1 L0,1 L6,1 L6,-5 L4,-5 L4,-1 L0,-1 z'
)
示例4: test_arc_segment_bounds
# 需要导入模块: from canoepaddle import Pen [as 别名]
# 或者: from canoepaddle.Pen import last_segment [as 别名]
def test_arc_segment_bounds():
# Arc which occupies its entire circle.
p = Pen()
p.fill_mode()
p.move_to((1, 0))
p.turn_to(90)
p.arc_left(359, 1)
arc = p.last_segment()
assert_equal(
arc.bounds(),
Bounds(-1, -1, 1, 1)
)
# Arc which pushes the boundary only with the endpoints.
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_to(30)
p.move_forward(1)
p.turn_left(90)
p.arc_left(30, center=(0, 0))
arc = p.last_segment()
assert_equal(
arc.bounds(),
Bounds(0.5, 0.5, sqrt3 / 2, sqrt3 / 2)
)
# Arc which pushes the boundary with the middle in one spot.
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_to(-45)
p.move_forward(1)
p.turn_left(90)
p.arc_left(90, center=(0, 0))
arc = p.last_segment()
assert_equal(
arc.bounds(),
Bounds(sqrt2 / 2, -sqrt2 / 2, 1, sqrt2 / 2)
)
# Arc which goes right.
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_to(45)
p.arc_right(90, 3)
arc = p.last_segment()
assert_equal(
arc.bounds(),
Bounds(0, 0, 3 * sqrt2, 3 - 1.5 * sqrt2)
)
# Arc which pushes the boundary with the middle in two spots.
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_to(-45)
p.move_forward(1)
p.turn_left(90)
p.arc_left(180, center=(0, 0))
arc = p.last_segment()
assert_equal(
arc.bounds(),
Bounds(-sqrt2 / 2, -sqrt2 / 2, 1, 1)
)
# Half circle, right side
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_to(0)
p.arc_right(180, 5)
arc = p.last_segment()
assert_equal(
arc.bounds(),
Bounds(0, -10, 5, 0)
)
# Thick circle,
p = Pen()
p.stroke_mode(1.0)
p.move_to((0, 0))
p.turn_to(0)
p.move_forward(5)
p.turn_left(90)
p.arc_left(180, 5, start_slant=45)
arc = p.last_segment()
assert_equal(
arc.bounds(),
Bounds(-5.5, -0.5314980314970469, 5.5, 5.5)
)