Line2D Clip Method Delta Engine Documentation

Namespace: DeltaEngine.Rendering2D.Shapes
Assembly: DeltaEngine.Rendering2D.Shapes (in DeltaEngine.Rendering2D.Shapes.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public void Clip(
	Rectangle clippingBounds
)
Remarks

Tests: DeltaEngine.Rendering2D.Shapes.Tests.Line2DTests
Examples

10 unit tests call DeltaEngine.Rendering2D.Shapes.Line2D.Clip(DeltaEngine.Datatypes.Rectangle)
[Test, CloseAfterFirstFrame]
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);
}
[Test, CloseAfterFirstFrame]
public void LineEnteringLeftEdgeIsClipped()
{
    var line = new Line2D(new Vector2D(-0.5f, 0.1f), new Vector2D(0.5f, 0.2f), Color.Red);
    line.Clip(Rectangle.One);
    Assert.AreEqual(new Vector2D(0.0f, 0.15f), line.StartPoint);
    Assert.AreEqual(new Vector2D(0.5f, 0.2f), line.EndPoint);
    Assert.IsTrue(line.IsVisible);
}
[Test, CloseAfterFirstFrame]
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);
}
See Also