Blame mono/Assistance/GuidelineLine.cs

cfceb0
using System;
cfceb0
using System.Collections.Generic;
cfceb0
cfceb0
namespace Assistance {
cfceb0
	public class GuidelineLine: Guideline {
cfceb0
		protected Point p0, p1;
cfceb0
		protected Point direction;
cfceb0
		
cfceb0
		public GuidelineLine(Point p0, Point p1) {
cfceb0
			this.p0 = p0;
cfceb0
			this.p1 = p1;
cfceb0
			direction = (p1 - p0).normalize();
cfceb0
		}
cfceb0
		
b82ef4
		public override void draw(Cairo.Context context, bool active) {
cfceb0
			Point pp0 = p0;
cfceb0
			Point pp1 = p1;
b82ef4
			Rectangle bounds = Drawing.Helper.getBounds(context);
b82ef4
			Geometry.truncateInfiniteLine(bounds, ref pp0, ref pp1);
b82ef4
			
b82ef4
			context.Save();
b82ef4
			(active ? penActive : pen).apply(context);
b82ef4
			context.MoveTo(pp0.x, pp0.y);
b82ef4
			context.LineTo(pp1.x, pp1.y);
b82ef4
			context.Stroke();
b82ef4
			context.Restore();
cfceb0
		}
cfceb0
		
702257
		public override Track.Point transformPoint(Track.Point p) {
702257
			Track.Point np = p;
702257
			np.position = Point.dot(p.position - p0, direction)*direction + p0;
589f9a
			return np;
cfceb0
		}
cfceb0
	}
cfceb0
}
cfceb0