예제 #1
0
def test_sphere():
    # Draw connected spheres, which are small enough to just be 8 points in a
    # 2x2x2 cube.
    a = Sphere((0.5, 0.5, 0.5), 1)
    b = Sphere((-0.5, -0.5, -0.5), 1)
    points = set(a.render()) | set(b.render())

    layers = draw_layers(points, on='#', off='-')

    assert_equal(
        '\n\n'.join(layers),
        dedent('''
            ---
            ##-
            ##-

            -##
            ###
            ##-

            -##
            -##
            ---
        ''').strip(),
    )
예제 #2
0
def test_plane_sphere_boolean():
    # Draw a sphere and slice off the top half.
    sphere = Sphere((0, 0, 0), 3)
    plane = Plane((0, 0, 0), (0, 0, 1), sphere.bounds())
    points = set(sphere.render()) - set(plane.render())

    layers = draw_layers(points, on='#', off='-')

    assert_equal(
        '\n\n'.join(layers),
        dedent('''
            --#--
            -###-
            #####
            -###-
            --#--

            -###-
            #####
            #####
            #####
            -###-
        ''').strip(),
    )
from volume import draw_layers, Sphere

a = Sphere((0, 0, 0), 10)
b = Sphere((5, 5, 5), 10)

points = set(a.render()) | set(b.render())

sep = '-' * 80
print(sep)
for layer in draw_layers(points):
    print(layer)
    print(sep)

print(len(points))