Exemplo n.º 1
0
 private void SetAxis(Line2D axis, Vector2D startPoint, Vector2D endPoint)
 {
     axis.StartPoint  = startPoint;
     axis.EndPoint    = endPoint;
     axis.RenderLayer = renderLayer;
     axis.Clip(clippingBounds);
 }
Exemplo n.º 2
0
 public void LineAboveViewportIsHidden()
 {
     var line = new Line2D(new Vector2D(0.2f, -1.0f), new Vector2D(0.6f, -1.5f), Color.Red);
     line.Clip(Rectangle.One);
     Assert.AreEqual(new Vector2D(0.2f, -1.0f), line.StartPoint);
     Assert.AreEqual(new Vector2D(0.6f, -1.5f), line.EndPoint);
     Assert.IsFalse(line.IsVisible);
 }
Exemplo n.º 3
0
        public void LineEnteringBottomEdgeIsClipped()
        {
            var line = new Line2D(new Vector2D(0.4f, 0.5f), new Vector2D(0.3f, 1.5f), Color.Red);

            line.Clip(Rectangle.FromCenter(0.5f, 0.5f, 0.5f, 0.5f));
            Assert.AreEqual(new Vector2D(0.4f, 0.5f), line.StartPoint);
            Assert.AreEqual(new Vector2D(0.375f, 0.75f), line.EndPoint);
            Assert.IsTrue(line.IsVisible);
        }
Exemplo n.º 4
0
        public void LineExitingBottomEdgeIsClipped()
        {
            var line = new Line2D(new Vector2D(0.1f, 1.5f), new Vector2D(0.2f, 0.5f), Color.Red);

            line.Clip(Rectangle.One);
            Assert.AreEqual(new Vector2D(0.15f, 1.0f), line.StartPoint);
            Assert.AreEqual(new Vector2D(0.2f, 0.5f), line.EndPoint);
            Assert.IsTrue(line.IsVisible);
        }
Exemplo n.º 5
0
        public void LineCrossingViewportIsClippedAtStartAndEnd()
        {
            var line = new Line2D(new Vector2D(-1.0f, 0.4f), new Vector2D(2.0f, 0.6f), Color.Red);

            line.Clip(Rectangle.FromCenter(0.5f, 0.5f, 0.5f, 0.5f));
            Assert.IsTrue(line.StartPoint.IsNearlyEqual(new Vector2D(0.25f, 0.4833f)));
            Assert.IsTrue(line.EndPoint.IsNearlyEqual(new Vector2D(0.75f, 0.5167f)));
            Assert.IsTrue(line.IsVisible);
        }
Exemplo n.º 6
0
        public void LineExitingLeftEdgeIsClipped()
        {
            var line = new Line2D(new Vector2D(0.5f, 0.4f), new Vector2D(-0.5f, 0.4f), Color.Red);

            line.Clip(Rectangle.FromCenter(0.5f, 0.5f, 0.5f, 0.5f));
            Assert.AreEqual(new Vector2D(0.5f, 0.4f), line.StartPoint);
            Assert.AreEqual(new Vector2D(0.25f, 0.4f), line.EndPoint);
            Assert.IsTrue(line.IsVisible);
        }
Exemplo n.º 7
0
        public void LineNotCrossingViewportIsHidden()
        {
            var line = new Line2D(new Vector2D(-1.0f, 0.2f), new Vector2D(0.2f, -1.0f), Color.Red);

            line.Clip(Rectangle.One);
            Assert.AreEqual(new Vector2D(-1.0f, 0.2f), line.StartPoint);
            Assert.AreEqual(new Vector2D(0.2f, -1.0f), line.EndPoint);
            Assert.IsFalse(line.IsVisible);
        }
Exemplo n.º 8
0
        public void LineRightOfViewportIsHidden()
        {
            var line = new Line2D(new Vector2D(1.2f, 0.5f), new Vector2D(1.6f, 0.5f), Color.Red);

            line.Clip(Rectangle.One);
            Assert.AreEqual(new Vector2D(1.2f, 0.5f), line.StartPoint);
            Assert.AreEqual(new Vector2D(1.6f, 0.5f), line.EndPoint);
            Assert.IsFalse(line.IsVisible);
        }
Exemplo n.º 9
0
        public void LineInsideViewportIsNotClipped()
        {
            var line = new Line2D(new Vector2D(0.4f, 0.4f), new Vector2D(0.6f, 0.5f), Color.Red);

            line.Clip(Rectangle.One);
            Assert.AreEqual(new Vector2D(0.4f, 0.4f), line.StartPoint);
            Assert.AreEqual(new Vector2D(0.6f, 0.5f), line.EndPoint);
            Assert.IsTrue(line.IsVisible);
        }
Exemplo n.º 10
0
		private void UpdateLine(int i)
		{
			Line2D line = lines[i - 1];
			line.StartPoint = ToQuadratic(points[i - 1], viewport, drawArea);
			line.EndPoint = ToQuadratic(points[i], viewport, drawArea);
			line.RenderLayer = graph.RenderLayer + RenderLayerOffset;
			line.Clip(clippingBounds);
			if (!graph.IsVisible)
				line.IsVisible = false;
		}
Exemplo n.º 11
0
		private void InsertPointAt(Vector2D point, int index)
		{
			if (index > 0)
				MoveLineEndpoint(point, index);
			var line = new Line2D(ToQuadratic(point, viewport, drawArea),
				ToQuadratic(points[index], viewport, drawArea), Color);
			line.Clip(clippingBounds);
			lines.Insert(index, line);
			points.Insert(index, point);
		}
Exemplo n.º 12
0
		private void AddPointToEnd(Vector2D point)
		{
			points.Add(point);
			if (points.Count <= 1)
				return;
			var line = new Line2D(ToQuadratic(points[points.Count - 2], viewport, drawArea),
				ToQuadratic(point, viewport, drawArea), Color);
			line.Clip(clippingBounds);
			lines.Add(line);
		}
Exemplo n.º 13
0
		public void LineCrossingViewportIsClippedAtStartAndEnd()
		{
			var line = new Line2D(new Vector2D(-1.0f, 0.4f), new Vector2D(2.0f, 0.6f), Color.Red);
			line.Clip(Rectangle.FromCenter(0.5f, 0.5f, 0.5f, 0.5f));
			Assert.IsTrue(line.StartPoint.IsNearlyEqual(new Vector2D(0.25f, 0.4833f)));
			Assert.IsTrue(line.EndPoint.IsNearlyEqual(new Vector2D(0.75f, 0.5167f)));
			Assert.IsTrue(line.IsVisible);
		}
Exemplo n.º 14
0
		public void LineExitingBottomEdgeIsClipped()
		{
			var line = new Line2D(new Vector2D(0.1f, 1.5f), new Vector2D(0.2f, 0.5f), Color.Red);
			line.Clip(Rectangle.One);
			Assert.AreEqual(new Vector2D(0.15f, 1.0f), line.StartPoint);
			Assert.AreEqual(new Vector2D(0.2f, 0.5f), line.EndPoint);
			Assert.IsTrue(line.IsVisible);
		}
Exemplo n.º 15
0
		public void LineEnteringBottomEdgeIsClipped()
		{
			var line = new Line2D(new Vector2D(0.4f, 0.5f), new Vector2D(0.3f, 1.5f), Color.Red);
			line.Clip(Rectangle.FromCenter(0.5f, 0.5f, 0.5f, 0.5f));
			Assert.AreEqual(new Vector2D(0.4f, 0.5f), line.StartPoint);
			Assert.AreEqual(new Vector2D(0.375f, 0.75f), line.EndPoint);
			Assert.IsTrue(line.IsVisible);
		}
Exemplo n.º 16
0
		public void LineExitingLeftEdgeIsClipped()
		{
			var line = new Line2D(new Vector2D(0.5f, 0.4f), new Vector2D(-0.5f, 0.4f), Color.Red);
			line.Clip(Rectangle.FromCenter(0.5f, 0.5f, 0.5f, 0.5f));
			Assert.AreEqual(new Vector2D(0.5f, 0.4f), line.StartPoint);
			Assert.AreEqual(new Vector2D(0.25f, 0.4f), line.EndPoint);
			Assert.IsTrue(line.IsVisible);
		}
Exemplo n.º 17
0
		public void LineInsideViewportIsNotClipped()
		{
			var line = new Line2D(new Vector2D(0.4f, 0.4f), new Vector2D(0.6f, 0.5f), Color.Red);
			line.Clip(Rectangle.One);
			Assert.AreEqual(new Vector2D(0.4f, 0.4f), line.StartPoint);
			Assert.AreEqual(new Vector2D(0.6f, 0.5f), line.EndPoint);
			Assert.IsTrue(line.IsVisible);
		}
Exemplo n.º 18
0
		private void MoveLineEndpoint(Vector2D point, int index)
		{
			Line2D line = lines[index - 1];
			line.EndPoint = ToQuadratic(point, viewport, drawArea);
			line.Clip(clippingBounds);
		}