package speiger.src.coreengine.rendering.guiOld.helper.animations.transitions;

import speiger.src.coreengine.math.value.IValue;
import speiger.src.coreengine.math.value.LiniarValue;

public class LiniarTransition implements ITransition
{
	float offsetValue;
	float duration;
	float selfDelay;
	
	public LiniarTransition(float offset, float duration) 
	{
		offsetValue = offset;
		this.duration = duration;
		selfDelay = 0;
	}
	
	public LiniarTransition(float offset, float duration, float selfDelay) {
		offsetValue = offset;
		this.duration = duration;
		this.selfDelay = selfDelay;
	}
	
	@Override
	public IValue initValue(float baseValue, float currentValue, boolean reverse, float delay, float totalDuration)
	{
		float target = reverse ? baseValue : offsetValue;
		float selfDelay = reverse ? totalDuration - (this.selfDelay + duration) : this.selfDelay;
		return new LiniarValue(delay + selfDelay, duration, currentValue, target);
	}
	
	@Override
	public float getHiddenValue()
	{
		return offsetValue;
	}
	
	@Override
	public float getDuration()
	{
		return duration + selfDelay;
	}
	
}
