Blame mono/Assistance/Track.cs

cfceb0
using System;
cfceb0
using System.Drawing;
cfceb0
using System.Drawing.Imaging;
cfceb0
using System.Collections.Generic;
cfceb0
cfceb0
namespace Assistance {
cfceb0
	public class Track {
cfceb0
		public static readonly Pen pen = new Pen(Brushes.DarkGreen, 3f);
cfceb0
		public static readonly Pen penPreview = new Pen(new SolidBrush(Color.FromArgb(64, Color.DarkGreen)), 1f);
cfceb0
	
cfceb0
		public readonly List<point> points = new List<point>();</point></point>
cfceb0
cfceb0
		public Rectangle getBounds() {
cfceb0
			if (points.Count == 0)
cfceb0
				return new Rectangle();
cfceb0
			Rectangle bounds = new Rectangle(points[0]);
cfceb0
			foreach(Point p in points)
cfceb0
				bounds = bounds.expand(p);
cfceb0
			return bounds.inflate(Math.Max(pen.Width, penPreview.Width) + 2.0);
cfceb0
		}
cfceb0
cfceb0
		public void draw(Graphics g, bool preview = false) {
cfceb0
			if (points.Count < 2)
cfceb0
				return;
cfceb0
			PointF[] ps = new PointF[points.Count];
cfceb0
			for(int i = 0; i < ps.Length; ++i)
cfceb0
				ps[i] = points[i].toFloat();
cfceb0
			g.DrawLines(preview ? penPreview : pen, ps);
cfceb0
		}
cfceb0
	}
cfceb0
}
cfceb0