本文整理汇总了C#中System.Windows.Rect.GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.GetCenter方法的具体用法?C# Rect.GetCenter怎么用?C# Rect.GetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Rect
的用法示例。
在下文中一共展示了Rect.GetCenter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public override Rect Apply(Rect oldDataRect, Rect newDataRect, Viewport2D viewport)
{
double ratio = newDataRect.Width / newDataRect.Height;
double coeff = Math.Sqrt(ratio);
double newWidth = newDataRect.Width / coeff;
double newHeight = newDataRect.Height * coeff;
Point center = newDataRect.GetCenter();
Rect res = RectExtensions.FromCenterSize(center, newWidth, newHeight);
return res;
}
示例2: Apply
public override Rect Apply(Rect oldDataRect, Rect newDataRect, Viewport2D viewport)
{
Rect output = viewport.Output;
if (output.Width == 0 || output.Height == 0)
return newDataRect;
double screenRatio = output.Width / output.Height;
double viewportRatio = newDataRect.Width / newDataRect.Height;
double ratio = screenRatio / viewportRatio;
double width = proportionRatio * newDataRect.Width * ratio;
double height = newDataRect.Height;
if (width < newDataRect.Width)
{
height = newDataRect.Height / proportionRatio / ratio;
width = newDataRect.Width;
}
Point center = newDataRect.GetCenter();
Rect res = RectExtensions.FromCenterSize(center, width, height);
return res;
}
示例3: RectZoom
public static Rect RectZoom(Rect rect, double ratio)
{
return RectZoom(rect, rect.GetCenter(), ratio);
}
示例4: Quadivide
private static IEnumerable<Point> Quadivide(Rect area)
{
if (area.Width > 0 && area.Height > 0)
{
var center = area.GetCenter();
var x = Math.Floor(center.X);
var y = Math.Floor(center.Y);
yield return new Point(x, y);
var quad1 = new Rect(area.TopLeft, new Point(x, y + 1));
var quad2 = new Rect(area.TopRight, new Point(x, y));
var quad3 = new Rect(area.BottomLeft, new Point(x + 1, y + 1));
var quad4 = new Rect(area.BottomRight, new Point(x + 1, y));
var quads = new Queue<IEnumerator<Point>>();
quads.Enqueue(Quadivide(quad1).GetEnumerator());
quads.Enqueue(Quadivide(quad2).GetEnumerator());
quads.Enqueue(Quadivide(quad3).GetEnumerator());
quads.Enqueue(Quadivide(quad4).GetEnumerator());
while (quads.Count > 0)
{
var quad = quads.Dequeue();
if (quad.MoveNext())
{
yield return quad.Current;
quads.Enqueue(quad);
}
}
}
}
示例5: EnlargeRect
protected Rect EnlargeRect(Rect rect)
{
Size newSize = rect.Size;
newSize.Width += 1;
newSize.Height += 1;
Rect result = RectExtensions.FromCenterSize(rect.GetCenter(), newSize);
return result;
//double coeff = 1 + 1.0 / tileWidth;
//return EnlargeRect(rect, coeff);
}