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