isClickImgArea static method
dynamic
isClickImgArea()
判断是否点中图片的指定区域 sw,sh,图片的原始大小 renderSize:图片的渲染后所占用的像素大小 clicLtInSImg:原图上可以点击的区域左上角 clickW, clickH:原图上可点击的矩形的宽度和高度 localPosition:实际交互的时候点击的内容
Implementation
static isClickImgArea(int sw, int sh, Size renderSize, Offset clicLtInSImg, int clickW, int clickH, Offset localPosition) {
//debugPrint("图片大小:${renderSize}");
//debugPrint("点击区域:${localPosition}");
double minX = clicLtInSImg.dx / sw * renderSize.width; //按比例求出渲染后的做上角X
double maxX = minX + clickW / sw * renderSize.width; //
double minY = clicLtInSImg.dy / sh * renderSize.height;
double maxY = minY + renderSize.height * clickH / sh;
Rect r = Rect.fromLTRB(minX, minY, maxX, maxY);
// debugPrint("矩形区域--->:${r}");
if (r.contains(localPosition)) {
return true;
}
return false;
}