mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-10-12 01:45:18 +02:00
FadeAnimation erstellt
This commit is contained in:
44
src/main/java/schule/ngb/zm/anim/FadeAnimation.java
Normal file
44
src/main/java/schule/ngb/zm/anim/FadeAnimation.java
Normal 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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user