package speiger.src.coreengine.rendering.guiOld.helper.constrains;

import speiger.src.collections.floats.functions.FloatSupplier;

public class DynamicConstrain extends Constrain
{
	FloatSupplier function;
	boolean invert = false;
	
	public DynamicConstrain(FloatSupplier function)
	{
		this.function = function;
	}
	
	public DynamicConstrain setInverted(boolean invert)
	{
		this.invert = invert;
		return this;
	}
	
	@Override
	public void apply()
	{
		set(invert ? get(target.toWidth()) - function.getAsFloat() : function.getAsFloat());
	}
	
}
