本文整理汇总了Python中canoepaddle.pen.Pen.turn_toward方法的典型用法代码示例。如果您正苦于以下问题:Python Pen.turn_toward方法的具体用法?Python Pen.turn_toward怎么用?Python Pen.turn_toward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canoepaddle.pen.Pen
的用法示例。
在下文中一共展示了Pen.turn_toward方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_line_to_coordinate
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_toward [as 别名]
def test_line_to_coordinate():
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_to(45)
p.line_to_y(3)
assert_points_equal(p.position, (3, 3))
for x, y in [
(2, 1),
(3, -4),
(-7, -5),
(-6, 6),
]:
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_toward((x, y))
p.line_to_y(y * 2)
assert_points_equal(p.position, (x * 2, y * 2))
p.move_to((0, 0))
p.turn_toward((x, y))
p.line_to_x(x * 3)
assert_points_equal(p.position, (x * 3, y * 3))
示例2: test_arc_angle_error
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_toward [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_move_to_xy
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_toward [as 别名]
def test_move_to_xy():
p = Pen()
p.move_to((0, 0))
p.turn_to(-45)
p.move_to_x(1)
assert_points_equal(p.position, (1, -1))
p = Pen()
p.move_to((0, 0))
p.turn_toward((3, 4))
p.move_to_y(8)
assert_points_equal(p.position, (6, 8))
示例4: test_arc_arc_joint
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_toward [as 别名]
def test_arc_arc_joint():
top = (0, 5)
left = (-2, 0)
right = (2, 0)
# Convex-convex.
p = Pen()
p.stroke_mode(1.0)
p.move_to(left)
p.turn_toward(top)
p.turn_left(5)
p.arc_to(top, start_slant=0)
p.turn_toward(right)
p.turn_left(5)
p.arc_to(right, end_slant=0)
assert_path_data(
p, 3,
(
'M-2.522,0.000 L-1.477,0.000 '
'A 30.394,30.394 0 0 1 0.000,-3.853 '
'A 30.394,30.394 0 0 1 1.477,0.000 '
'L2.522,0.000 '
'A 31.394,31.394 0 0 0 0.000,-6.076 '
'A 31.394,31.394 0 0 0 -2.522,0.000 z'
)
)
# Concave-concave.
p = Pen()
p.stroke_mode(1.0)
p.move_to(left)
p.turn_toward(top)
p.turn_right(5)
p.arc_to(top, start_slant=0)
p.turn_toward(right)
p.turn_right(5)
p.arc_to(right, end_slant=0)
assert_path_data(
p, 3,
(
'M-2.561,0.000 L-1.441,0.000 '
'A 31.394,31.394 0 0 0 0.000,-3.400 '
'A 31.394,31.394 0 0 0 1.441,0.000 '
'L2.561,0.000 '
'A 30.394,30.394 0 0 1 0.000,-6.923 '
'A 30.394,30.394 0 0 1 -2.561,0.000 z'
)
)
# Convex-concave.
p = Pen()
p.stroke_mode(1.0)
p.move_to(left)
p.turn_toward(top)
p.turn_left(5)
p.arc_to(top, start_slant=0)
p.turn_toward(right)
p.turn_right(5)
p.arc_to(right, end_slant=0)
assert_path_data(
p, 3,
(
'M-2.522,0.000 L-1.477,0.000 '
'A 30.394,30.394 0 0 1 -0.090,-3.656 '
'A 31.394,31.394 0 0 0 1.441,0.000 '
'L2.561,0.000 '
'A 30.394,30.394 0 0 1 0.144,-6.339 '
'A 31.394,31.394 0 0 0 -2.522,0.000 z'
)
)
# Concave-convex.
p = Pen()
p.stroke_mode(1.0)
p.move_to(left)
p.turn_toward(top)
p.turn_right(5)
p.arc_to(top, start_slant=0)
p.turn_toward(right)
p.turn_left(5)
p.arc_to(right, end_slant=0)
assert_path_data(
p, 3,
(
'M-2.561,0.000 L-1.441,0.000 '
'A 31.394,31.394 0 0 0 0.090,-3.656 '
'A 30.394,30.394 0 0 1 1.477,0.000 '
'L2.522,0.000 '
'A 31.394,31.394 0 0 0 -0.144,-6.339 '
'A 30.394,30.394 0 0 1 -2.561,0.000 z'
)
)
示例5: test_movement
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import turn_toward [as 别名]
def test_movement():
p = Pen()
p.move_to((0, 0))
p.turn_toward((1, 1))
assert_equal(p.heading, 45)