1 21 package proguard.gui.splash; 22 23 import java.awt.Color ; 24 25 30 public class LinearColor implements VariableColor 31 { 32 private Color fromValue; 33 private Color toValue; 34 private Timing timing; 35 36 private double cachedTiming = -1.0; 37 private Color cachedColor; 38 39 40 46 public LinearColor(Color fromValue, Color toValue, Timing timing) 47 { 48 this.fromValue = fromValue; 49 this.toValue = toValue; 50 this.timing = timing; 51 } 52 53 54 56 public Color getColor(long time) 57 { 58 double t = timing.getTiming(time); 59 if (t != cachedTiming) 60 { 61 cachedTiming = t; 62 cachedColor = 63 t == 0.0 ? fromValue : 64 t == 1.0 ? toValue : 65 new Color ((int)(fromValue.getRed() + t * (toValue.getRed() - fromValue.getRed())), 66 (int)(fromValue.getGreen() + t * (toValue.getGreen() - fromValue.getGreen())), 67 (int)(fromValue.getBlue() + t * (toValue.getBlue() - fromValue.getBlue()))); 68 } 69 70 return cachedColor; 71 } 72 } 73 | Popular Tags |