(2.5, 10), (5, 10), (10, 5), (10, 2.5), (5, 0), (2.5, 0), (0, 2.5), (0, 5) ]) # Initialize the algorithm v = Voronoi(polygon) # Attach a Voronoi observer that visualizes the Voronoi diagram every step v.attach_observer( VoronoiObserver( # Settings to pass into the visualizer's plot_all() method. # - By default, the observer uses a set of minimalistic presets that are useful for visualizing during # construction, clipping and the final result. Have a look at Presets.construction, Presets.clipping and # Presets.final. # - These settings below will update the default presets used by the observer. For example, by default, # the arc_labels are not shown, but below we can enable the arc labels. Other parameters can be found in # the visualizer's plot_all() method. settings=dict(arc_labels=True, site_labels=True), # Callback that saves the figure every step # If no callback is provided, it will simply display the figure in a matplotlib window callback=lambda observer, figure: figure.savefig(f"output/voronoi/{observer.n_messages:02d}.png") ) ) # Attach observer that visualizes the tree every step. This is a binary tree data structure that keeps track of where # the arcs and the breakpoints between the arcs are going. v.attach_observer( TreeObserver( # Callback that saves the figure every step # If no callback is provided, it will render the figure in a window
# ] # Initialize the algorithm v = Voronoi(triangle) # Optional: attach observer that visualizes Voronoi diagram every step v.attach_observer( VoronoiObserver( # Settings to put into the visualizer settings=dict(polygon=True, edges=True, vertices=True, sites=True, outgoing_edges=False, border_to_site=False, scale=1, edge_labels=False, site_labels=False, triangles=False, arcs=False), # Callback that saves the figure every step callback=lambda observer, figure: figure.savefig( f"output/{observer.n_messages:02d}.png"))) # Make the output directory if not os.path.exists("output"): os.mkdir("output") # Start the procedure