FadeAnimation erstellt

This commit is contained in:
ngb
2022-07-17 08:54:34 +02:00
parent d87e455e9d
commit aad53d51d1

View File

@@ -0,0 +1,44 @@
package schule.ngb.zm.anim;
import schule.ngb.zm.Color;
import schule.ngb.zm.Constants;
import schule.ngb.zm.shapes.Shape;
import java.util.function.DoubleUnaryOperator;
@SuppressWarnings( "unused" )
public class FadeAnimation extends Animation<Shape> {
public static final int FADE_IN = 255;
public static final int FADE_OUT = 0;
private Shape object;
private Color fill, stroke;
private int fillAlpha, strokeAlpha, tAlpha;
public FadeAnimation( Shape object, int alpha, int runtime, DoubleUnaryOperator easing ) {
super(runtime, easing);
this.object = object;
fill = object.getFillColor();
fillAlpha = fill.getAlpha();
stroke = object.getStrokeColor();
strokeAlpha = stroke.getAlpha();
tAlpha = alpha;
}
@Override
public Shape getAnimationTarget() {
return object;
}
@Override
public void interpolate( double e ) {
object.setFillColor(new Color(fill, (int) Constants.interpolate(fillAlpha, tAlpha, e)));
object.setStrokeColor(new Color(stroke, (int) Constants.interpolate(strokeAlpha, tAlpha, e)));
}
}