class Interpolate { float value; float startValue; float endValue; int totalFrames; int currentFrame; int type; Interpolate(float s, float e, int tf, int t) { this.value = 0; this.startValue = s; this.endValue = e; this.totalFrames = tf; this.currentFrame = 0; this.type = t; }; void step() { if (this.type == INTERPOLATE_LINEAR) { calculateLinearValue(); } this.currentFrame++; } void calculateLinearValue() { // step is a linear amount along start to end float stepValue = (this.endValue - this.startValue) / this.totalFrames; this.value = this.startValue + (stepValue * this.currentFrame); } float getValue() { if (this.getFinished()) { return this.endValue; } else { return this.value; } } boolean getFinished() { return (this.currentFrame >= this.totalFrames); } void start() { this.value = this.startValue; // println("start: this.value = " + this.value); } void setValue(float v) { this.value = v; } void setStartValue(float sv) { this.startValue = sv; } float getStartValue() { return startValue; } void setEndValue(float ev) { this.endValue = ev; } float getEndValue() { return this.endValue; } void setTotalFrames(int tf) { this.totalFrames = tf; } void setCurrentFrame(int cf) { this.currentFrame = cf; } void setType(int t) { this.type = t; } };