本文整理汇总了C#中CGRect.UnionWith方法的典型用法代码示例。如果您正苦于以下问题:C# CGRect.UnionWith方法的具体用法?C# CGRect.UnionWith怎么用?C# CGRect.UnionWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGRect
的用法示例。
在下文中一共展示了CGRect.UnionWith方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FinishedLaunching
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Two disjoint rects
var r1 = new CGRect (50, 50, 10, 10);
var r2 = new CGRect (100, 100, 10, 10);
// This condradicts with Apple's doc – https://developer.apple.com/reference/coregraphics/cgrectnull
// The null rectangle. This is the rectangle returned when, for example, you intersect two disjoint rectangles.
// Note that the null rectangle is not the same as the zero rectangle.
// For example, the union of a rectangle with the null rectangle is the original rectangle (that is, the null rectangle contributes nothing).
var tmp = r1;
tmp.Intersect (r2); // this is mutable method
Console.WriteLine (tmp.IsNull ()); // Expected true, but result is false
tmp = CGRectIntersection (r1, r2);
Console.WriteLine (tmp.IsNull ()); // Expected true, actual true
// This should be CGRectNull
var rectNull = new CGRect (nfloat.PositiveInfinity, nfloat.PositiveInfinity, 0, 0);
Console.WriteLine (rectNull.IsNull ()); // Expected true, actual true
// CGRectEmpty and CGRectNull are different
var union1 = r1.UnionWith (CGRect.Empty); // new rect {0, 0, 60, 60}
Console.WriteLine (union1);
var union2 = r1.UnionWith (rectNull); // r1
Console.WriteLine (union2);
return true;
}
示例2: UpdateRectForLinePoint
static CGRect UpdateRectForLinePoint(LinePoint point, LinePoint previousPoint)
{
var rect = new CGRect (point.Location, CGSize.Empty);
var pointMagnitude = point.Magnitude;
if (previousPoint != null) {
pointMagnitude = NMath.Max (pointMagnitude, previousPoint.Magnitude);
rect = rect.UnionWith (new CGRect (previousPoint.Location, CGSize.Empty));
}
// The negative magnitude ensures an outset rectangle.
var magnitude = -3 * pointMagnitude - 2;
rect = rect.Inset (magnitude, magnitude);
return rect;
}
示例3: AddPointsOfType
CGRect AddPointsOfType (PointType type, UITouch[] touches, Line line, CGRect rect)
{
var accumulatedRect = CGRect.Empty;
for (int i = 0; i < touches.Length; i++) {
var touch = touches [i];
bool isStylus = touch.Type == UITouchType.Stylus;
// The visualization displays non-`.Stylus` touches differently.
if (!isStylus)
type = type.Add (PointType.Finger);
if (isTouchUpdatingEnabled && (touch.EstimatedProperties != 0))
type = type.Add (PointType.NeedsUpdate);
bool isLast = i == touches.Length - 1;
if (type.Has (PointType.Coalesced) && isLast) {
type = type.Remove (PointType.Coalesced);
type = type.Add (PointType.Standard);
}
var touchRect = line.AddPointOfType (type, touch);
accumulatedRect = accumulatedRect.UnionWith (touchRect);
CommitLine (line);
}
return rect.UnionWith (accumulatedRect);
}