public class Animator { public ParamSet p; public Bifurcator bif; public LGraph lg; public boolean zoomed; public int zoomState; public int zoomMax = 40; public int xCurrent; public boolean reverse; public int zAreaLeft; private float lastX = 0; private float lastY = 0; private int iteration = 0; private float[] seq; private PImage zoomImage; public Animator(ParamSet p, Bifurcator bif, LGraph lg) { this.p = p; this.bif = bif; this.lg = lg; zoomed = false; zoomState = 0; xCurrent = round(bif.rToXPos(p.rCurrent)); } public void update() { if(zoomed == false) { pushMatrix(); translate(bif.xPos, bif.yPos); fill(255); stroke(lineRed); rect(xCurrent, 0, zoomState, bif.h-1); popMatrix(); if(reverse) zoomState--; else zoomState += 3; if(xCurrent + zoomState >= bif.w) { zoomed = true; lg.clear(); seq = lg.seq; // Store zoomImage zoomImage = get(bif.xPos, bif.yPos, zoomMax+2, bif.h); zAreaLeft = xCurrent-zoomState-1; } } else { pushMatrix(); translate(lg.xPos, lg.yPos); float pRng = p.pMax - p.pMin; stroke(lineRed); float x = iteration * lg.spacing; float y = (lg.h - (lg.next() - p.pMin) / pRng * (lg.h-1)); line(lastX, lastY, x, y); lastX = x; lastY = y; stroke(0, 20); line(0, y, lg.w, y); popMatrix(); // Update the other thing image(zoomImage, bif.xPos, bif.yPos); stroke(0, 20); line(bif.xPos+xCurrent, y-1, bif.xPos+xCurrent+zoomState, y-1); if(iteration < seq.length) iteration++; } } }