本文整理汇总了Python中canoepaddle.pen.Pen.arc_left方法的典型用法代码示例。如果您正苦于以下问题:Python Pen.arc_left方法的具体用法?Python Pen.arc_left怎么用?Python Pen.arc_left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canoepaddle.pen.Pen
的用法示例。
在下文中一共展示了Pen.arc_left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_offwidth_arc_joins
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_offwidth_arc_joins():
# Join arcs and lines of different widths.
p = Pen()
p.move_to((0, 0))
p.turn_to(0)
p.stroke_mode(0.8)
p.line_forward(5)
p.turn_left(45)
p.stroke_mode(3.0)
p.arc_left(90, 5)
p.turn_to(-180)
p.line_forward(5)
p.turn_left(45)
p.stroke_mode(0.8)
p.arc_left(45, 5)
p.turn_right(90)
p.stroke_mode(3.0)
p.arc_right(90, 4)
assert_svg_file(
p, 3,
'test_offwidth_arc_joins.svg'
)
示例2: test_arc_joint_continue
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_joint_continue():
p = Pen()
p.stroke_mode(2.0)
p.move_to((0, 0))
p.turn_to(0)
p.arc_left(90, 5)
p.arc_left(90, 5)
p.move_to((0, 0))
p.turn_to(0)
p.arc_right(90, 5)
p.arc_right(90, 5)
assert_path_data(
p, 0,
(
'M0,-1 L0,1 A 6,6 0 0 0 6,-5 A 6,6 0 0 0 0,-11 '
'L0,-9 A 4,4 0 0 1 4,-5 A 4,4 0 0 1 0,-1 z '
'M0,-1 L0,1 A 4,4 0 0 1 4,5 A 4,4 0 0 1 0,9 '
'L0,11 A 6,6 0 0 0 6,5 A 6,6 0 0 0 0,-1 z'
),
)
示例3: test_arc_normalize
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_normalize():
# Arc angles larger than 360 behave correctly.
p = Pen()
p.fill_mode()
p.move_to((-5, 0))
p.turn_to(0)
p.arc_left(360 + 90, radius=5)
assert_path_data(
p, 0,
'M-5,0 A 5,5 0 0 0 0,-5'
)
示例4: test_arc_sweep_bug
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_sweep_bug():
p = Pen()
p.stroke_mode(2.0)
p.move_to((3, 0))
p.turn_to(90)
p.arc_left(270, 3)
assert_path_data(
p, 0,
'M2,0 L4,0 A 4,4 0 1 0 0,4 L0,2 A 2,2 0 1 1 2,0 z'
)
示例5: test_arc_zero
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_zero():
p = Pen()
p.stroke_mode(1.0)
p.move_to((0, 0))
p.turn_to(0)
# Zero-angle and zero-radius arcs have zero length, so they are not added.
p.arc_left(0, radius=1)
assert_equal(p.paper.paths, [])
p.arc_left(90, radius=0)
assert_equal(p.paper.paths, [])
示例6: test_arc_pie_slice
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_pie_slice():
# Draw a "pie slice" arc that is wide enough to reach all the way to the
# arc center.
p = Pen()
p.stroke_mode(1.0)
p.move_to((0.5, 0))
p.turn_to(90)
p.arc_left(90, 0.5)
assert_path_data(
p, 0,
'M0,0 L1,0 A 1,1 0 0 0 0,-1 L0,0 z'
)
示例7: test_stroke_fill_mode
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [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" />'
)
)
示例8: test_arc_angle
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_angle():
p = Pen()
p.stroke_mode(1.0)
p.move_to((0, 0))
p.turn_to(0)
p.arc_left(90, radius=5, start_slant=45, end_slant=45)
assert_path_data(
p, 2,
(
'M0.53,-0.53 L-0.48,0.48 A 5.50,5.50 0 0 0 5.48,-5.48 '
'L4.47,-4.47 A 4.50,4.50 0 0 1 0.53,-0.53 z'
),
)
示例9: test_arc_line_joint
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_line_joint():
p = Pen()
p.stroke_mode(1.0)
p.move_to((0, 0))
p.turn_to(0)
p.line_forward(3)
p.turn_left(90)
p.arc_left(180, 3)
assert_path_data(
p, 3,
(
'M0.000,-0.500 L0.000,0.500 L3.464,0.500 '
'A 3.500,3.500 0 1 0 -3.500,0.000 L-2.500,0.000 '
'A 2.500,2.500 0 0 1 2.449,-0.500 L0.000,-0.500 z'
),
)
示例10: test_arc_arc_joint_off_radius
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_arc_joint_off_radius():
p = Pen()
p.stroke_mode(1.0)
p.move_to((0, 0))
p.turn_to(0)
p.arc_left(180, 1)
p.arc_left(90, 2)
assert_path_data(
p, 1,
(
'M0.0,-0.5 L0.0,0.5 '
'A 1.5,1.5 0 0 0 0.0,-2.5 '
'A 2.5,2.5 0 0 0 -2.5,0.0 '
'L-1.5,0.0 '
'A 1.5,1.5 0 0 1 0.0,-1.5 '
'A 0.5,0.5 0 0 1 0.0,-0.5 z'
)
)
示例11: test_various_joins
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_various_joins():
p = Pen()
p.stroke_mode(0.5)
p.move_to((-2, 0))
p.turn_to(0)
p.line_forward(1)
p.turn_left(90)
p.line_forward(1)
p.turn_right(90)
p.arc_right(90, 1)
p.arc_left(90, 1)
p.turn_left(90)
p.line_forward(1)
p.paper.override_bounds(-3, -3, 3, 3)
assert_svg_file(
p, 2,
'test_various_joins.svg',
)
示例12: test_arc_error
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_arc_error():
# Don't allow drawing an arc without a center or radius.
p = Pen()
assert_raises(
TypeError,
lambda: p.arc_left(90)
)
assert_raises(
TypeError,
lambda: p.arc_right(90)
)
示例13: test_repr
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [as 别名]
def test_repr():
p = Pen()
p.fill_mode()
p.move_to((0, 0))
p.turn_to(0)
p.line_forward(1)
p.arc_left(90, 1)
path = p.paper.paths[0]
line, arc = path.segments
assert_equal(
repr(line),
'LineSegment(a=Point(x=0, y=0), b=Point(x=1.0, y=0.0))'
)
assert_equal(
repr(arc),
(
'ArcSegment(a=Point(x=1.0, y=0.0), b=Point(x=2.0, y=0.9999999999999999), '
'center=Point(x=1.0, y=1.0), radius=1, start_heading=0, end_heading=90)'
)
)
示例14: test_arc_start_slant_bug
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [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)
示例15: test_arc_angle_error
# 需要导入模块: from canoepaddle.pen import Pen [as 别名]
# 或者: from canoepaddle.pen.Pen import arc_left [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