예제 #1
0
def test_plane():
    bounds = Box([(0, 3), (0, 3), (0, 3)])
    plane = Plane((1.5, 1.5, 1.5), (1, 1, 1), bounds)
    field = set(bounds.render())
    points = field - set(plane.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(),
    )