當前位置: 首頁>>代碼示例>>Python>>正文


Python Pen.arc_right方法代碼示例

本文整理匯總了Python中canoepaddle.Pen.arc_right方法的典型用法代碼示例。如果您正苦於以下問題:Python Pen.arc_right方法的具體用法?Python Pen.arc_right怎麽用?Python Pen.arc_right使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在canoepaddle.Pen的用法示例。


在下文中一共展示了Pen.arc_right方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_arc_segment_bounds

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import arc_right [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)
    )
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:101,代碼來源:test_bounds.py

示例2: return

# 需要導入模塊: from canoepaddle import Pen [as 別名]
# 或者: from canoepaddle.Pen import arc_right [as 別名]
    a = 12
    b = 0.03
    c = 0.2
    d = 1.5
    e = 0.5
    wobble = a * math.exp(-b * n) * math.sin(c * n + d * n**e)
    return (
        Angle(-24 + wobble),
        Angle(24 + wobble),
    )

center_heading = Heading(90)
center = p.position

p.turn_to(center_heading)

num_layers = 26
for layer in range(num_layers):
    lo, hi = f(layer)
    lo = center_heading + lo
    hi = center_heading + hi

    p.arc_right((p.heading - lo) + 90, center=center)
    p.arc_left(180, 1)

    p.arc_left((hi - p.heading) + 90, center=center)
    if layer < (num_layers - 1):
        p.arc_right(180, 1)

print(p.paper.format_svg(resolution=720 / p.paper.bounds().width))
開發者ID:christian-oudard,項目名稱:canoepaddle,代碼行數:32,代碼來源:spaghetti.py


注:本文中的canoepaddle.Pen.arc_right方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。