using Dolphin.ExamPictureCut.Domains.Quest;
using Dolphin.ExamPictureCut.Exams.Dto;
namespace Dolphin.ExamPictureCut.Extensions;
public static class RectExt
{
///
/// 四舍五入
///
///
///
public static int SSWR(this float px)
{
return (int)Math.Round(px, 0, MidpointRounding.AwayFromZero);
}
public static float MMToPX(this float MM)
{
return MM * 96 / 25.4F;
}
///
/// AU转像素
///
///
///
public static float AUToPX(this int AU)
{
return (AU * 0.3F / 8).MMToPX();
}
public static bool IsRectContainsLattice(TemplateJsonModel_Rect rect, PenOfflineData latt)
{
var x = latt.CX.AUToPX();
var y = latt.CY.AUToPX();
return rect.pxLeft <= x && x <= rect.pxLeft + rect.pxWidth
&& rect.pxTop <= y && y <= rect.pxTop + rect.pxHeight;
}
}