本文整理汇总了C#中Rectangle.Clip方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Clip方法的具体用法?C# Rectangle.Clip怎么用?C# Rectangle.Clip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Clip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawRectangle
public void DrawRectangle(Rectangle bounds, int x1, int y1, int width, int height, int color)
{
var actual_rectangle = new Rectangle(x1, y1, width, height);
actual_rectangle.Clip(bounds);
if (actual_rectangle.IsEmpty)
return;
DrawRectangle((int)actual_rectangle.X, (int)actual_rectangle.Y, (int)actual_rectangle.Width, (int)actual_rectangle.Height, color);
}
示例2: Clip_area_contains_original__no_clipping
public void Clip_area_contains_original__no_clipping()
{
var r1 = new Rectangle(25, 50, 75, 100);
r1.Clip(new Rectangle(0, 0, 200, 200));
Assert.AreEqual(25, r1.X);
Assert.AreEqual(50, r1.Y);
Assert.AreEqual(75, r1.Width);
Assert.AreEqual(100, r1.Height);
}
示例3: Clips_TopLeft_Preserves_RightBottom
public void Clips_TopLeft_Preserves_RightBottom()
{
var r1 = new Rectangle(-25, -50, 75, 100);
var old_right = r1.Right;
var old_bottom = r1.Bottom;
r1.Clip(new Rectangle(0, 0, 200, 300));
Assert.AreEqual(0, r1.X);
Assert.AreEqual(0, r1.Y);
Assert.AreEqual(old_right, r1.Right);
Assert.AreEqual(old_bottom, r1.Bottom);
}
示例4: TestRectangleClip
public void TestRectangleClip()
{
var rect = new Rectangle(0, 0, 100, 100);
var view = new Rectangle(10, 10, 80, 80);
var clipped = rect.Clip(view);
Assert.True(clipped == view);
view = new Rectangle(0, 0, 200, 200);
clipped = rect.Clip(view);
Assert.True(clipped == rect);
var a = new Rectangle(0, 0, 1024, 768);
var b = new Rectangle(200, 0, 1024 + 200, 768);
clipped = b.Clip(a);
Assert.True(clipped.Left == 200);
Assert.True(clipped.Top == 0);
Assert.True(clipped.Right == 1024);
Assert.True(clipped.Bottom == 768);
}