计算范围的算法

mac2025-04-06  12

前言

在计算组合块边框范围的时候想计算出四边的padding结果有问题,以后再想 private void CalcPadding(ComPieceData comPieceData) { int[] padding = new int[4]; int top = comPieceData.height - comPieceData.centerY; int right = comPieceData.width - comPieceData.centerX; int down = comPieceData.centerY; int left = comPieceData.centerX; padding[0] = top; padding[1] = right; padding[2] = down; padding[3] = left; comPieceData.padding = padding; } public int Iteration() { rotateByIte %= 4; return comPieceData.padding[rotateByIte++]; } private bool IsFir = true; public void CalClpRge() { public int Iteration() { rotateByIte %= 4; return comPieceData.padding[rotateByIte++]; } private bool IsFir = true; public void CalClpRge() { if (!IsFir) { rotateCpy--; if (rotateCpy < 0) rotateCpy = 3; rotateByIte = rotateCpy; } IsFir = false; int[] padding = new int[4]; int top = comPieceData.height - comPieceData.centerY; //2 int right = comPieceData.width - comPieceData.centerX; //1 int down = comPieceData.centerY;//0 int left = comPieceData.centerX;//0 maxY = height - top; //3 maxX = width - right;//4; 3 minX = left - 1; // left 0 0 minY = down - 1; // 0 1 //旋转90 maxY = height - top; //left 1 maxX = width - right;//4; top 1 minX = left; // left 0 right 0 minY = down; // 0 down 1 //maxY = height - (Iteration()); //maxX = width - Iteration(); //minY = Iteration(); //minX = Iteration(); Debug.Log($"{maxY}-{minY}-{maxX}-{minX}"); }
最新回复(0)