<commit_before>﻿using System;
using System.Globalization;
using System.Collections.Generic;
using NGraphics.Interfaces;

namespace NGraphics
{
	public abstract class PathOp
	{
		public abstract Point GetContinueCurveControlPoint ();
	}
	public class MoveTo : PathOp
	{
		public Point Point;
	  public bool IsAbsolute;

	  public MoveTo (Point point, bool isAbsolute)
	  {
	    Point = point;
	    IsAbsolute = isAbsolute;
	  }

	  public MoveTo (double x, double y, bool isAbsolute)
			: this (new Point (x, y), isAbsolute)
		{
		}

		public override Point GetContinueCurveControlPoint ()
		{
			return Point;
		}
	}

    public class StartFigure : PathOp
    {
        public override Point GetContinueCurveControlPoint()
        {
            throw new NotImplementedException();
        }
    }

	public class LineTo : PathOp
	{
		public Point Start;
		public Point End;
		public LineTo (Point point)
		{
			Start = point;
		}

        public LineTo(Point start, Point end)
        {
            Start = start;
            End = end;
        }
		public LineTo (double x, double y, bool isAbsolute)
			: this (new Point (x, y, isAbsolute))
		{
		}
		public override Point GetContinueCurveControlPoint ()
		{
			return Start;
		}
	}
	public class ArcTo : PathOp
	{
		public Size Radius;
		public bool LargeArc;
		public bool SweepClockwise;
		public Point Point;
		public ArcTo (Size radius, bool largeArc, bool sweepClockwise, Point point)
		{
			Radius = radius;
			LargeArc = largeArc;
			SweepClockwise = sweepClockwise;
			Point = point;
		}
		public override Point GetContinueCurveControlPoint ()
		{
			return Point;
		}
		public void GetCircles (Point prevPoint, out Point circle1Center, out Point circle2Center)
		{
			//Following explanation at http://mathforum.org/library/drmath/view/53027.html'
			if (Radius.Width == 0)
				throw new Exception ("radius x of zero");
			if (Radius.Height == 0)
				throw new Exception ("radius y of zero");
			var p1 = prevPoint;
			var p2 = Point;
			if (p1 == p2)
				throw new Exception ("coincident points gives infinite number of Circles");
			// delta x, delta y between points
			var dp = p2 - p1;
			// dist between points
			var q = dp.Distance;
			if (q > 2.0*Radius.Diagonal)
				throw new Exception ("separation of points > diameter");
			// halfway point
			var p3 = (p1 + p2) / 2;
			// distance along the mirror line
			var xd = Math.Sqrt (Radius.Width*Radius.Width - (q/2)*(q/2));
			var yd = Math.Sqrt (Radius.Height*Radius.Height - (q/2)*(q/2));

			circle1Center = new Point (p3.X - yd * dp.Y / q, p3.Y + xd * dp.X / q);
			circle2Center = new Point (p3.X + yd * dp.Y / q, p3.Y - xd * dp.X / q);
		}
	}
	public class CurveTo : PathOp
	{
		public Point Start;
		public Point FirstControlPoint;
		public Point SecondControlPoint;
		public Point End;
		public CurveTo (Point start, Point firstControlPoint, Point secondControlPoint)
		{
			Start = start;
			FirstControlPoint = firstControlPoint;
			SecondControlPoint = secondControlPoint;
		}

        public CurveTo(Point start, Point firstControlPoint, Point secondControlPoint, Point end)
        {
            Start = start;
            FirstControlPoint = firstControlPoint;
            SecondControlPoint = secondControlPoint;
            End = end;
        }

		public override Point GetContinueCurveControlPoint ()
		{
			return FirstControlPoint.ReflectedAround (SecondControlPoint);
		}
	}
	public class ClosePath : PathOp
	{
		public override Point GetContinueCurveControlPoint ()
		{
			throw new NotSupportedException ();
		}
	}

	public class Path : Element
	{
		public readonly List<PathOp> Operations = new List<PathOp> ();

		public Path (IEnumerable<PathOp> operations, Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
			Operations.AddRange (operations);
		}
		public Path (Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
		}

		protected override void DrawElement (ICanvas canvas)
		{
			canvas.DrawPath (Operations, Pen, Brush);
		}

		void Add (PathOp op)
		{
			Operations.Add (op);
		}


		public void MoveTo (Point point, bool isAbsolute)
		{
			Add (new MoveTo (point, isAbsolute));
		}
		public void MoveTo (double x, double y, bool isAbsolute)
		{
			Add (new MoveTo (x, y, isAbsolute));
		}

		public void LineTo ( Point point)
		{
			Add (new LineTo (point));
		}

        public void LineTo(Point start, Point end)
        {<commit_msg>Adding MoveTo support for 2 points<commit_after>﻿using System;
using System.Globalization;
using System.Collections.Generic;
using NGraphics.Interfaces;

namespace NGraphics
{
	public abstract class PathOp
	{
		public abstract Point GetContinueCurveControlPoint ();
	}
	public class MoveTo : PathOp
	{
		public Point Point;
	  public bool IsAbsolute;
		public Point Start;
		public Point End;
	  public MoveTo (Point point, bool isAbsolute)
	  {
	    Point = point;
	    IsAbsolute = isAbsolute;
	  }

		public MoveTo (double x, double y, bool isAbsolute)
			: this (new Point (x, y), isAbsolute)
		{
		}

		public MoveTo (Point start, Point end, bool isAbsolute)
		{
			Start = start;
			End = end;
			IsAbsolute = isAbsolute;
		}

		public override Point GetContinueCurveControlPoint ()
		{
			return Point;
		}
	}

    public class StartFigure : PathOp
    {
        public override Point GetContinueCurveControlPoint()
        {
            throw new NotImplementedException();
        }
    }

	public class LineTo : PathOp
	{
		public Point Start;
		public Point End;
		public LineTo (Point point)
		{
			Start = point;
		}

        public LineTo(Point start, Point end)
        {
            Start = start;
            End = end;
        }
		public LineTo (double x, double y, bool isAbsolute)
			: this (new Point (x, y, isAbsolute))
		{
		}
		public override Point GetContinueCurveControlPoint ()
		{
			return Start;
		}
	}
	public class ArcTo : PathOp
	{
		public Size Radius;
		public bool LargeArc;
		public bool SweepClockwise;
		public Point Point;
		public ArcTo (Size radius, bool largeArc, bool sweepClockwise, Point point)
		{
			Radius = radius;
			LargeArc = largeArc;
			SweepClockwise = sweepClockwise;
			Point = point;
		}
		public override Point GetContinueCurveControlPoint ()
		{
			return Point;
		}
		public void GetCircles (Point prevPoint, out Point circle1Center, out Point circle2Center)
		{
			//Following explanation at http://mathforum.org/library/drmath/view/53027.html'
			if (Radius.Width == 0)
				throw new Exception ("radius x of zero");
			if (Radius.Height == 0)
				throw new Exception ("radius y of zero");
			var p1 = prevPoint;
			var p2 = Point;
			if (p1 == p2)
				throw new Exception ("coincident points gives infinite number of Circles");
			// delta x, delta y between points
			var dp = p2 - p1;
			// dist between points
			var q = dp.Distance;
			if (q > 2.0*Radius.Diagonal)
				throw new Exception ("separation of points > diameter");
			// halfway point
			var p3 = (p1 + p2) / 2;
			// distance along the mirror line
			var xd = Math.Sqrt (Radius.Width*Radius.Width - (q/2)*(q/2));
			var yd = Math.Sqrt (Radius.Height*Radius.Height - (q/2)*(q/2));

			circle1Center = new Point (p3.X - yd * dp.Y / q, p3.Y + xd * dp.X / q);
			circle2Center = new Point (p3.X + yd * dp.Y / q, p3.Y - xd * dp.X / q);
		}
	}
	public class CurveTo : PathOp
	{
		public Point Start;
		public Point FirstControlPoint;
		public Point SecondControlPoint;
		public Point End;
		public CurveTo (Point start, Point firstControlPoint, Point secondControlPoint)
		{
			Start = start;
			FirstControlPoint = firstControlPoint;
			SecondControlPoint = secondControlPoint;
		}

        public CurveTo(Point start, Point firstControlPoint, Point secondControlPoint, Point end)
        {
            Start = start;
            FirstControlPoint = firstControlPoint;
            SecondControlPoint = secondControlPoint;
            End = end;
        }

		public override Point GetContinueCurveControlPoint ()
		{
			return FirstControlPoint.ReflectedAround (SecondControlPoint);
		}
	}
	public class ClosePath : PathOp
	{
		public override Point GetContinueCurveControlPoint ()
		{
			throw new NotSupportedException ();
		}
	}

	public class Path : Element
	{
		public readonly List<PathOp> Operations = new List<PathOp> ();

		public Path (IEnumerable<PathOp> operations, Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
			Operations.AddRange (operations);
		}
		public Path (Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
		}

		protected override void DrawElement (ICanvas canvas)
		{
			canvas.DrawPath (Operations, Pen, Brush);
		}

		void Add (PathOp op)
		{
			Operations.Add (op);
		}


		public void MoveTo (Point point, bool isAbsolute)
		{
			Add (new MoveTo (point, isAbsolute));
		}
		public void MoveTo (double x, double y, bool isAbsolute)
		{
			Add (new MoveTo (x, y, isAbsolute));
		}

		public void MoveTo (Point start, Point end, bool isAbsolute)
		{
			Add (new MoveTo (start,end, isAbsolute));
		}

		public void LineTo ( Point point)
		{
			Add (new LineTo (point));
		}

        public void LineTo(Point start, Point end)
        {
{'fraction_non_alphanumeric': 0.09433548811219458, 'fraction_numerical': 0.0069025966911361895, 'mean_word_length': 2.8433684210526318, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3465638', 'n_tokens_mistral': 3246, 'n_tokens_neox': 2836, 'n_words': 913}