Пример #1
0
 private void SetAxis(Line2D axis, Vector2D startPoint, Vector2D endPoint)
 {
     axis.StartPoint  = startPoint;
     axis.EndPoint    = endPoint;
     axis.RenderLayer = renderLayer;
     axis.Clip(clippingBounds);
 }
Пример #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);
 }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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;
		}
Пример #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);
		}
Пример #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);
		}
Пример #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);
		}
Пример #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);
		}
Пример #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);
		}
Пример #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);
		}
Пример #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);
		}
Пример #18
0
		private void MoveLineEndpoint(Vector2D point, int index)
		{
			Line2D line = lines[index - 1];
			line.EndPoint = ToQuadratic(point, viewport, drawArea);
			line.Clip(clippingBounds);
		}