package transformer;

import timedistortion.Point;
import timedistortion.ITransform;

public class Manhattan extends AbstractTransformer implements ITransform {
	
//	private static final float speed = -0.1f;
	private static final float speed = 1f;
	private static final float radius = 200f;

//	@Override
//	public void t(Point p) {
//		int max_diff = (ictx.width + ictx.height) / 2;
//		int diff_x = Math.abs(p.dx - ictx.width / 2); 
//		int diff_y = Math.abs(p.dy - ictx.height / 2); 
//		float r = speed * (float)(max_diff - (diff_x + diff_y));
//		float pos = p.ti - r;
//		interpolate_linear(p, pos);
//	}

	@Override
	public void t(Point p) {
//		int max_diff = (ictx.width + ictx.height) / 2;
		int diff_x = Math.abs(p.dx - ictx.width / 2); 
		int diff_y = Math.abs(p.dy - ictx.height / 2); 
//		float r = (float)(max_diff - (diff_x + diff_y));
		float r = (float)(diff_x + diff_y);
		r = Math.max(0f, r - radius);
		float pos = p.ti - speed * r;
		interpolate_linear(p, pos);
	}

}
