Skip to content

Instantly share code, notes, and snippets.

@grkvlt
Created October 12, 2017 15:17
Show Gist options
  • Save grkvlt/aa385d50d6d08260bb1e6a65555519ec to your computer and use it in GitHub Desktop.
Save grkvlt/aa385d50d6d08260bb1e6a65555519ec to your computer and use it in GitHub Desktop.
Exploring Iterated Function Systems
/** Perform an {@link Consumer action} with a disposable {@link Graphics2D graphics context}. */
public static void context(BiConsumer<Throwable,String> handler,
Graphics graphics, Consumer<Graphics2D> action) {
Graphics2D g = (Graphics2D) graphics.create();
try {
action.accept(g);
} catch (Throwable t) {
handler.accept(t, "Error executing graphics context action");
} finally {
g.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment