📄 sitetran.cpp
字号:
//-----------------------------------------------------------------------tranStruct z_slideTable[] ={ {SlideFromLeft, -1, "fromLeft"}, {SlideFromTop, -1, "fromTop"}, {SlideFromRight, -1, "fromRight"}, {SlideFromBottom, -1, "fromBottom"}};tranStruct z_fadeTable[] ={ {Crossfade, -1, "crossfade"}, {FadeToColor, -1, "fadeToColor"}, {FadeFromColor, -1, "fadeFromColor"}};tranStruct z_defaultTable[] ={ {DefaultTransition, -1, "DefaultTransition"}};//////////////////////////////////////#endif //_TRANSITIONS_ON_tranType z_TransitionTable[] = { {z_defaultTable, "noTransition", sizeof(z_defaultTable) / sizeof(z_defaultTable[0])}, #ifdef _TRANSITIONS_ON_ {z_barWipeTable, "barWipe", sizeof(z_barWipeTable) / sizeof(z_barWipeTable[0])}, {z_boxWipeTable, "boxWipe", sizeof(z_boxWipeTable) / sizeof(z_boxWipeTable[0])}, {z_fourBoxTable, "fourBoxWipe", sizeof(z_fourBoxTable) / sizeof(z_fourBoxTable[0])}, {z_barnDoorTable, "barnDoorWipe", sizeof(z_barnDoorTable) / sizeof(z_barnDoorTable[0])}, {z_diagonalTable, "diagonalWipe", sizeof(z_diagonalTable) / sizeof(z_diagonalTable[0])}, {z_bowTieTable, "bowTieWipe", sizeof(z_bowTieTable) / sizeof(z_bowTieTable[0])}, {z_miscDiagonalTable, "miscDiagonalWipe", sizeof(z_miscDiagonalTable) / sizeof(z_miscDiagonalTable[0])}, {z_veeTable, "veeWipe", sizeof(z_veeTable) / sizeof(z_veeTable[0])}, {z_barnVeeTable, "barnVeeWipe", sizeof(z_barnVeeTable) / sizeof(z_barnVeeTable[0])}, {z_zigZagTable, "zigZagWipe", sizeof(z_zigZagTable) / sizeof(z_zigZagTable[0])}, {z_barnZigZagTable, "barnZigZagWipe", sizeof(z_barnZigZagTable) / sizeof(z_barnZigZagTable[0])}, {z_irisTable, "irisWipe", sizeof(z_irisTable) / sizeof(z_irisTable[0])}, {z_triangleTable, "triangleWipe", sizeof(z_triangleTable) / sizeof(z_triangleTable[0])}, {z_arrowHeadTable, "arrowHeadWipe", sizeof(z_arrowHeadTable) / sizeof(z_arrowHeadTable[0])}, {z_pentagonTable, "pentagonWipe", sizeof(z_pentagonTable) / sizeof(z_pentagonTable[0])}, {z_hexagonTable, "hexagonWipe", sizeof(z_hexagonTable) / sizeof(z_hexagonTable[0])}, {z_ellipseTable, "ellipseWipe", sizeof(z_ellipseTable) / sizeof(z_ellipseTable[0])}, {z_eyeTable, "eyeWipe", sizeof(z_eyeTable) / sizeof(z_eyeTable[0])}, {z_roundRectTable, "roundRectWipe", sizeof(z_roundRectTable) / sizeof(z_roundRectTable[0])}, {z_starTable, "starWipe", sizeof(z_starTable) / sizeof(z_starTable[0])}, {z_miscShapeTable, "miscShapeWipe", sizeof(z_miscShapeTable) / sizeof(z_miscShapeTable[0])}, {z_clockTable, "clockWipe", sizeof(z_clockTable) / sizeof(z_clockTable[0])}, {z_pinWheelTable, "pinWheelWipe", sizeof(z_pinWheelTable) / sizeof(z_pinWheelTable[0])}, {z_singleSweepTable, "singleSweepWipe", sizeof(z_singleSweepTable) / sizeof(z_singleSweepTable[0])}, {z_fanTable, "fanWipe", sizeof(z_fanTable) / sizeof(z_fanTable[0])}, {z_doubleFanTable, "doubleFanWipe", sizeof(z_doubleFanTable) / sizeof(z_doubleFanTable[0])}, {z_doubleSweepTable, "doubleSweepWipe", sizeof(z_doubleSweepTable) / sizeof(z_doubleSweepTable[0])}, {z_saloonDoorTable, "saloonDoorWipe", sizeof(z_saloonDoorTable) / sizeof(z_saloonDoorTable[0])}, {z_windshieldTable, "windshieldWipe", sizeof(z_windshieldTable) / sizeof(z_windshieldTable[0])}, {z_snakeTable, "snakeWipe", sizeof(z_snakeTable) / sizeof(z_snakeTable[0])}, {z_spiralTable, "spiralWipe", sizeof(z_spiralTable) / sizeof(z_spiralTable[0])}, {z_parallelSnakesTable, "parallelSnakesWipe", sizeof(z_parallelSnakesTable) / sizeof(z_parallelSnakesTable[0])}, {z_boxSnakesTable, "boxSnakesWipe", sizeof(z_boxSnakesTable) / sizeof(z_boxSnakesTable[0])}, {z_waterfallTable, "waterfallWipe", sizeof(z_waterfallTable) / sizeof(z_waterfallTable[0])}, {z_slideTable, "slideWipe", sizeof(z_slideTable) / sizeof(z_slideTable[0])}, {z_fadeTable, "fade", sizeof(z_fadeTable) / sizeof(z_fadeTable[0])}#endif //_TRANSITIONS_ON_};INT32 z_nNumberTransitionTypes = sizeof(z_TransitionTable) / sizeof(z_TransitionTable[0]);#ifdef _TRANSITIONS_ON_void CalcMatrixLines(tranLines* lines, LineSegment* src, LineSegment* mod, BOOL* blocked){ LineSegment ls; *blocked = TRUE; lines->Destroy(); if (src->start.y == src->finish.y) // horizontal lines { if (mod->start.x <= src->start.x && mod->finish.x >= src->start.x && mod->finish.x < src->finish.x) { ls.start.x = mod->finish.x; ls.finish.x = src->finish.x; ls.start.y = ls.finish.y = src->start.y; *lines += ls; } else if (mod->start.x <= src->finish.x && mod->start.x > src->start.x && mod->finish.x >= src->finish.x) { ls.start.x = src->start.x; ls.finish.x = mod->start.x; ls.start.y = ls.finish.y = src->start.y; *lines += ls; } else if (mod->start.x > src->start.x && mod->finish.x < src->finish.x) { ls.start.x = mod->finish.x; ls.finish.x = src->finish.x; ls.start.y = ls.finish.y = src->start.y; *lines += ls; ls.start.x = src->start.x; ls.finish.x = mod->start.x; ls.start.y = ls.finish.y = src->start.y; *lines += ls; } else if (mod->start.x >= src->finish.x || mod->finish.x <= src->start.x) { *blocked = FALSE; } } else // vertical lines { if (mod->start.y < src->start.y && mod->finish.y >= src->start.y && mod->finish.y < src->finish.y) { ls.start.y = mod->finish.y; ls.finish.y = src->finish.y; ls.start.x = ls.finish.x = src->start.x; *lines += ls; } else if (mod->start.y < src->finish.y && mod->start.y > src->start.y && mod->finish.y >= src->finish.y) { ls.start.y = src->start.y; ls.finish.y = mod->start.y; ls.start.x = ls.finish.x = src->start.x; *lines += ls; } else if (mod->start.y > src->start.y && mod->finish.y < src->finish.y) { ls.start.y = mod->finish.y; ls.finish.y = src->finish.y; ls.start.x = ls.finish.x = src->start.x; *lines += ls; ls.start.y = src->start.y; ls.finish.y = mod->start.y; ls.start.x = ls.finish.x = src->start.x; *lines += ls; } else if (mod->start.y >= src->finish.y || mod->finish.y <= src->start.y) { *blocked = FALSE; } }}void CalcMatrixLines(tranLines* newLines, tranLines* src, LineSegment* mod, BOOL* blocked){ tranLines tmpLines; newLines->Destroy(); //XXXSMJ this is not foolproof but will be good enough for our current needs for (int i = 0; i < src->m_nLines; ++i) { CalcMatrixLines(&tmpLines,&src->m_pLines[i],mod,blocked); if (!tmpLines.m_nLines) // this happens when lines don't obstruct each other *newLines += src->m_pLines[i]; else *newLines += tmpLines; }}void CalcMatrixBlockCoords(int left, int top, int right, int bottom, MatrixTransitionData *pData, int block, int* blockLeft, int* blockTop, int* blockRight, int* blockBottom){ double blockX = double(right - left + 1) / double(pData->GetWidth()); double blockY = double(bottom - top + 1) / double(pData->GetHeight()); *blockLeft = int(left + blockX * (block % pData->GetWidth())); *blockTop = int(top + blockY * (block / pData->GetWidth())); *blockRight = int(left + blockX * (block % pData->GetWidth() + 1)); *blockBottom = int(top + blockY * (block / pData->GetWidth() + 1)); if (*blockLeft < left) *blockRight = left; if (*blockTop < top) *blockBottom = top; if (*blockRight > right) *blockRight = right; if (*blockBottom > bottom) *blockBottom = bottom;}HXREGION* MatrixTransition(int left, int top, int right, int bottom, int completeness, MatrixTransitionData *pData, tranLines* lines){ HXREGION* retRGN = HXCreateRegion(); HXREGION* rgn1; int bLeft,bTop,bRight,bBottom; double frameLength = 1000.0 / pData->GetTransitionLength(); int frame = (int)((float)completeness/(frameLength+0.1)); MatrixBlockTransitionList* blockTransList = pData->GetTransactionListPtr(); for (int i = 0; i < frame; ++i) { MatrixBlockTransition* transList = blockTransList[i].GetListPtr(); for (int j = 0; j < blockTransList[i].GetSize(); ++j) { // these will all be completed blocks CalcMatrixBlockCoords(left,top,right,bottom,pData,transList[j].block,&bLeft,&bTop,&bRight,&bBottom); rgn1 = HXCreateRectRegion(bLeft,bTop,bRight-bLeft,bBottom-bTop); HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_OR); HXDestroyRegion(rgn1); } } int tmpCompleteness = int((completeness - frameLength * frame) / frameLength * 1000); MatrixBlockTransition* transList = blockTransList[frame].GetListPtr(); for (int j = 0; j < blockTransList[frame].GetSize(); ++j) { CalcMatrixBlockCoords(left,top,right,bottom,pData,transList[j].block,&bLeft,&bTop,&bRight,&bBottom); if (transList[j].invert) { rgn1 = transList[j].transition(bLeft,bTop,bRight,bBottom,1000 - tmpCompleteness,lines); rgn1 = InvertRGN(rgn1,bLeft,bTop,bRight,bBottom); } else { rgn1 = transList[j].transition(bLeft,bTop,bRight,bBottom,tmpCompleteness,lines); } HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_OR); HXDestroyRegion(rgn1); } if (lines) { BOOL blocked,tmpBlock; LineSegment lineSeg1, lineSeg2; tranLines tmpLines; for (int x = 0; x < retRGN->numRects; ++x) { // top if (retRGN->rects[x].y1 > top) { tranLines tl; blocked = tmpBlock = FALSE; lineSeg1.start.x = retRGN->rects[x].x1; lineSeg1.start.y = retRGN->rects[x].y1; lineSeg1.finish.x = retRGN->rects[x].x2; lineSeg1.finish.y = retRGN->rects[x].y1; for (int y = 0; y < x; ++y) { if (retRGN->rects[y].y2 == retRGN->rects[x].y1) { lineSeg2.start.x = retRGN->rects[y].x1; lineSeg2.start.y = retRGN->rects[y].y2; 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; } // right if (retRGN->rects[x].x2 < right) { tranLines tl; blocked = tmpBlock = FALSE; lineSeg1.start.x = retRGN->rects[x].x2; lineSeg1.start.y = retRGN->rects[x].y1; lineSeg1.finish.x = retRGN->rects[x].x2; lineSeg1.finish.y = retRGN->rects[x].y2; for (int y = 0; y < retRGN->numRects; ++y) { if (retRGN->rects[y].x1 == retRGN->rects[x].x2) { lineSeg2.start.x = retRGN->rects[y].x1; lineSeg2.start.y = retRGN->rects[y].y1; lineSeg2.finish.x = retRGN->rects[y].x1; 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; } // bottom if (retRGN->rects[x].y2 < bottom) { tranLines tl; blocked = tmpBlock = FALSE; lineSeg1.start.x = retRGN->rects[x].x1; lineSeg1.start.y = retRGN->rects[x].y2; lineSeg1.finish.x = retRGN->rects[x].x2; lineSeg1.finish.y = retRGN->rects[x].y2; for (int y = 0; y < retRGN->numRects; ++y) { if (retRGN->rects[y].y1 == retRGN->rects[x].y2) { lineSeg2.start.x = retRGN->rects[y].x1; lineSeg2.start.y = retRGN->rects[y].y1; lineSeg2.finish.x = retRGN->rects[y].x2; lineSeg2.finish.y = retRGN->rects[y].y1; 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; } // left if (retRGN->rects[x].x1 > left) { tranLines tl; blocked = tmpBlock = FALSE; lineSeg1.start.x = retRGN->rects[x].x1; lineSeg1.start.y = retRGN->rects[x].y1; lineSeg1.finish.x = retRGN->rects[x].x1; lineSeg1.finish.y = retRGN->rects[x].y2; for (int y = 0; y < retRGN->numRects; ++y) { if (retRGN->rects[y].x2 == retRGN->rects[x].x1) { 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; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -