asclass Animation { int w = 128, h = 128; double fps = 20; Graphics2D g; *() {} *(int *w, int *h) {} void setSize(int w, int h) { this.w = w; this.h = h; } void setGraphics(Graphics2D g) { this.g = g; } // override me void start {} // override me void paint {} // override me void nextFrame {} BufferedImage toImage() { var img = whiteImage(w, h); setGraphics(createGraphics(img)); paint(); ret img; } }