def make_plot(intersection_info, save_plot):
    curve1 = intersection_info.curve1
    curve2 = intersection_info.curve2
    intersection_pts = intersection_info.intersections

    ax = curve1.plot(64)
    curve2.plot(64, ax=ax)
    ax.plot(intersection_pts[:, 0],
            intersection_pts[:, 1],
            marker='o',
            linestyle='None',
            color='black')
    ax.axis('scaled')
    _plot_helpers.add_plot_boundary(ax)

    filename = intersection_info.img_filename
    if save_plot:
        # NOTE: This is an abuse of ``current_test``, but we don't need
        #       a full-fledged ``Config``, we **just** need ``save_fig``.
        CONFIG.current_test = filename
        CONFIG.save_fig()
    else:
        plt.title(filename)
        plt.show()

    plt.close(ax.figure)
Beispiel #2
0
def make_plot(intersection_info, save_plot):
    surface1 = intersection_info.surface1
    surface2 = intersection_info.surface2
    ax = surface1.plot(64)
    surface2.plot(64, ax=ax)
    color = None
    for curved_polygon_info in intersection_info.intersections:
        curved_polygon = make_curved_polygon(
            surface1, surface2, curved_polygon_info
        )
        curved_polygon.plot(64, color=color, ax=ax)
        # Color is (R,G,B,A) but we just want (R,G,B).
        color = ax.patches[-1].get_facecolor()[:3]
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    filename = intersection_info.img_filename
    if save_plot:
        # NOTE: This is an abuse of ``current_test``, but we don't need
        #       a full-fledged ``Config``, we **just** need ``save_fig``.
        CONFIG.current_test = filename
        CONFIG.save_fig()
    else:
        plt.title(filename)
        plt.show()
    plt.close(ax.figure)
Beispiel #3
0
def unit_triangle():
    """Image for :class:`.triangle.Triangle` docstring."""
    if NO_IMAGES:
        return

    nodes = np.asfortranarray([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
    triangle = bezier.Triangle(nodes, degree=1)
    ax = triangle.plot(256, color=BLUE)
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    save_image(ax.figure, "unit_triangle.png")
Beispiel #4
0
def helper_parallel_lines(start0, end0, start1, end1, filename):
    """Image for :func:`.parallel_lines_parameters` docstring."""
    if NO_IMAGES:
        return

    figure = plt.figure()
    ax = figure.gca()
    points = stack1d(start0, end0, start1, end1)
    ax.plot(points[0, :2], points[1, :2], marker="o", color=BLUE)
    ax.plot(points[0, 2:], points[1, 2:], marker="o", color=GREEN)
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    save_image(figure, filename)
Beispiel #5
0
def curve_reduce_approx(curve, reduced):
    """Image for :meth:`.curve.Curve.reduce` docstring."""
    if NO_IMAGES:
        return

    ax = curve.plot(256, color=BLUE)
    color = ax.lines[-1].get_color()
    add_patch(ax, curve._nodes, color, alpha=0.25, node_color=color)
    reduced.plot(256, ax=ax, color=GREEN)
    color = ax.lines[-1].get_color()
    add_patch(ax, reduced._nodes, color, alpha=0.25, node_color=color)
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    save_image(ax.figure, "curve_reduce_approx.png")
Beispiel #6
0
def curve_reduce(curve, reduced):
    """Image for :meth:`.curve.Curve.reduce` docstring."""
    if NO_IMAGES:
        return

    figure, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)
    curve.plot(256, ax=ax1, color=BLUE)
    color = ax1.lines[-1].get_color()
    add_patch(ax1, curve._nodes, color)
    reduced.plot(256, ax=ax2, color=BLUE)
    color = ax2.lines[-1].get_color()
    add_patch(ax2, reduced._nodes, color)
    ax1.axis("scaled")
    ax2.axis("scaled")
    _plot_helpers.add_plot_boundary(ax2)
    save_image(figure, "curve_reduce.png")
Beispiel #7
0
def helper_parallel_different(start0, end0, start1, end1, filename):
    """Image for :func:`.parallel_different` docstring."""
    if NO_IMAGES:
        return

    figure = plt.figure()
    ax = figure.gca()

    points = np.vstack([start0, end0, start1, end1])
    ax.plot(points[:2, 0], points[:2, 1], marker='o')
    ax.plot(points[2:, 0], points[2:, 1], marker='o')

    ax.axis('scaled')
    _plot_helpers.add_plot_boundary(ax)

    save_image(figure, filename)
Beispiel #8
0
def curve_elevate(curve, elevated):
    """Image for :meth:`.curve.Curve.elevate` docstring."""
    if NO_IMAGES:
        return

    figure, (ax1, ax2) = plt.subplots(1, 2)
    curve.plot(256, ax=ax1, color=BLUE)
    color = ax1.lines[-1].get_color()
    add_patch(ax1, curve._nodes, color)
    elevated.plot(256, ax=ax2, color=BLUE)
    color = ax2.lines[-1].get_color()
    add_patch(ax2, elevated._nodes, color)
    ax1.axis("scaled")
    ax2.axis("scaled")
    _plot_helpers.add_plot_boundary(ax1)
    ax2.set_xlim(*ax1.get_xlim())
    ax2.set_ylim(*ax1.get_ylim())
    save_image(figure, "curve_elevate.png")
Beispiel #9
0
def unit_triangle():
    """Image for :class:`.surface.Surface` docstring."""
    if NO_IMAGES:
        return

    nodes = np.asfortranarray([
        [0.0, 0.0],
        [1.0, 0.0],
        [0.0, 1.0],
    ])
    surface = bezier.Surface(nodes, degree=1)

    ax = surface.plot(256)

    ax.axis('scaled')
    _plot_helpers.add_plot_boundary(ax)

    save_image(ax.figure, 'unit_triangle.png')
Beispiel #10
0
def make_plot(triangle_index, point_index, save_plot):
    triangle = test_triangle_locate.TRIANGLES[triangle_index]
    point = test_triangle_locate.POINTS[:, [point_index]]
    name = f"test_triangle{triangle_index}_and_point{point_index}"

    ax = triangle.plot(64)
    ax.plot(point[0, :],
            point[1, :],
            color="black",
            marker="o",
            linestyle="None")
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    if save_plot:
        utils.save_fig(name)
    else:
        plt.title(name.replace("_", r"\_"))
        plt.show()
    plt.close(ax.figure)
Beispiel #11
0
def triangle_elevate(triangle, elevated):
    """Image for :meth:`.triangle.Triangle.elevate` docstring."""
    if NO_IMAGES:
        return

    figure, (ax1, ax2) = plt.subplots(1, 2)
    triangle.plot(256, ax=ax1, color=BLUE)
    color = ax1.lines[-1].get_color()
    nodes = triangle._nodes[:, (0, 1, 2, 4, 5)]
    add_patch(ax1, nodes, color)
    elevated.plot(256, ax=ax2, color=BLUE)
    color = ax2.lines[-1].get_color()
    nodes = elevated._nodes[:, (0, 1, 2, 3, 6, 8, 9)]
    add_patch(ax2, nodes, color)
    ax1.axis("scaled")
    ax2.axis("scaled")
    _plot_helpers.add_plot_boundary(ax1)
    ax2.set_xlim(*ax1.get_xlim())
    ax2.set_ylim(*ax1.get_ylim())
    save_image(figure, "triangle_elevate.png")
def make_plot(surface, point):
    if not CONFIG.running:
        return

    ax = surface.plot(64)
    ax.plot(point[:, 0],
            point[:, 1],
            color='black',
            marker='o',
            linestyle='None')

    ax.axis('scaled')
    _plot_helpers.add_plot_boundary(ax)

    if CONFIG.save_plot:
        CONFIG.save_fig()
    else:
        plt.title(CONFIG.current_test)
        plt.show()

    plt.close(ax.figure)
def make_plot(intersection_info, save_plot):
    triangle1 = intersection_info.triangle1
    triangle2 = intersection_info.triangle2
    ax = triangle1.plot(64, color=BLUE)
    triangle2.plot(64, ax=ax, color=GREEN)
    color = RED
    for curved_polygon_info in intersection_info.intersections:
        curved_polygon = make_curved_polygon(triangle1, triangle2,
                                             curved_polygon_info)
        curved_polygon.plot(64, color=color, ax=ax)
        # Color is (R,G,B,A) but we just want (R,G,B).
        color = ax.patches[-1].get_facecolor()[:3]
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    filename = intersection_info.img_filename
    if save_plot:
        utils.save_fig(filename)
    else:
        plt.title(filename)
        plt.show()
    plt.close(ax.figure)
def make_plot(intersection_info, save_plot):
    curve1 = intersection_info.curve1
    curve2 = intersection_info.curve2
    intersection_pts = intersection_info.intersections
    ax = curve1.plot(64, color=BLUE)
    curve2.plot(64, ax=ax, color=GREEN)
    ax.plot(
        intersection_pts[0, :],
        intersection_pts[1, :],
        marker="o",
        linestyle="None",
        color="black",
    )
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    filename = intersection_info.img_filename
    if save_plot:
        utils.save_fig(filename)
    else:
        plt.title(filename)
        plt.show()
    plt.close(ax.figure)
Beispiel #15
0
def curve_reduce(curve, reduced):
    """Image for :meth:`.curve.Curve.reduce` docstring."""
    if NO_IMAGES:
        return

    figure, (ax1, ax2) = plt.subplots(1, 2)

    curve.plot(256, ax=ax1)
    color = ax1.lines[-1].get_color()
    add_patch(ax1, curve._nodes, color)

    reduced.plot(256, ax=ax2)
    color = ax2.lines[-1].get_color()
    add_patch(ax2, reduced._nodes, color)

    ax1.axis('scaled')
    ax2.axis('scaled')
    _plot_helpers.add_plot_boundary(ax2)
    ax1.set_xlim(*ax1.get_xlim())
    ax1.set_ylim(*ax1.get_ylim())

    save_image(figure, 'curve_reduce.png')
Beispiel #16
0
def make_plot(surface, point):
    # NOTE: We import the plotting library at runtime to
    #       avoid the cost for users that only want to compute.
    #       The ``matplotlib`` import is a tad expensive.
    import matplotlib.pyplot as plt
    import seaborn

    seaborn.set()  # Required in `seaborn >= 0.8`
    ax = surface.plot(64)
    ax.plot(point[0, :],
            point[1, :],
            color="black",
            marker="o",
            linestyle="None")
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    if CONFIG.save_plot:
        CONFIG.save_fig()
    else:
        plt.title(CONFIG.current_test)
        plt.show()
    plt.close(ax.figure)
Beispiel #17
0
def surface_elevate(surface, elevated):
    """Image for :meth:`.surface.Surface.elevate` docstring."""
    if NO_IMAGES:
        return

    figure, (ax1, ax2) = plt.subplots(1, 2)

    surface.plot(256, ax=ax1)
    color = ax1.lines[-1].get_color()
    nodes = surface._nodes[(0, 1, 2, 4, 5), :]
    add_patch(ax1, nodes, color)

    elevated.plot(256, ax=ax2)
    color = ax2.lines[-1].get_color()
    nodes = elevated._nodes[(0, 1, 2, 3, 6, 8, 9), :]
    add_patch(ax2, nodes, color)

    ax1.axis('scaled')
    ax2.axis('scaled')
    _plot_helpers.add_plot_boundary(ax1)
    ax2.set_xlim(*ax1.get_xlim())
    ax2.set_ylim(*ax1.get_ylim())

    save_image(figure, 'surface_elevate.png')
Beispiel #18
0
    def _call_function_under_test(ax, **kwargs):
        from bezier import _plot_helpers

        return _plot_helpers.add_plot_boundary(ax, **kwargs)