📄 sitetran.cpp
字号:
lineSeg2.start.x = retRGN->rects[y].x2;
lineSeg2.start.y = retRGN->rects[y].y1;
lineSeg2.finish.x = retRGN->rects[y].x2;
lineSeg2.finish.y = retRGN->rects[y].y2;
if (tl.m_nLines)
{
CalcMatrixLines(&tmpLines, &tl, &lineSeg2, &tmpBlock);
tl = tmpLines;
}
else
{
CalcMatrixLines(&tmpLines, &lineSeg1, &lineSeg2, &tmpBlock);
tl += tmpLines;
}
// once we're blocked we don't want to be changed
if (tmpBlock)
blocked = TRUE;
}
}
if (!blocked && !tl.m_nLines)
{
tl += lineSeg1;
}
*lines += tl;
}
}
}
return retRGN;
}
HXREGION* HorizontalMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
static CHXBuffer* z_HorizontalMatrixDataBuffer = NULL;
if (!z_HorizontalMatrixDataBuffer || completeness == MATRIX_TRANSITION_INIT)
{
MatrixTransitionData* HorizontalMatrixTransition = new MatrixTransitionData(8,8,64);
MatrixBlockTransitionList* blockTransList = HorizontalMatrixTransition->GetTransactionListPtr();
for (int i = 0; i < 64; ++i)
{
blockTransList[i].CreateList(1);
MatrixBlockTransition* list = blockTransList[i].GetListPtr();
list->invert = ((i / 8) & 1);
if (list->invert) // determine if row we're in is odd; the top row is row 0
list->block = ((i / 8) + 1) * 8 - (i % 8) - 1; // if we're odd we're moving right to left
else
list->block = i; // otherwise left to right
list->transition = EdgeWipe;
}
z_HorizontalMatrixDataBuffer = new CHXBuffer();
z_HorizontalMatrixDataBuffer->AddRef();
z_HorizontalMatrixDataBuffer->Set((UCHAR*)&HorizontalMatrixTransition, sizeof(UCHAR*));
}
else if (completeness == MATRIX_TRANSITION_DELETE)
{
delete *((MatrixTransitionData**)z_HorizontalMatrixDataBuffer->GetBuffer());
if (!z_HorizontalMatrixDataBuffer->Release())
{
z_HorizontalMatrixDataBuffer = NULL;
return HXCreateRegion();
}
}
return MatrixTransition(left,top,right,bottom,completeness,
*((MatrixTransitionData**)z_HorizontalMatrixDataBuffer->GetBuffer()),lines);
}
HXREGION* VerticalMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
static CHXBuffer* z_VerticalMatrixDataBuffer = NULL;
if (!z_VerticalMatrixDataBuffer || completeness == MATRIX_TRANSITION_INIT)
{
MatrixTransitionData* VerticalMatrixTransition = new MatrixTransitionData(8,8,64);
MatrixBlockTransitionList* blockTransList = VerticalMatrixTransition->GetTransactionListPtr();
for (int i = 0; i < 64; ++i)
{
blockTransList[i].CreateList(1);
MatrixBlockTransition* list = blockTransList[i].GetListPtr();
list->invert = (i / 8) & 1;
if (list->invert) // determine if column we're in is odd; the left col is col 0
list->block = ((7 - i % 8) % 8) * 8 + i / 8;
else
list->block = (i % 8) * 8 + i / 8;
list->transition = SlideVerticalEdgeWipe;
}
z_VerticalMatrixDataBuffer = new CHXBuffer();
z_VerticalMatrixDataBuffer->AddRef();
z_VerticalMatrixDataBuffer->Set((UCHAR*)&VerticalMatrixTransition, sizeof(UCHAR*));
}
else if (completeness == MATRIX_TRANSITION_DELETE)
{
delete *((MatrixTransitionData**)z_VerticalMatrixDataBuffer->GetBuffer());
if (!z_VerticalMatrixDataBuffer->Release())
{
z_VerticalMatrixDataBuffer = NULL;
return HXCreateRegion();
}
}
return MatrixTransition(left,top,right,bottom,completeness,*((MatrixTransitionData**)z_VerticalMatrixDataBuffer->GetBuffer()),lines);
}
void GetTopLeftDiagonalCoords(int left, int top, int right, int bottom, int completeness, HXxPoint p[7], tranLines* lines)
{
int width = right - left;
int height = bottom - top;
double x = double(width) / 8.0;
double y = double(height) / 8.0;
int area = 0, lastArea = 0;
int i;
memset(p,0,sizeof(HXxPoint) * 7);
int areaComplete = int(double(width * height * completeness) / 1000.0);
for (i = 0; i < 16; ++i)
{
if (i < 8)
{
area = int((x * i + x) * (y * i + y) / 2);
}
else
{
area = width * height - int((x * (14 - i) + x) * (y * (14 - i) + y) / 2);
}
if (areaComplete < area)
break;
lastArea = area;
}
if (i == 16) --i;
int tmpCompleteness = 1000 - int(double(area - areaComplete) / double(area - lastArea) * 1000);
HXxPoint topPt, bottomPt;
if (i < 8)
{
p[0].x = left;
p[0].y = int(top + i * y);
p[1].x = int(left + i * x);
p[1].y = top;
p[2].x = int(left + (i + 1) * x);
p[2].y = top;
p[3].x = left;
p[3].y = int(top + (i + 1) * y);
}
else
{
int tmp = i - 8;
p[0].x = int(left + tmp * x);
p[0].y = bottom;
p[1].x = right;
p[1].y = int(top + tmp * y);
p[2].x = right;
p[2].y = int(top + (tmp + 1) * y);
p[3].x = int(left + (tmp + 1) * x);
p[3].y = bottom;
}
if (i & 1)
tmpCompleteness = 1000 - tmpCompleteness;
GetDiagonalStripCoords(p[0],p[1],p[2],p[3],&topPt,&bottomPt,tmpCompleteness);
p[0].x = left;
p[0].y = top;
p[1].y = top;
if (i < 8)
{
if (i & 1)
{
p[1].x = int(left + x * i + x);
p[2].x = bottomPt.x;
p[2].y = bottomPt.y;
p[3].x = topPt.x;
p[3].y = topPt.y;
p[4].y = int(top + y * i);
}
else
{
p[1].x = int(left + x * i);
p[2].x = topPt.x;
p[2].y = topPt.y;
p[3].x = bottomPt.x;
p[3].y = bottomPt.y;
p[4].y = int(top + y * i + y);
}
p[4].x = left;
}
else
{
p[1].x = right;
p[2].x = right;
p[5].y = bottom;
p[6].x = left;
p[6].y = bottom;
if (i & 1)
{
p[2].y = int(top + y * (i - 8) + y);
p[3].x = bottomPt.x;
p[3].y = bottomPt.y;
p[4].x = topPt.x;
p[4].y = topPt.y;
p[5].x = int(left + x * (i - 8));
}
else
{
p[2].y = int(top + y * (i - 8));
p[3].x = topPt.x;
p[3].y = topPt.y;
p[4].x = bottomPt.x;
p[4].y = bottomPt.y;
p[5].x = int(left + x * (i - 8) + x);
}
}
if (lines)
{
lines->m_nLines = 3;
lines->m_pLines = new LineSegment[3];
if(!lines->m_pLines)
{
lines->m_nLines = 0;
}
else
{
int pt = (i < 8) ? 1 : 2;
lines->m_pLines[0].start.x = p[pt].x;
lines->m_pLines[0].start.y= p[pt].y;
lines->m_pLines[0].finish.x = p[pt+1].x;
lines->m_pLines[0].finish.y= p[pt+1].y;
lines->m_pLines[1].start.x = p[pt+1].x;
lines->m_pLines[1].start.y= p[pt+1].y;
lines->m_pLines[1].finish.x = p[pt+2].x;
lines->m_pLines[1].finish.y= p[pt+2].y;
lines->m_pLines[2].start.x = p[pt+2].x;
lines->m_pLines[2].start.y= p[pt+2].y;
lines->m_pLines[2].finish.x = p[pt+3].x;
lines->m_pLines[2].finish.y= p[pt+3].y;
}
}
}
HXREGION* TopLeftDiagonalMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
HXxPoint p[7];
GetTopLeftDiagonalCoords(left,top,right,bottom,completeness,p,lines);
return HXPolygonRegion(p, 7, WindingRule);
}
HXREGION* TopRightDiagonalMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
HXREGION* retRGN = MirrorVertical(TopLeftDiagonalMatrix(left,top,right,bottom,completeness,lines),left + (right - left + 1) / 2);
if (lines)
MirrorVertical(lines,(right - left) / 2);
return retRGN;
}
HXREGION* BottomRightDiagonalMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
HXREGION* retRGN = MirrorHorizontal(MirrorVertical(TopLeftDiagonalMatrix(left,top,right,bottom,completeness,lines),left + (right - left + 1) / 2),top + (bottom - top + 1) / 2);
if (lines)
{
MirrorVertical(lines,(right - left) / 2);
MirrorHorizontal(lines,top + (bottom - top + 1) / 2);
}
return retRGN;
}
HXREGION* BottomLeftDiagonalMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
HXREGION* retRGN = MirrorHorizontal(TopLeftDiagonalMatrix(left,top,right,bottom,completeness,lines),top + (bottom - top + 1) / 2);
if (lines)
MirrorHorizontal(lines,top + (bottom - top + 1) / 2);
return retRGN;
}
HXREGION* ClockwiseTopLeftMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
static CHXBuffer* z_cwTopLeftDataBuffer = NULL;
if (!z_cwTopLeftDataBuffer || completeness == MATRIX_TRANSITION_INIT)
{
MatrixTransitionData* VerticalMatrixTransition = new MatrixTransitionData(8,8,64);
MatrixBlockTransitionList* blockTransList = VerticalMatrixTransition->GetTransactionListPtr();
int blockIdx = 0;
for (int i = 8; i > 0; i -= 2)
{
int j;
int horzOffset = ((8 - i) / 2) * 9;
int vertOffset = (9 - i) / 2;
int vertOffsetRt = i / 2 + 2;
for (j = 0; j < i; ++j, ++blockIdx)
{
blockTransList[blockIdx].CreateList(1);
MatrixBlockTransition* list = blockTransList[blockIdx].GetListPtr();
list->block = j + horzOffset;
list->invert = 0;
list->transition = EdgeWipe;
}
for (j = 0; j < i - 2; ++j, ++blockIdx)
{
blockTransList[blockIdx].CreateList(1);
MatrixBlockTransition* list = blockTransList[blockIdx].GetListPtr();
list->block = (j + 2 + vertOffset) * 8 - (vertOffset + 1);
list->invert = 0;
list->transition = SlideVerticalEdgeWipe;
}
for (j = 0; j < i; ++j, ++blockIdx)
{
blockTransList[blockIdx].CreateList(1);
MatrixBlockTransition* list = blockTransList[blockIdx].GetListPtr();
list->block = 63 - j - horzOffset;
list->invert = 1;
list->transition = EdgeWipe;
}
for (j = 0; j < i - 2; ++j, ++blockIdx)
{
blockTransList[blockIdx].CreateList(1);
MatrixBlockTransition* list = blockTransList[blockIdx].GetListPtr();
list->block = (vertOffsetRt - j) * 8 + (vertOffset);
list->invert = 1;
list->transition = SlideVerticalEdgeWipe;
}
}
z_cwTopLeftDataBuffer = new CHXBuffer();
z_cwTopLeftDataBuffer->AddRef();
z_cwTopLeftDataBuffer->Set((UCHAR*)&VerticalMatrixTransition, sizeof(UCHAR*));
}
else if (completeness == MATRIX_TRANSITION_DELETE)
{
delete *((MatrixTransitionData**)z_cwTopLeftDataBuffer->GetBuffer());
if (!z_cwTopLeftDataBuffer->Release())
{
z_cwTopLeftDataBuffer = NULL;
return HXCreateRegion();
}
}
return MatrixTransition(left,top,right,bottom,completeness,*((MatrixTransitionData**)z_cwTopLeftDataBuffer->GetBuffer()),lines);
}
HXREGION* ClockwiseTopRightMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
HXREGION* retRGN = MirrorVertical(
CounterClockwiseTopLeftMatrix(left,top,right,bottom,completeness,lines),
left + (right - left+1) / 2
);
if (lines)
MirrorVertical(lines,(left + right) / 2);
return retRGN;
}
HXREGION* ClockwiseBottomRightMatrix(int left, int top, int right, int bottom, int completeness, tranLines* lines)
{
HXREGION* retRGN = MirrorHorizontal(MirrorVertical(ClockwiseTopLeftMatrix(left,top,right,bottom,completeness,lines),left + (right - left + 1) / 2),(top + bottom) / 2);
if (lines)
{
MirrorVertical(lines,left + (right - left + 1) / 2);
MirrorHorizontal(lines,(top + bottom) / 2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -