public TimeEffect getEffect(int hours, int minutes, int seconds) { TimeEffect newEffect = new TimeEffect(hours, minutes); Bracket effects = getEffectBracket(hours, minutes); int minPrev = effects.prior.minutesSince(hours, minutes); minPrev *= 60; minPrev += seconds; int minNext = effects.next.minutesUntil(hours, minutes); minNext *= 60; minNext -= seconds; float percentComplete = (float) (minPrev / (double) (minPrev + minNext)); // System.out.println(minPrev + ":" + minNext + ":" + percentComplete); // set colors for (Integer cid : effects.prior.colors.keySet()) { Color newColor = getColor(effects.prior, effects.next, cid, percentComplete); newEffect.colors.put(cid, newColor); } // entropy newEffect.entropy = easingFunction.valueAt(percentComplete, effects.prior.entropy, effects.next.entropy); return newEffect; }
private Color getColor(TimeEffect prior, TimeEffect next, int cid, float percentComplete) { Color priorColor = prior.getColor(cid); Color nextColor = next.getColor(cid); float r1 = priorColor.getRed(); float r2 = nextColor.getRed(); float g1 = priorColor.getGreen(); float g2 = nextColor.getGreen(); float b1 = priorColor.getBlue(); float b2 = nextColor.getBlue(); float r3 = easingFunction.valueAt(percentComplete, r1, r2); float g3 = easingFunction.valueAt(percentComplete, g1, g2); float b3 = easingFunction.valueAt(percentComplete, b1, b2); return new Color((int) r3, (int) g3, (int) b3); }