Refactor set_graphics.