Blame mono/Assistance/GuidelineLine.cs

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