本文整理汇总了C#中Android.Graphics.RectF.Inset方法的典型用法代码示例。如果您正苦于以下问题:C# RectF.Inset方法的具体用法?C# RectF.Inset怎么用?C# RectF.Inset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.RectF
的用法示例。
在下文中一共展示了RectF.Inset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: growBy
// Grows the cropping rectange by (dx, dy) in image space.
private void growBy(float dx, float dy)
{
if (maintainAspectRatio)
{
if (dx != 0)
{
dy = dx / initialAspectRatio;
}
else if (dy != 0)
{
dx = dy * initialAspectRatio;
}
}
// Don't let the cropping rectangle grow too fast.
// Grow at most half of the difference between the image rectangle and
// the cropping rectangle.
RectF r = new RectF(cropRect);
if (dx > 0F && r.Width() + 2 * dx > imageRect.Width())
{
float adjustment = (imageRect.Width() - r.Width()) / 2F;
dx = adjustment;
if (maintainAspectRatio)
{
dy = dx / initialAspectRatio;
}
}
if (dy > 0F && r.Height() + 2 * dy > imageRect.Height())
{
float adjustment = (imageRect.Height() - r.Height()) / 2F;
dy = adjustment;
if (maintainAspectRatio)
{
dx = dy * initialAspectRatio;
}
}
r.Inset(-dx, -dy);
// Don't let the cropping rectangle shrink too fast.
float widthCap = 25F;
if (r.Width() < widthCap)
{
r.Inset(-(widthCap - r.Width()) / 2F, 0F);
}
float heightCap = maintainAspectRatio
? (widthCap / initialAspectRatio)
: widthCap;
if (r.Height() < heightCap)
{
r.Inset(0F, -(heightCap - r.Height()) / 2F);
}
// Put the cropping rectangle inside the image rectangle.
if (r.Left < imageRect.Left)
{
r.Offset(imageRect.Left - r.Left, 0F);
}
else if (r.Right > imageRect.Right)
{
r.Offset(-(r.Right - imageRect.Right), 0);
}
if (r.Top < imageRect.Top)
{
r.Offset(0F, imageRect.Top - r.Top);
}
else if (r.Bottom > imageRect.Bottom)
{
r.Offset(0F, -(r.Bottom - imageRect.Bottom));
}
cropRect.Set(r);
DrawRect = computeLayout();
context.Invalidate();
}