sitetran.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:180k
- points[3].x = right - ((right - left) * completeness)/ 1000;
- points[3].y = bottom;
-
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = points[1].x;
- lines->m_pLines[0].start.y = points[1].y;
- lines->m_pLines[0].finish.x = points[2].x;
- lines->m_pLines[0].finish.y = points[2].y;
- lines->m_pLines[1].start.x = points[2].x;
- lines->m_pLines[1].start.y = points[2].y;
- lines->m_pLines[1].finish.x = points[3].x;
- lines->m_pLines[1].finish.y = points[3].y;
- }
- }
- return HXPolygonRegion( points, 4, WindingRule);
- }
- HXREGION* BottomLeftEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXxPoint points[4];
-
- points[0].x = left;
- points[0].y = bottom;
- points[1].x = left;
- points[1].y = bottom - ((bottom - top) * completeness )/ 1000;
- points[2].y = bottom - ((bottom - top) * completeness )/ 1000;
- points[2].x = left + ((right - left) * completeness )/ 1000;
- points[3].x = left + ((right - left) * completeness )/ 1000;
- points[3].y = bottom;
-
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = points[1].x;
- lines->m_pLines[0].start.y = points[1].y;
- lines->m_pLines[0].finish.x = points[2].x;
- lines->m_pLines[0].finish.y = points[2].y;
- lines->m_pLines[1].start.x = points[2].x;
- lines->m_pLines[1].start.y = points[2].y;
- lines->m_pLines[1].finish.x = points[3].x;
- lines->m_pLines[1].finish.y = points[3].y;
- }
- }
- return HXPolygonRegion( points, 4, WindingRule);
- }
- HXREGION* FourCornerEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines *tl1 = NULL, *tl2 = NULL, *tl3 = NULL;
- if (lines)
- {
- tl1 = new tranLines;
- tl2 = new tranLines;
- tl3 = new tranLines;
- }
- HXREGION* retRGN = HXCreateRectRegion(0, 0, 0, 0);
- HXREGION* rgn1 = TopLeftEdgeWipe(left, top, left+(right-left)/2, top+(bottom-top)/2, completeness,lines);
- HXREGION* rgn2 = TopRightEdgeWipe(left+(right-left)/2, top, right, top+(bottom-top)/2, completeness,tl1);
- HXREGION* rgn3 = BottomRightEdgeWipe(left+(right-left)/2, top+(bottom-top)/2, right, bottom, completeness,tl2);
- HXREGION* rgn4 = BottomLeftEdgeWipe(left, top+(bottom-top)/2, left+(right-left)/2, bottom, completeness,tl3);
- if (lines)
- {
- *lines += *tl1;
- *lines += *tl2;
- *lines += *tl3;
- delete tl1;
- delete tl2;
- delete tl3;
- }
-
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXCombineRgn(retRGN, retRGN, rgn2, HX_RGN_OR);
- HXCombineRgn(retRGN, retRGN, rgn3, HX_RGN_OR);
- HXCombineRgn(retRGN, retRGN, rgn4, HX_RGN_OR);
-
- HXDestroyRegion(rgn1);
- HXDestroyRegion(rgn2);
- HXDestroyRegion(rgn3);
- HXDestroyRegion(rgn4);
-
- return retRGN;
- }
- HXREGION* BoxEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- double dleft = left;
- double dtop = top;
- double dright = right;
- double dbottom = bottom;
- double dcompleteness = completeness;
- int l = (int) (((dleft+dright)/2.0 ) - ((dright - dleft)/2.0 ) * dcompleteness/1000.0);
- int t = (int) (((dtop+dbottom)/2.0 ) - ((dbottom - dtop)/2.0 ) * dcompleteness/1000.0);
- int r = (int) (((dleft+dright)/2.0 ) + ((dright - dleft)/2.0 ) * dcompleteness/1000.0);
- int b = (int) (((dtop+dbottom)/2.0 ) + ((dbottom - dtop)/2.0 ) * dcompleteness/1000.0);
- if (lines)
- {
- lines->m_nLines = 4;
- lines->m_pLines = new LineSegment[4];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = l;
- lines->m_pLines[0].start.y = t;
- lines->m_pLines[0].finish.x = r;
- lines->m_pLines[0].finish.y = t;
- lines->m_pLines[1].start.x = r;
- lines->m_pLines[1].start.y = t;
- lines->m_pLines[1].finish.x = r;
- lines->m_pLines[1].finish.y = b;
- lines->m_pLines[2].start.x = r;
- lines->m_pLines[2].start.y = b;
- lines->m_pLines[2].finish.x = l;
- lines->m_pLines[2].finish.y = b;
- lines->m_pLines[3].start.x = l;
- lines->m_pLines[3].start.y = b;
- lines->m_pLines[3].finish.x = l;
- lines->m_pLines[3].finish.y = t;
- }
- }
- return HXCreateRectRegion(l,t,r-l,b-t);
- }
- HXREGION* FourBoxEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines *tl1 = NULL, *tl2 = NULL, *tl3 = NULL;
- if (lines)
- {
- tl1 = new tranLines;
- tl2 = new tranLines;
- tl3 = new tranLines;
- }
- HXREGION* retRGN = HXCreateRectRegion(0, 0, 0, 0);
- HXREGION* rgn1 = BoxEdgeWipe(left, top, left+(right-left)/2, top+(bottom-top)/2, completeness,lines);
- HXREGION* rgn2 = BoxEdgeWipe(left+(right-left)/2, top, right, top+(bottom-top)/2, completeness,tl1);
- HXREGION* rgn3 = BoxEdgeWipe(left+(right-left)/2, top+(bottom-top)/2, right, bottom, completeness,tl2);
- HXREGION* rgn4 = BoxEdgeWipe(left, top+(bottom-top)/2, left+(right-left)/2, bottom, completeness,tl3);
-
- if (lines)
- {
- *lines += *tl1;
- *lines += *tl2;
- *lines += *tl3;
- delete tl1;
- delete tl2;
- delete tl3;
- }
-
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXCombineRgn(retRGN, retRGN, rgn2, HX_RGN_OR);
- HXCombineRgn(retRGN, retRGN, rgn3, HX_RGN_OR);
- HXCombineRgn(retRGN, retRGN, rgn4, HX_RGN_OR);
-
- HXDestroyRegion(rgn1);
- HXDestroyRegion(rgn2);
- HXDestroyRegion(rgn3);
- HXDestroyRegion(rgn4);
-
- return retRGN;
- }
- HXREGION* BarnVerticalEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- int l = (int)(((double)(left+right)/2)-((double) (right - left)/2 ) * ((double)completeness/1000.0));
- int r = (int) (((double) (left+right)/2 ) + ((double) (right - left)/2 ) * ((double)completeness/1000.0));
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = l;
- lines->m_pLines[0].start.y = top;
- lines->m_pLines[0].finish.x = l;
- lines->m_pLines[0].finish.y = bottom;
- lines->m_pLines[1].start.x = r;
- lines->m_pLines[1].start.y = top;
- lines->m_pLines[1].finish.x = r;
- lines->m_pLines[1].finish.y = bottom;
- }
- }
- return HXCreateRectRegion(l,top,r-l,bottom-top);
- }
- HXREGION* BarnHorizontalEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- int t = (int) (((double) (top+bottom)/2 ) - ((double) (bottom - top)/2 ) * ((double)completeness/1000.0));
- int b = (int) (((double) (top+bottom)/2 ) + ((double) (bottom - top)/2 ) * ((double)completeness/1000.0));
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = left;
- lines->m_pLines[0].start.y = t;
- lines->m_pLines[0].finish.x = right;
- lines->m_pLines[0].finish.y = t;
- lines->m_pLines[1].start.x = left;
- lines->m_pLines[1].start.y = b;
- lines->m_pLines[1].finish.x = right;
- lines->m_pLines[1].finish.y = b;
- }
- }
- return HXCreateRectRegion(left,t,right-left,b-t);
- }
- HXREGION* TopCenterEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- int l = (int) (((double) (left+right)/2 ) - ((double) (right - left)/2 ) * ((double)completeness/1000.0));
- int r = (int) (((double) (left+right)/2 ) + ((double) (right - left)/2 ) * ((double)completeness/1000.0));
- int b = (int) (((double) top + ((double) (bottom - top) )) * ((double)completeness/1000.0));
- if (lines)
- {
- lines->m_nLines = 3;
- lines->m_pLines = new LineSegment[3];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = l;
- lines->m_pLines[0].start.y = top;
- lines->m_pLines[0].finish.x = l;
- lines->m_pLines[0].finish.y = b;
- lines->m_pLines[1].start.x = l;
- lines->m_pLines[1].start.y = b;
- lines->m_pLines[1].finish.x = r;
- lines->m_pLines[1].finish.y = b;
- lines->m_pLines[2].start.x = r;
- lines->m_pLines[2].start.y = b;
- lines->m_pLines[2].finish.x = r;
- lines->m_pLines[2].finish.y = top;
- }
- }
- HXREGION* retRGN = HXCreateRectRegion(l,top,r-l,b-top);
-
- return retRGN;
- }
- HXREGION* CenterRightEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- int l = (int) (left + ((double) (right - left) ) * ( 1.0 - (double)completeness/1000.0));
- int t = (int) (((double) (top+bottom)/2 ) - ((double) (bottom - top)/2 ) * ((double)completeness/1000.0));
- int b = (int) (((double) (top+bottom)/2 ) + ((double) (bottom - top)/2 ) * ((double)completeness/1000.0));
- if (lines)
- {
- lines->m_nLines = 3;
- lines->m_pLines = new LineSegment[3];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = right;
- lines->m_pLines[0].start.y = t;
- lines->m_pLines[0].finish.x = l;
- lines->m_pLines[0].finish.y = t;
- lines->m_pLines[1].start.x = l;
- lines->m_pLines[1].start.y = t;
- lines->m_pLines[1].finish.x = l;
- lines->m_pLines[1].finish.y = b;
- lines->m_pLines[2].start.x = l;
- lines->m_pLines[2].start.y = b;
- lines->m_pLines[2].finish.x = right;
- lines->m_pLines[2].finish.y = b;
- }
- }
- HXREGION* retRGN = HXCreateRectRegion(l,t,right-l,b-t);
-
- return retRGN;
- }
- HXREGION* BottomCenterEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- int l = (int) (((double) (left+right)/2 ) - ((double) (right - left)/2 ) * ((double)completeness/1000.0));
- int t = (int) (bottom - ((double) (bottom - top) ) * ((double)completeness/1000.0));
- int r = (int) (((double) (left+right)/2 ) + ((double) (right - left)/2 ) * ((double)completeness/1000.0));
- if (lines)
- {
- lines->m_nLines = 3;
- lines->m_pLines = new LineSegment[3];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = l;
- lines->m_pLines[0].start.y = bottom;
- lines->m_pLines[0].finish.x = l;
- lines->m_pLines[0].finish.y = t;
- lines->m_pLines[1].start.x = l;
- lines->m_pLines[1].start.y = t;
- lines->m_pLines[1].finish.x = r;
- lines->m_pLines[1].finish.y = t;
- lines->m_pLines[2].start.x = r;
- lines->m_pLines[2].start.y = t;
- lines->m_pLines[2].finish.x = r;
- lines->m_pLines[2].finish.y = bottom;
- }
- }
- HXREGION* retRGN = HXCreateRectRegion(l,t,r-l,bottom-t);
-
- return retRGN;
- }
- HXREGION* LeftCenterEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- int t = (int) (((double) (top+bottom)/2 ) - ((double) (bottom - top)/2 ) * ((double)completeness/1000.0));
- int r = (int) (left + ((double) (right - left) ) * ((double)completeness/1000.0));
- int b = (int) (((double) (top+bottom)/2 ) + ((double) (bottom - top)/2 ) * ((double)completeness/1000.0));
- if (lines)
- {
- lines->m_nLines = 3;
- lines->m_pLines = new LineSegment[3];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = left;
- lines->m_pLines[0].start.y = t;
- lines->m_pLines[0].finish.x = r;
- lines->m_pLines[0].finish.y = t;
- lines->m_pLines[1].start.x = r;
- lines->m_pLines[1].start.y = t;
- lines->m_pLines[1].finish.x = r;
- lines->m_pLines[1].finish.y = b;
- lines->m_pLines[2].start.x = r;
- lines->m_pLines[2].start.y = b;
- lines->m_pLines[2].finish.x = left;
- lines->m_pLines[2].finish.y = b;
- }
- }
- HXREGION* retRGN = HXCreateRectRegion(left,t,r-left,b-t);
-
- return retRGN;
- }
- HXREGION* DiagonalLeftDownEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = HXCreateRectRegion(left, top, right-left, bottom-top);
- HXxPoint points[4];
-
- points[0].x = left;
- points[0].y = top;
- points[1].x = left + ((right - left) * completeness * 2)/ 1000;
- points[1].y = top;
- points[2].x = left;
- points[2].y = top + ((bottom - top) * completeness * 2)/ 1000;
- if (lines)
- {
- lines->m_nLines = 1;
- lines->m_pLines = new LineSegment[1];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines->start.x = points[1].x;
- lines->m_pLines->start.y = points[1].y;
- lines->m_pLines->finish.x = points[2].x;
- lines->m_pLines->finish.y = points[2].y;
- }
- }
-
- HXREGION* tempRGN = HXPolygonRegion( points, 3, WindingRule);
-
- HXCombineRgn(retRGN, retRGN, tempRGN, HX_RGN_AND);
- HXDestroyRegion(tempRGN);
- return retRGN;
- }
- HXREGION* DiagonalRightDownEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = HXCreateRectRegion(left, top, right-left, bottom-top);
- HXxPoint points[4];
-
- points[0].x = right;
- points[0].y = top;
- points[1].x = right - ((right - left) * completeness * 2)/ 1000;
- points[1].y = top;
- points[2].x = right;
- points[2].y = top + ((bottom - top) * completeness * 2)/ 1000;
-
- if (lines)
- {
- lines->m_nLines = 1;
- lines->m_pLines = new LineSegment[1];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines->start.x = points[1].x;
- lines->m_pLines->start.y = points[1].y;
- lines->m_pLines->finish.x = points[2].x;
- lines->m_pLines->finish.y = points[2].y;
- }
- }
-
- HXREGION* tempRGN = HXPolygonRegion( points, 3, WindingRule);
-
- HXCombineRgn(retRGN, retRGN, tempRGN, HX_RGN_AND);
- HXDestroyRegion(tempRGN);
- return retRGN;
- }
- HXREGION* HalfBowTieEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = NULL;
- HXxPoint points[5];
- if (completeness < 500)
- {
- points[0].x = left;
- points[0].y = top;
- points[1].x = (int) ((right + left) / 2 - ((double)(right - left)) * (double)completeness / 1000.0);
- points[1].y = top;
- points[2].x = points[1].x + (right + left) / 2;
- points[2].y = (top + bottom) / 2;
- points[3].x = points[1].x;
- points[3].y = bottom;
- points[4].x = left;
- points[4].y = bottom;
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = points[1].x;
- lines->m_pLines[0].start.y = points[1].y;
- lines->m_pLines[0].finish.x = points[2].x;
- lines->m_pLines[0].finish.y = points[2].y;
- lines->m_pLines[1].start.x = points[2].x;
- lines->m_pLines[1].start.y = points[2].y;
- lines->m_pLines[1].finish.x = points[3].x;
- lines->m_pLines[1].finish.y = points[3].y;
- }
- }
- retRGN = InvertRGN(HXPolygonRegion(points, 5, WindingRule),left, top, right, bottom);
- }
- else
- {
- int vOffset = (int)((bottom - top) / 2 * (double)(completeness - 500) / 500.0);
- points[0].x = left;
- points[0].y = top + vOffset;
- points[1].x = (right + left) / 2 - (int)((left + right) / 2 * (double)(completeness - 500) / 500.0);
- points[1].y = (top + bottom) / 2;
- points[2].x = left;
- points[2].y = bottom - vOffset;
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = points[0].x;
- lines->m_pLines[0].start.y = points[0].y;
- lines->m_pLines[0].finish.x = points[1].x;
- lines->m_pLines[0].finish.y = points[1].y;
- lines->m_pLines[1].start.x = points[1].x;
- lines->m_pLines[1].start.y = points[1].y;
- lines->m_pLines[1].finish.x = points[2].x;
- lines->m_pLines[1].finish.y = points[2].y;
- }
- }
- retRGN = InvertRGN(HXPolygonRegion(points, 3, WindingRule),left, top, right, bottom);
- }
- return retRGN;
- }
- HXREGION* VerticalBowTieEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = HalfBowTieEdgeWipe(left, top, right, bottom, completeness, NULL);
- HXREGION* tempRGN = MirrorVertical(HalfBowTieEdgeWipe(left, top, right, bottom, completeness,lines),(left + right) / 2);
- HXCombineRgn(retRGN, retRGN, tempRGN, HX_RGN_AND);
- HXDestroyRegion(tempRGN);
- if (lines)
- {
- tranLines tmpLines;
- tmpLines += *lines;
- MirrorVertical(&tmpLines,(left + right) / 2);
- *lines += tmpLines;
- }
- return retRGN;
- }
- HXREGION* HorizontalBowTieEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = InvertRGN(VerticalBowTieEdgeWipe(left, top, right, bottom, 1000 - completeness,lines), left, top, right, bottom);
- if (lines && lines->m_nLines == 4)
- {
- MirrorHorizontal(lines,(top + bottom) / 2);
- lines->m_pLines[0].Clip(left,top,(right + left) / 2, bottom);
- lines->m_pLines[1].Clip(left,top,(right + left) / 2, bottom);
- lines->m_pLines[2].Clip((right + left) / 2,top,right, bottom);
- lines->m_pLines[3].Clip((right + left) / 2,top,right, bottom);
- }
- return retRGN;
- }
- HXREGION* DiagonaLeftOutEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXxPoint points[6];
-
- points[0].x = (int) (right - ((double)(right - left)) * ((double)completeness / 1000.0));
- points[0].y = top;
- points[1].x = right;
- points[1].y = top;
- points[2].x = right;
- points[2].y = (int) (top + ((double)(bottom - top)) * ((double)completeness/ 1000.0));
- points[3].x = (int) (left + ((double)(right - left)) * ((double)completeness/ 1000.0));
- points[3].y = bottom;
- points[4].x = left;
- points[4].y = bottom;
- points[5].x = left;
- points[5].y = (int) (bottom - ((double)(bottom - top)) * ((double)completeness/ 1000.0));
-
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = points[0].x;
- lines->m_pLines[0].start.y = points[0].y;
- lines->m_pLines[0].finish.x = points[5].x;
- lines->m_pLines[0].finish.y = points[5].y;
- lines->m_pLines[1].start.x = points[2].x;
- lines->m_pLines[1].start.y = points[2].y;
- lines->m_pLines[1].finish.x = points[3].x;
- lines->m_pLines[1].finish.y = points[3].y;
- }
- }
- return HXPolygonRegion(points, 6, WindingRule);
- }
- HXREGION* DiagonaRightOutEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = DiagonaLeftOutEdgeWipe(left,top,right,bottom,completeness,lines);
- if (lines)
- MirrorVertical(lines,(right - left) / 2);
- return MirrorVertical(retRGN,(right - left) / 2);
- }
- HXREGION* DiagonaCrossEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- LineSegment ls;
- HXxPoint p[16];
- int xOff = int(double(right - left) / 2000.0 * completeness);
- int yOff = int(double(bottom - top) / 2000.0 * completeness);
- int midX = (right + left) / 2;
- int midY = (bottom + top) / 2;
- p[0].x = left + xOff;
- p[0].y = top;
- p[1].x = midX;
- p[1].y = midY - yOff;
- p[2].x = right - xOff;
- p[2].y = top;
- p[3].x = right;
- p[3].y = top;
- if (lines)
- {
- ls.start.x = p[0].x;
- ls.start.y = p[0].y;
- ls.finish.x = p[1].x;
- ls.finish.y = p[1].y;
- *lines += ls;
- ls.start.x = p[2].x;
- ls.start.y = p[2].y;
- ls.finish.x = p[1].x;
- ls.finish.y = p[1].y;
- *lines += ls;
- }
- p[4].x = right;
- p[4].y = top + yOff;
- p[5].x = midX + xOff;
- p[5].y = midY;
- p[6].x = right;
- p[6].y = bottom - yOff;
- p[7].x = right;
- p[7].y = bottom;
- if (lines)
- {
- ls.start.x = p[4].x;
- ls.start.y = p[4].y;
- ls.finish.x = p[5].x;
- ls.finish.y = p[5].y;
- *lines += ls;
- ls.start.x = p[6].x;
- ls.start.y = p[6].y;
- ls.finish.x = p[5].x;
- ls.finish.y = p[5].y;
- *lines += ls;
- }
-
- p[8].x = right - xOff;
- p[8].y = bottom;
- p[9].x = midX;
- p[9].y = midY + yOff;
- p[10].x = left + xOff;
- p[10].y = bottom;
- p[11].x = left;
- p[11].y = bottom;
- if (lines)
- {
- ls.start.x = p[8].x;
- ls.start.y = p[8].y;
- ls.finish.x = p[9].x;
- ls.finish.y = p[9].y;
- *lines += ls;
- ls.start.x = p[10].x;
- ls.start.y = p[10].y;
- ls.finish.x = p[9].x;
- ls.finish.y = p[9].y;
- *lines += ls;
- }
- p[12].x = left;
- p[12].y = bottom - yOff;
- p[13].x = midX - xOff;
- p[13].y = midY;
- p[14].x = left;
- p[14].y = top + yOff;
- p[15].x = left;
- p[15].y = top;
- if (lines)
- {
- ls.start.x = p[12].x;
- ls.start.y = p[12].y;
- ls.finish.x = p[13].x;
- ls.finish.y = p[13].y;
- *lines += ls;
- ls.start.x = p[14].x;
- ls.start.y = p[14].y;
- ls.finish.x = p[13].x;
- ls.finish.y = p[13].y;
- *lines += ls;
- }
-
- return HXPolygonRegion(p, 16, WindingRule);
- }
- HXREGION* DiagonalBoxEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = DiamondIris(left, top, right, bottom, completeness/2+500,lines);
- HXREGION* rgn1 = DiamondIris(left, top, right, bottom, 500 - completeness/2,tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
-
- return retRGN;
- }
- HXREGION* FilledVEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXxPoint points[3];
-
- points[0].x = (int) ((right+left)/2 + ((double)(right - left)) * ( (double)completeness/ 1000.0));
- points[0].y = top;
- points[1].x = (int) ((right+left)/2 - ((double)(right - left)) * ( (double)completeness/ 1000.0));
- points[1].y = top;
- points[2].x = (right+left)/2;
- points[2].y = (int) (top + ((double)(bottom - top)) * 2.0 * ( (double)completeness/ 1000.0));
-
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = points[0].x;
- lines->m_pLines[0].start.y = points[0].y;
- lines->m_pLines[0].finish.x = points[2].x;
- lines->m_pLines[0].finish.y = points[2].y;
- lines->m_pLines[1].start.x = points[1].x;
- lines->m_pLines[1].start.y = points[1].y;
- lines->m_pLines[1].finish.x = points[2].x;
- lines->m_pLines[1].finish.y = points[2].y;
- }
- }
- return HXPolygonRegion( points, 3, WindingRule);
- }
- HXREGION* FilledVRightEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXxPoint points[3];
-
- points[0].x = right;
- points[0].y = (int) ((bottom+top)/2 + ((double)(bottom - top)) * ( (double)completeness/ 1000.0));
- points[1].x = right;
- points[1].y = (int) ((bottom+top)/2 - ((double)(bottom - top)) * ( (double)completeness/ 1000.0));
- points[2].x = (int) (right - ((double)(right - top)) * 2.0 * ( (double)completeness/ 1000.0));
- points[2].y = (bottom+top)/2;
-
- if (lines)
- {
- lines->m_nLines = 2;
- lines->m_pLines = new LineSegment[2];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- lines->m_pLines[0].start.x = points[0].x;
- lines->m_pLines[0].start.y = points[0].y;
- lines->m_pLines[0].finish.x = points[2].x;
- lines->m_pLines[0].finish.y = points[2].y;
- lines->m_pLines[1].start.x = points[1].x;
- lines->m_pLines[1].start.y = points[1].y;
- lines->m_pLines[1].finish.x = points[2].x;
- lines->m_pLines[1].finish.y = points[2].y;
- }
- }
- return HXPolygonRegion( points, 3, WindingRule);
- }
- HXREGION* FilledVBottomEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRgn = FilledVEdgeWipe(left,top,right,bottom,completeness,lines);
- if (lines)
- MirrorHorizontal(lines,(top + bottom) / 2);
- return MirrorHorizontal(retRgn,(top + bottom) / 2);
- }
- HXREGION* FilledVLeftEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRgn = FilledVRightEdgeWipe(left,top,right,bottom,completeness,lines);
- if (lines)
- MirrorVertical(lines,(left + right) / 2);
- return MirrorVertical(retRgn,(left + right) / 2);
- }
- HXREGION* HollowVEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmp = NULL;
- if (lines)
- tmp = new tranLines;
- HXREGION* retRGN = FilledVEdgeWipe(left, top, right, bottom, 500+ completeness/2,lines);
- HXREGION* rgn1 = FilledVEdgeWipe(left, top, right, bottom, 500 - completeness/2,tmp);
- if (lines)
- {
- *lines += *tmp;
- delete tmp;
- }
-
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
-
- return retRGN;
- }
- HXREGION* HollowVRightEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmp = NULL;
- if (lines)
- tmp = new tranLines;
- HXREGION* retRGN = FilledVRightEdgeWipe(left, top, right, bottom, 500+ completeness/2,lines);
- HXREGION* rgn1 = FilledVRightEdgeWipe(left, top, right, bottom, 500 - completeness/2,tmp);
-
- if (lines)
- {
- *lines += *tmp;
- delete tmp;
- }
-
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
-
- return retRGN;
- }
- HXREGION* HollowVLeftEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRgn = HollowVRightEdgeWipe(left,top,right,bottom,completeness,lines);
- if (lines)
- MirrorVertical(lines,(left + right) / 2);
- return MirrorVertical(retRgn,(left + right) / 2);
- }
- HXREGION* HollowVBottomEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRgn = HollowVEdgeWipe(left,top,right,bottom,completeness,lines);
- if (lines)
- MirrorHorizontal(lines,(top + bottom) / 2);
- return MirrorHorizontal(retRgn,(top + bottom) / 2);
- }
- HXREGION* VerticalZigZagEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- int width = right - left;
-
- if (!width)
- ++width;
-
- HXxPoint points[13];
- // this is the width of the zigzag portion
- int zigzag = (int) ((float)(bottom - top + 1) / 10.0+.5);
- int tmpCompleteness = (int) ((float)completeness * (float)(right - left + zigzag + 1) / (float)width+.5);
-
- points[0].x = left - zigzag;
- points[0].y = top;
- points[1].x = left + (width * tmpCompleteness) / 1000 - zigzag;
- points[1].y = top;
-
- for(int i = 1; i< 11; i++)
- {
- points[i+1].x = left + (width * tmpCompleteness) / 1000 - !(i & 1) * zigzag;
- points[i+1].y = top + zigzag * i;
- }
-
- points[12].x = left-zigzag;
- points[12].y = bottom;
-
- if (lines)
- {
- lines->m_nLines = 10;
- lines->m_pLines = new LineSegment[10];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- for(int i = 1; i < 11; i++)
- {
- lines->m_pLines[i-1].start.x = points[i].x;
- lines->m_pLines[i-1].start.y = points[i].y;
- lines->m_pLines[i-1].finish.x = points[i + 1].x;
- lines->m_pLines[i-1].finish.y = points[i + 1].y;
- }
- }
- }
-
- return HXPolygonRegion( points, 13, WindingRule);
- }
- HXREGION* HorizontalZigZagEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- // this is the height of the zigzag portion
- int height = bottom - top;
-
- if (!height)
- ++height;
-
- int zigzag = (int)(((float)right - (float)left) / 10.0 +.5);
- int tmpCompleteness = completeness * (bottom - top + zigzag + 1) / height;
- int worknow = (int)(((float)height * (float)tmpCompleteness) / 1000.0 +.5);
-
- HXxPoint points[13];
-
- points[0].x = left;
- points[0].y = top - zigzag;
- points[1].x = left;
- points[1].y = top + worknow - zigzag;
-
- for(int i = 1; i< 11; i++)
- {
- points[i+1].y = top + worknow - !(i & 1) * zigzag;
- points[i+1].x = left + zigzag * i ;
- }
-
- points[12].x = right;
- points[12].y = top - zigzag;
-
- if (lines)
- {
- lines->m_nLines = 10;
- lines->m_pLines = new LineSegment[10];
- if (!lines->m_pLines)
- {
- lines->m_nLines = 0;
- }
- else
- {
- for(int i = 1; i < 11; i++)
- {
- lines->m_pLines[i-1].start.x = points[i].x;
- lines->m_pLines[i-1].start.y = points[i].y;
- lines->m_pLines[i-1].finish.x = points[i + 1].x;
- lines->m_pLines[i-1].finish.y = points[i + 1].y;
- }
- }
- }
-
- return HXPolygonRegion( points, 13, WindingRule);
- }
- HXREGION* HorizontalBarnZigZagEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmp = NULL;
- if (lines)
- tmp = new tranLines;
- HXREGION* retRGN = HorizontalZigZagEdgeWipe(left, top, right, bottom, (int) (500 - (double)completeness/2),lines);
- HXREGION* rgn1 = HorizontalZigZagEdgeWipe(left, top, right, bottom, 500 + completeness/2,tmp);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmp;
- delete tmp;
- }
- return retRGN;
- }
- HXREGION* VerticalBarnZigZagEdgeWipe(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmp = NULL;
- if (lines)
- tmp = new tranLines;
- HXREGION* retRGN = VerticalZigZagEdgeWipe(left, top, right, bottom, (int) (500 - (double)completeness/2),lines);
- HXREGION* rgn1 = VerticalZigZagEdgeWipe(left, top, right, bottom, 500 + completeness/2,tmp);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmp;
- delete tmp;
- }
- return retRGN;
- }
- HXREGION* InternalRotatingTopRadial(int left, int top, int right, int bottom, int completeness = NULL, tranLines* lines = NULL)
- {
- HXxPoint points[8];
-
- points[0].x = (left+right)/2;
- points[0].y = (top+bottom)/2;
- points[1].x = points[0].x; //(left+right)/2;
- points[1].y = top;
- int count = 2;
- for(int temp = completeness; temp >= 125; temp-=250)
- {
- points[count].x = count < 4 ? right : left;
- points[count].y = (count>2) && (count<5) ? bottom : top;
- count++;
- }
-
- double r = max(right - left, bottom - top);
- r*=2.0;
-
- double angle = ((double)completeness/1000.0) * PI * 2.0;
- points[count].x = (left+right)/2 + (int) (r * sin(angle));
- points[count].y = (top+bottom)/2 - (int) (r * cos(angle));
- count++;
-
- HXREGION* retRGN = HXPolygonRegion( points, count, WindingRule);
- if (lines)
- {
- lines->m_nLines = 1;
- lines->m_pLines = new LineSegment[1];
- lines->m_pLines->start.x = points[0].x;
- lines->m_pLines->start.y = points[0].y;
- lines->m_pLines->finish.x = points[count-1].x;
- lines->m_pLines->finish.y = points[count-1].y;
- }
-
- return retRGN;
- }
- HXREGION* RotatingTopRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = InternalRotatingTopRadial(left, top, right, bottom, completeness, lines);
- if (lines)
- {
- LineSegment ls;
- ls.start.x = (left + right) / 2;
- ls.start.y = (top + bottom) / 2;
- ls.finish.x = ls.start.x;
- ls.finish.y = top;
- *lines += ls;
- }
- return retRGN;
- }
- HXREGION* InternalRotatingRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines = NULL)
- {
- HXREGION* retRGN = InternalRotatingTopRadial(left, top, right, bottom, (completeness+250)> 1000 ? 1000: completeness+250,lines);
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 250);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_DIFF);
- HXDestroyRegion(rgn1);
-
- if (completeness > 750)
- {
- if (lines)
- {
- lines->Destroy(); // need to remove the ones we put in by the 1st call to IRTR()
- }
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, completeness - 750, lines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- }
-
- return retRGN;
- }
- HXREGION* RotatingRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = InternalRotatingRightRadial(left, top, right, bottom, completeness,lines);
- if (lines)
- {
- LineSegment ls;
- ls.start.x = (left + right) / 2;
- ls.start.y = (top + bottom) / 2;
- ls.finish.x = right;
- ls.finish.y = ls.start.y;
- *lines += ls;
- }
- return retRGN;
- }
- HXREGION* InternalRotatingBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines = NULL)
- {
- HXREGION* retRGN = InternalRotatingTopRadial(left, top, right, bottom, (completeness+500)> 1000 ? 1000: completeness+500, lines);
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 500);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_DIFF);
- HXDestroyRegion(rgn1);
-
- if (completeness > 500)
- {
- if (lines)
- {
- lines->Destroy(); // need to remove the ones we put in by the 1st call to IRTR()
- }
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, completeness - 500, lines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- }
-
- return retRGN;
- }
- HXREGION* RotatingBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = InternalRotatingBottomRadial(left, top, right, bottom, completeness,lines);
- if (lines)
- {
- LineSegment ls;
- ls.start.x = (left + right) / 2;
- ls.start.y = (top + bottom) / 2;
- ls.finish.x = ls.start.x;
- ls.finish.y = bottom;
- *lines += ls;
- }
- return retRGN;
- }
- HXREGION* InternalRotatingLeftRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines = NULL)
- {
- HXREGION* retRGN = InternalRotatingTopRadial(left, top, right, bottom, (completeness+750)> 1000 ? 1000: completeness+750, lines);
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 750);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_DIFF);
- HXDestroyRegion(rgn1);
-
- if (completeness > 250)
- {
- if (lines)
- {
- lines->Destroy(); // need to remove the ones we put in by the 1st call to IRTR()
- }
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, completeness - 250, lines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- }
-
- return retRGN;
- }
- HXREGION* RotatingLeftRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = InternalRotatingLeftRadial(left, top, right, bottom, completeness,lines);
- if (lines)
- {
- LineSegment ls;
- ls.start.x = (left + right) / 2;
- ls.start.y = (top + bottom) / 2;
- ls.finish.x = left;
- ls.finish.y = ls.start.y;
- *lines += ls;
- }
- return retRGN;
- }
- HXREGION* RotatingTopBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, completeness/2, lines);
- HXREGION* retRGN = InternalRotatingBottomRadial(left, top, right, bottom, completeness/2, tmpLines);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- LineSegment ls;
- ls.start.x = (left + right) / 2;
- ls.start.y = top;
- ls.finish.x = ls.start.x;
- ls.finish.y = bottom;
- *lines += ls;
- }
-
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- return retRGN;
- }
- HXREGION* RotatingLeftRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* rgn1 = InternalRotatingLeftRadial(left, top, right, bottom, completeness/2, lines);
- HXREGION* retRGN = InternalRotatingRightRadial(left, top, right, bottom, completeness/2, tmpLines);
-
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- LineSegment ls;
- ls.start.x = left;
- ls.start.y = (top + bottom) / 2;
- ls.finish.x = right;
- ls.finish.y = ls.start.y;
- *lines += ls;
- }
-
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- return retRGN;
- }
- HXREGION* RotatingQuadrantRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* rgn1 = InternalRotatingLeftRadial(left, top, right, bottom, completeness/4, lines);
- HXREGION* retRGN = InternalRotatingRightRadial(left, top, right, bottom, completeness/4, tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- rgn1 = InternalRotatingTopRadial(left, top, right, bottom, completeness/4, tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- rgn1 = InternalRotatingBottomRadial(left, top, right, bottom, completeness/4, tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- LineSegment ls;
- ls.start.x = (left + right) / 2;
- ls.start.y = top;
- ls.finish.x = ls.start.x;
- ls.finish.y = bottom;
- *lines += ls;
- ls.start.x = left;
- ls.start.y = (top + bottom) / 2;
- ls.finish.x = right;
- ls.finish.y = ls.start.y;
- *lines += ls;
- }
- return retRGN;
- }
- HXREGION* TopBottom180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = HXCreateRectRegion(left, top, right-left, bottom-top);
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 1000 - completeness / 2, lines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_DIFF);
- HXDestroyRegion(rgn1);
- HXREGION* ret1 = InternalRotatingTopRadial(left, top, right, bottom, completeness / 2, tmpLines);
- HXCombineRgn(retRGN, retRGN, ret1, HX_RGN_OR);
- HXDestroyRegion(ret1);
-
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* RightToLeft180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = HXCreateRectRegion(left, top, right-left,bottom-top);
- HXREGION* rgn1 = InternalRotatingRightRadial(left, top, right, bottom, 1000 - completeness / 2, lines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_DIFF);
- HXDestroyRegion(rgn1);
- HXREGION* ret1 = InternalRotatingRightRadial(left, top, right, bottom, completeness / 2, tmpLines);
- HXCombineRgn(retRGN, retRGN, ret1, HX_RGN_OR);
- HXDestroyRegion(ret1);
-
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* topBottom90Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN= InternalRotatingBottomRadial(left, top, right, bottom, 500 - completeness / 4, lines);
- HXREGION* rgn1 = InternalRotatingBottomRadial(left, top, right, bottom, 500+ completeness / 4, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 500 - completeness / 4, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 500+ completeness / 4, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- return retRGN;
- }
- HXREGION* RightToLeft90Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN= InternalRotatingBottomRadial(left, top, right, bottom, 250 - completeness / 4, lines);
- HXREGION* rgn1 = InternalRotatingBottomRadial(left, top, right, bottom, 250+ completeness / 4, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 250 - completeness / 4, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- rgn1 = InternalRotatingTopRadial(left, top, right, bottom, 250+ completeness / 4, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_XOR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- tmpLines = new tranLines;
- }
-
- return retRGN;
- }
- HXREGION* InternalTop180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines = NULL)
- {
- return InternalRotatingRightRadial(left, top - (bottom-top), right, bottom, completeness / 2, lines);
- }
- HXREGION* Top180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- return InternalTop180Radial(left, top, right, bottom, completeness, lines);
- }
- HXREGION* InternalRight180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines = NULL)
- {
- HXREGION* retRGN = InternalRotatingBottomRadial(left - (right -left), top, right, bottom, completeness / 2, lines);
- HXOffsetRegion(retRGN, (right -left), 0);
- if (lines)
- lines->Offset(right - left, 0);
- return retRGN;
- }
- HXREGION* Right180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- return InternalRight180Radial(left, top, right, bottom, completeness, lines);
- }
- HXREGION* InternalBottom180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines = NULL)
- {
- HXREGION* retRGN = InternalRotatingLeftRadial(left, top - (bottom-top), right, bottom, completeness / 2, lines);
- HXOffsetRegion(retRGN, 0, bottom - top);
- if (lines)
- lines->Offset(0, bottom - top);
- return retRGN;
- }
- HXREGION* Bottom180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- return InternalBottom180Radial(left, top, right, bottom, completeness, lines);
- }
- HXREGION* InternalLeft180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines = NULL)
- {
- return InternalRotatingTopRadial(left - (right -left), top, right, bottom, completeness / 2, lines);
- }
- HXREGION* Left180Radial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- return InternalLeft180Radial(left, top, right, bottom, completeness, lines);
- }
- HXREGION* CounterRotatingTopBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalTop180Radial(left, top, right, bottom, completeness / 2, lines);
- HXREGION* rgn1 = InternalBottom180Radial(left, top, right, bottom, completeness / 2, tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* CounterRotatingLeftRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalLeft180Radial(left, top, right, bottom, completeness / 2, lines);
- HXREGION* rgn1 = InternalRight180Radial(left, top, right, bottom, completeness / 2, tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* DoubleRotatingTopBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalBottom180Radial(left, top, right, bottom, 1000 - completeness,lines);
- HXREGION* rgn1 = HXCreateRectRegion(left, top, right-left,bottom-top);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_DIFF);
- HXDestroyRegion(rgn1);
- rgn1 = InternalTop180Radial(left, top, right, bottom, completeness, tmpLines);
- if (completeness > 500)
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_AND);
- else
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- lines->Clip(left,(top + bottom) / 2,right,bottom);
- tmpLines->Clip(left,top,right,(top + bottom) / 2);
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* DoubleRotatingLeftRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalRight180Radial(left, top, right, bottom, 1000 - completeness, lines);
- HXREGION* rgn1 = HXCreateRectRegion(left, top, right-left,bottom-top);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_DIFF);
- HXDestroyRegion(rgn1);
- rgn1 = InternalLeft180Radial(left, top, right, bottom, completeness, tmpLines);
- if (completeness > 500)
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_AND);
- else
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- lines->Clip((left + right) / 2,top,right,bottom);
- tmpLines->Clip(left,top,(left + right) / 2,bottom);
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* OpenVTopRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRgn = MirrorHorizontal(OpenVBottomRadial(left,top,right,bottom,completeness,lines),(top + bottom) / 2);
- if (lines)
- MirrorHorizontal(lines,(top + bottom) / 2);
- return retRgn;
- }
- HXREGION* OpenVRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRgn = MirrorVertical(OpenVLeftRadial(left,top,right,bottom,completeness,lines),(left + right) / 2);
- if (lines)
- MirrorVertical(lines,(left + right) / 2);
- return retRgn;
- }
- HXREGION* OpenVBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalRotatingLeftRadial(left, top - (bottom - top), right, bottom, 250 - completeness/4, lines);
- HXOffsetRegion(retRGN, 0, bottom - top);
- retRGN = InvertRGN(retRGN, left, top, left + (right - left)/2, bottom);
- HXREGION* rgn1 = InternalRotatingTopRadial(left, top - (bottom - top), right, bottom, completeness/4, tmpLines);
- HXOffsetRegion(rgn1, 0, bottom - top);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- lines->Offset(0, bottom - top);
- }
- return retRGN;
- }
- HXREGION* OpenVLeftRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalRotatingRightRadial(left - (right - left), top, right, bottom, completeness/4, lines);
- HXREGION* rgn1 = InternalRotatingTopRadial(left - (right - left), top, right, bottom, 250 - completeness/4, tmpLines);
- rgn1 = InvertRGN(rgn1, left, top, right, top + (bottom - top) / 2);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* OpenVTopBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = OpenVBottomRadial(left, top, right, bottom, completeness, lines);
- HXREGION* rgn1 = OpenVTopRadial(left, top, right, bottom, completeness, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_AND);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* OpenVLeftRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = OpenVLeftRadial(left, top, right, bottom, completeness, lines);
- HXREGION* rgn1 = OpenVRightRadial(left, top, right, bottom, completeness, tmpLines);
- HXCombineRgn(retRGN, rgn1, retRGN, HX_RGN_AND);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* RotatingTopLeftRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = RotatingRightRadial(left - (right - left), top - (bottom - top), right, bottom, completeness / 4, lines);
- if (lines)
- {
- //XXXSMJ This is cheap! Changes to RotatingRightRadial() might break this
- lines->m_nLines = 1;
- }
- return retRGN;
- }
- HXREGION* RotatingBottomLeftRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = InvertRGN(RotatingRightRadial(left - (right - left), top, right, bottom + (bottom - top), 1000 - completeness / 4, lines), left, top, right, bottom);
- if (lines)
- {
- //XXXSMJ This is cheap! Changes to RotatingRightRadial() might break this
- lines->m_nLines = 1;
- }
- return retRGN;
- }
- HXREGION* RotatingBottomRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = RotatingLeftRadial(left, top, right + (right - left), bottom + (bottom - top), completeness / 4, lines);
- if (lines)
- {
- //XXXSMJ This is cheap! Changes to RotatingLeftRadial() might break this
- lines->m_nLines = 1;
- }
- return retRGN;
- }
- HXREGION* RotatingTopRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = InvertRGN(RotatingLeftRadial(left, top - (bottom - top), right + (right - left), bottom, 1000 - completeness / 4, lines), left, top, right, bottom);
- if (lines)
- {
- //XXXSMJ This is cheap! Changes to RotatingLeftRadial() might break this
- lines->m_nLines = 1;
- }
- return retRGN;
- }
- HXREGION* RotatingTopLeftBottomRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- LineSegment ls;
- HXxPoint points[3];
-
- points[0].x = left;
- points[0].y = top;
- points[1].x = right;
- points[1].y = (int) (bottom - ((double)(bottom - top)) * ( 1.0 - (double)completeness/ 1000.0));
- points[2].x = right;
- points[2].y = top;
-
- HXREGION* retRGN = HXPolygonRegion( points, 3, WindingRule);
- if (lines)
- {
- ls.start.x = points[0].x;
- ls.start.y = points[0].y;
- ls.finish.x = points[1].x;
- ls.finish.y = points[1].y;
- *lines += ls;
- }
-
- points[0].x = right;
- points[0].y = bottom;
- points[1].x = left;
- points[1].y = (int) (bottom - ((double)(bottom - top)) * ((double)completeness/ 1000.0));
- points[2].x = left;
- points[2].y = bottom;
-
- HXREGION* tempRGN = HXPolygonRegion( points, 3, WindingRule);
- if (lines)
- {
- ls.start.x = points[0].x;
- ls.start.y = points[0].y;
- ls.finish.x = points[1].x;
- ls.finish.y = points[1].y;
- *lines += ls;
- }
- HXCombineRgn(retRGN, retRGN, tempRGN, HX_RGN_OR);
- HXDestroyRegion(tempRGN);
-
- return retRGN;
- }
- HXREGION* RotatingBottomLeftTopRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- LineSegment ls;
- HXxPoint points[3];
-
- points[0].x = left;
- points[0].y = bottom;
- points[1].x = int(left + double(right - left) * double(completeness) / 1000.0);
- points[1].y = top;
- points[2].x = left;
- points[2].y = top;
-
- HXREGION* retRGN = HXPolygonRegion( points, 3, WindingRule);
- if (lines)
- {
- ls.start.x = points[0].x;
- ls.start.y = points[0].y;
- ls.finish.x = points[1].x;
- ls.finish.y = points[1].y;
- *lines += ls;
- }
-
- points[0].x = right;
- points[0].y = top;
- points[1].x = int(right - double(right - left) * double(completeness) / 1000.0);
- points[1].y = bottom;
- points[2].x = right;
- points[2].y = bottom;
-
- HXREGION* tempRGN = HXPolygonRegion( points, 3, WindingRule);
- if (lines)
- {
- ls.start.x = points[0].x;
- ls.start.y = points[0].y;
- ls.finish.x = points[1].x;
- ls.finish.y = points[1].y;
- *lines += ls;
- }
- HXCombineRgn(retRGN, retRGN, tempRGN, HX_RGN_OR);
- HXDestroyRegion(tempRGN);
-
- return retRGN;
- }
- HXREGION* RotatingTopLeftRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = RotatingTopLeftRadial(left, top, right, bottom, completeness, lines);
- HXREGION* rgn1 = RotatingTopRightRadial(left, top, right, bottom, completeness, tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_AND);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* RotatingLeftTopBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = RotatingTopLeftRadial(left, top, right, bottom, 1000 - completeness, lines);
- HXREGION* rgn1 = RotatingBottomLeftRadial(left, top, right, bottom, 1000 - completeness, tmpLines);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *lines += *tmpLines;
- delete tmpLines;
- }
- return InvertRGN(retRGN, left, top, right, bottom);
- }
- HXREGION* RotatingBottomLeftRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = MirrorHorizontal(RotatingTopLeftRightRadial(left, top, right, bottom, completeness, lines),(top + bottom) / 2);
- if (lines)
- MirrorHorizontal(lines,(top + bottom) / 2);
- return retRGN;
- }
- HXREGION* RotatingRightTopBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = MirrorVertical(RotatingLeftTopBottomRadial(left, top, right, bottom, completeness, lines),(left + right) / 2);
- if (lines)
- MirrorVertical(lines,(left + right) / 2);
- return retRGN;
- }
- HXREGION* RotatingDoubleCenterRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = RotatingBottomRadial(left, top, right, bottom, 1000 - completeness, lines);
- HXREGION* rgn1 = RotatingTopRadial(left, top, right, bottom, completeness, tmpLines);
- rgn1 = InvertRGN(rgn1, left, top, right, bottom);
- HXOffsetRegion(retRGN,0,-(bottom - top) / 4);
- HXOffsetRegion(rgn1,0,(bottom - top) / 4);
- if (completeness > 750)
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_AND);
- else
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- lines->Offset(0,-(bottom - top) / 4);
- lines->Clip(left,top,right,(top + bottom) / 2);
- tmpLines->Offset(0,(bottom - top) / 4);
- tmpLines->Clip(left,(top + bottom) / 2,right,bottom);
- *lines += *tmpLines;
- delete tmpLines;
- }
- return InvertRGN(retRGN, left, top, right, bottom);
- }
- HXREGION* RotatingDoubleCenterTopRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = RotatingLeftRadial(left, top, right, bottom, completeness,lines);
- retRGN = InvertRGN(retRGN, left, top, right, bottom);
- HXREGION* rgn1 = RotatingRightRadial(left, top, right, bottom, 1000 - completeness, tmpLines);
- HXOffsetRegion(retRGN,(right - left) / 4, 0);
- HXOffsetRegion(rgn1,-(right - left) / 4, 0);
- if (completeness > 750)
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_AND);
- else
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- lines->Offset((right - left) / 4, 0);
- lines->Clip((right + left) / 2,top,right,bottom);
- tmpLines->Offset(-(right - left) / 4, 0);
- tmpLines->Clip(left,top,(right + left) / 2,bottom);
- *lines += *tmpLines;
- delete tmpLines;
- }
- return InvertRGN(retRGN, left, top, right, bottom);
- }
- HXREGION* RotatingDoubleCenterTopBottomRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalRotatingTopRadial(left, top, right, bottom, completeness / 2, lines);
- HXOffsetRegion(retRGN,0,-(bottom - top) / 4);
- HXREGION* rgn1 = HXCreateRegion();
- CopyRegion(rgn1,retRGN);
- MirrorHorizontal(rgn1,(bottom + top) / 2);
- if (lines)
- {
- lines->Offset(0,-(bottom - top) / 4);
- lines->Clip(left,top,right,(top + bottom) / 2);
- *tmpLines += *lines;
- MirrorHorizontal(tmpLines,(bottom + top) / 2);
- *lines += *tmpLines;
- tmpLines->Destroy();
- }
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- CopyRegion(rgn1,retRGN);
- MirrorVertical(rgn1,(left + right) / 2);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *tmpLines += *lines;
- MirrorVertical(tmpLines,(left + right) / 2);
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* RotatingDoubleCenterLeftRightRadial(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- tranLines* tmpLines = NULL;
- if (lines)
- tmpLines = new tranLines;
- HXREGION* retRGN = InternalRotatingLeftRadial(left, top, right, bottom, completeness / 2, lines);
- HXOffsetRegion(retRGN,-(right + left) / 4, 0);
- HXREGION* rgn1 = HXCreateRegion();
- CopyRegion(rgn1,retRGN);
- MirrorHorizontal(rgn1,(bottom + top) / 2);
- if (lines)
- {
- lines->Offset(-(right + left) / 4, 0);
- lines->Clip(left,top,(left + right) / 2,bottom);
- *tmpLines += *lines;
- MirrorHorizontal(tmpLines,(bottom + top) / 2);
- *lines += *tmpLines;
- tmpLines->Destroy();
- }
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- CopyRegion(rgn1,retRGN);
- MirrorVertical(rgn1,(left + right) / 2);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_OR);
- HXDestroyRegion(rgn1);
- if (lines)
- {
- *tmpLines += *lines;
- MirrorVertical(tmpLines,(left + right) / 2);
- *lines += *tmpLines;
- delete tmpLines;
- }
- return retRGN;
- }
- HXREGION* DoubleDiagonalBottom(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if (completeness <= 0)
- return HXCreateRegion();
-
- HXxPoint p[7];
- tranLines* tmpLines = NULL;
- GetTopLeftDiagonalCoords(left,top,right,bottom,500 + completeness / 2,p,lines);
- HXREGION* retRGN = HXPolygonRegion(p, 7, WindingRule);
- HXREGION* rgn1 = MirrorHorizontal(MirrorVertical(HXPolygonRegion(p, 7, WindingRule),(left + right) / 2),top + (bottom - top) / 2);
- HXCombineRgn(retRGN, retRGN, rgn1, HX_RGN_AND);
- if (lines)
- {
- tmpLines = new tranLines;
- *tmpLines += *lines;
- MirrorVertical(tmpLines,(left + right) / 2);
- MirrorHorizontal(tmpLines,top + (bottom - top) / 2);
- *lines += *tmpLines;
- }
- if (completeness < 120) // deal with slight overlap until the two snakes meet
- {
- HXREGION* blank1 = InvertRGN(HXCreateRectRegion(left,bottom - p[3].y,right,p[3].y),left,top,right-left,bottom-top);
- HXCombineRgn(retRGN, retRGN, blank1, HX_RGN_AND);
- HXDestroyRegion(blank1);
- }
- HXDestroyRegion(rgn1);
-
- return retRGN;
- }
- HXREGION* DoubleDiagonalTop(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- HXREGION* retRGN = MirrorVertical(DoubleDiagonalBottom(left, top, right, bottom, completeness,lines),(left + right) / 2);
- if (lines)
- MirrorVertical(lines,(left + right) / 2);
- return retRGN;
- }
- HXREGION* SlideFromLeft(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if (lines)
- {
- lines->m_nLines = 0;
- HX_VECTOR_DELETE( lines->m_pLines );
- }
- return HXCreateRectRegion(left, top, right - left, bottom - top);
- }
- HXREGION* SlideFromTop(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if (lines)
- {
- lines->m_nLines = 0;
- HX_VECTOR_DELETE( lines->m_pLines );
- }
- return HXCreateRectRegion(left, top, right - left, bottom - top);
- }
- HXREGION* SlideFromRight(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if (lines)
- {
- lines->m_nLines = 0;
- HX_VECTOR_DELETE( lines->m_pLines );
- }
- return HXCreateRectRegion(left, top, right - left, bottom - top);
- }
- HXREGION* SlideFromBottom(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if (lines)
- {
- lines->m_nLines = 0;
- HX_VECTOR_DELETE( lines->m_pLines );
- }
- return HXCreateRectRegion(left, top, right - left, bottom - top);
- }
- HXREGION* Crossfade(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if(lines)
- {
- lines->m_nLines = 0;
- HX_VECTOR_DELETE(lines->m_pLines);
- }
- return HXCreateRectRegion(left, top, right - left, bottom - top);
- }
- HXREGION* FadeToColor(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if (lines)
- {
- lines->m_nLines = 0;
- HX_VECTOR_DELETE( lines->m_pLines );
- }
- return HXCreateRectRegion(left, top, right - left, bottom - top);
- }
- HXREGION* FadeFromColor(int left, int top, int right, int bottom, int completeness, tranLines* lines)
- {
- if (lines)
- {
- lines->m_nLines = 0;
- HX_VECTOR_DELETE( lines->m_pLines );
- }
- return HXCreateRectRegion(left, top, right - left, bottom - top);
- }
- #endif //_TRANSITIONS_ON_
- #ifdef _TESTING_TRANITIONS_
- #define FORWARD
- // sloppy, but cheap for this test program
- int z_PaneWidth = 280;
- int z_PaneHeight = 250;
- struct tranMap
- {
- int in;
- int type;
- int subType;
- };
- tranMap theTranMap[200];
- extern tranType z_TransitionTable[];
- extern int z_nNumberTransitions;
- HWND zm_hwnd;
- HWND zm_comboHWND;
- HWND zm_displayOuter;
- HWND zm_displayInner;
- char* zm_pszWindowClassName = "TestRGNClass";
- char* zm_pszWindowName = "TestRGNWindow";
- HFONT zm_theFONT = 0;
- HFONT zm_theSmallFONT = 0;
- HBITMAP zm_hBitmapOLD= 0;
- HBITMAP zm_hBitmapNEW= 0;
- HBITMAP zm_hScratchSurface= 0;
- HBITMAP zm_oldSurface = 0;
- HBITMAP zm_oldSurface2 = 0;
- HDC zm_memDC = 0;
- HDC zm_memDC2 = 0;
- int currentPosition = 0;
- int CurrentTransition = 1;
- int CurrentSubType = 0;
- int zm_maxRects = 0;
- int zm_numFrames = 0;
- double zm_startTime;
- double zm_totalCPUTime;
- int zm_bRegionEffect = 1;
- int z_pPixelValues[300][300];
- double GetAngle(int x, int y, int x1, int y1)
- {
- int dx = x- x1;
- int dy = y - y1;
-
- return atan2(dx, dy);
- }
- int GetRange(int x, int y, int x1, int y1)
- {
- return (int) sqrt( (double) ((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y)));
- }
- void DoPixelTransition(HBITMAP back, HBITMAP front, HBITMAP scratch, int completeness, tranLines* lines)
- {
- if (!zm_memDC2)
- {
- HDC hdc = GetDC(0);
- zm_memDC2 = CreateCompatibleDC(hdc);
- ReleaseDC(0, hdc);
- }
-
- zm_oldSurface = (HBITMAP)SelectObject(zm_memDC, back);
- zm_oldSurface2 = (HBITMAP)SelectObject(zm_memDC2, zm_hScratchSurface);
- SelectObject(zm_memDC, front);
-
- if (!z_pPixelValues[0][0])
- {
- for(int y = 0; y<z_PaneWidth; y++)
- {
- for(int x = 0; x< z_PaneWidth; x++)
- {
- z_pPixelValues[x][y]= GetPixel(zm_memDC, x, y);
- if (!x && !y && !z_pPixelValues[x][y])
- {
- z_pPixelValues[x][y] = 1;
- }
- }
- }
- }
-
- int implodex = 140;
- int implodey = 140;
-
- for(int y = 0; y<z_PaneWidth; y++)
- {
- for(int x = 0; x< z_PaneWidth; x++)
- {
- int color = z_pPixelValues[x][y];
- double angle= GetAngle(x,y,implodex, implodey);
- int range = GetRange(x,y,implodex, implodey);
- range = (range * (1000 - completeness)) / 1000;
- double mess = (double)completeness/500.0 * PI;
- double scaleFactor = sin(angle*3 + mess)*cos(angle*2 + mess);
- scaleFactor = (1.0 - scaleFactor)* (1000.0 - completeness) / 1000.0 + scaleFactor;
- range = (int) (range * scaleFactor + 0.5);
- int newx = (int) ((double) range * sin (angle + mess / 4) + implodex + 0.5);
- int newy = (int) ((double) range * cos (angle + mess / 4) + implodey + 0.5);
- SetPixel(zm_memDC2, newx, newy, color);
- }
- }
- SelectObject(zm_memDC, zm_oldSurface);
- SelectObject(zm_memDC2, zm_oldSurface2);
- }
- double currentTime()
- {
- static LARGE_INTEGER QueryPerformanceCounterResult = {0,0};
- static LARGE_INTEGER QueryPerformanceFrequencyResult = {0,0};
-
- QueryPerformanceFrequency(&QueryPerformanceFrequencyResult);
-
- double frequency = ((double)QueryPerformanceFrequencyResult.LowPart + 4294967296.0*QueryPerformanceFrequencyResult.HighPart);
- QueryPerformanceCounter(&QueryPerformanceCounterResult);
-
- return ((double)QueryPerformanceCounterResult.LowPart + 4294967296.0*QueryPerformanceCounterResult.HighPart)/frequency;
- }
- void PrintStat(int x, int y, char* pszStatName, int stat)
- {
- LOGBRUSH logBrush;
- logBrush.lbStyle = BS_SOLID;
- logBrush.lbColor = 0x00000000;
- logBrush.lbHatch = 0;
- HBRUSH brush = CreateBrushIndirect(&logBrush);
-
-
- HDC hdc = GetDC(zm_hwnd);
- char buffer[20]; /* Flawfinder: ignore */
- SetTextColor(hdc, 0x00FFFFFF);
- SetBkColor(hdc, 0x00000000);
- SetBkMode(hdc, OPAQUE);
- HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, brush);
-
- TextOut(hdc, x, y, pszStatName, strlen(pszStatName));
- Rectangle(hdc, x+90, y, x+230, y+20);
- sprintf(buffer, "%d", stat); /* Flawfinder: ignore */
- TextOut(hdc, x+90, y, buffer, strlen(buffer));
- SelectObject(hdc, oldBrush);
- DeleteObject(brush);
- ReleaseDC(zm_hwnd, hdc);
- }
- #ifdef NO_GRAPHICS
- void DoTransition(int currentPosition)
- {
- RECT rect;
-
- rect.left = 0;
- rect.top = 0;
- rect.right = z_PaneWidth;
- rect.bottom = z_PaneHeight;
-
- HXDestroyRegion(z_TransitionTable[CurrentTransition].m_pSubTypes[CurrentSubType].m_fpTranFunction(rect.left, rect.top, rect.right, rect.bottom, currentPosition));
- }
- #endif
- LRESULT __declspec(dllexport) __stdcall CWindowProc
- (
- HWND hWnd,
- UINT message,
- WPARAM wParam,
- LPARAM lParam
- )
- {
- switch (message)
- {
- case WM_TIMER:
- {
- /* The following commented out code is for determing which
- * region is supposed to be old and which is supposed to be new.
- */
-
- /*
- {
- RECT rect;
- GetClientRect(zm_displayInner, &rect);
- HRGN rgn = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
- SetWindowRgn(zm_displayInner, rgn, FALSE);
- HDC hdc = GetDC(zm_displayInner);
- FillRect(hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH));
- GdiFlush();
- ReleaseDC(zm_displayInner, hdc);
- }
- */
-
- double startTime = currentTime();
-
- RECT rect;
-
- rect.left = 0;
- rect.top = 0;
- rect.right = z_PaneWidth;// - 1;
- rect.bottom = z_PaneHeight;// - 1;
-
- #ifdef FORWARD
- currentPosition += 5;
- if (currentPosition > 1000) currentPosition = 1000;
- #else
- currentPosition -= 5;
- if (currentPosition < 0) currentPosition = 0;
- #endif
-
- HXREGION* XclipRgn = InvertRGN(z_TransitionTable[CurrentTransition].m_pSubTypes[CurrentSubType].m_fpTranFunction(rect.left, rect.top, rect.right, rect.bottom, currentPosition),rect.left, rect.top, rect.right, rect.bottom);
-
- HRGN clipRgn = CreateRectRgn(0,0,0,0);
- for(int i=0 ; i<XclipRgn->numRects ; i++ )
- {
- HRGN tmp = CreateRectRgn(
- XclipRgn->rects[i].x1,
- XclipRgn->rects[i].y1,
- XclipRgn->rects[i].x2,
- XclipRgn->rects[i].y2
- );
- CombineRgn( clipRgn, clipRgn, tmp, RGN_OR );
- DeleteObject( tmp );
- }
- HXDestroyRegion(XclipRgn);
- if (!zm_theSmallFONT)
- {
- zm_theSmallFONT = CreateFont(15, 0, 0, 0, 700, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Ariel");
- }
-
- if (!zm_theFONT)
- {
- zm_theFONT = CreateFont(115, 0, 0, 0, 700, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Ariel");
- }
- int totalrects;
- totalrects = 0;
-
- {
- LPRGNDATA lpRgnData;
- DWORD sizeNeeed = GetRegionData(clipRgn, 0, NULL);
- lpRgnData = (LPRGNDATA) new char[sizeNeeed];
- GetRegionData(clipRgn, sizeNeeed, lpRgnData);
- PrintStat(z_PaneWidth + 20, 50, "Old Rects:", lpRgnData->rdh.nCount);
- totalrects += lpRgnData->rdh.nCount;
- delete lpRgnData;
- }
-
- // Create Initial Objects.
-
- if (!zm_memDC)
- {
- HDC hdc = GetDC(0);
- zm_memDC = CreateCompatibleDC(hdc);
- ReleaseDC(0, hdc);
- }
-
- if (!zm_hBitmapNEW)
- {
- HDC hdc = GetDC(0);
- zm_hBitmapNEW = CreateCompatibleBitmap(hdc, z_PaneWidth, z_PaneHeight);
- ReleaseDC(0, hdc);
-
- zm_oldSurface = (HBITMAP)SelectObject(zm_memDC, zm_hBitmapNEW);
- LOGBRUSH logBrush;
- logBrush.lbStyle = BS_SOLID;
- logBrush.lbColor = 0x000000FF;
- logBrush.lbHatch = 0;
- HBRUSH brush = CreateBrushIndirect(&logBrush);
-
- HFONT oldfont = (HFONT)SelectObject(zm_memDC, zm_theFONT);
- HBRUSH oldBrush = (HBRUSH)SelectObject(zm_memDC, brush);
- Rectangle(zm_memDC, 0,0,z_PaneWidth, z_PaneHeight);
- SetBkMode(zm_memDC, TRANSPARENT);
- SIZE stringSize;
- GetTextExtentPoint32(zm_memDC,"NEW",3,&stringSize);
- TextOut(zm_memDC, (z_PaneWidth - stringSize.cx) / 2, (z_PaneHeight - stringSize.cy) / 2, "NEW", 3);
- GdiFlush();
- SelectObject(zm_memDC, oldBrush);
- DeleteObject(brush);
- SelectObject(zm_memDC, oldfont);
- SelectObject(zm_memDC, zm_oldSurface);
- }
-
- if (!zm_hBitmapOLD)
- {
- HDC hdc = GetDC(0);
- zm_hBitmapOLD = CreateCompatibleBitmap(hdc, z_PaneWidth, z_PaneHeight);
- ReleaseDC(0, hdc);
-
- zm_oldSurface = (HBITMAP)SelectObject(zm_memDC, zm_hBitmapOLD);
- LOGBRUSH logBrush;
- logBrush.lbStyle = BS_SOLID;
- logBrush.lbColor = 0x0000FFFF;
- logBrush.lbHatch = 0;
- HBRUSH brush = CreateBrushIndirect(&logBrush);
-
- HFONT oldfont = (HFONT)SelectObject(zm_memDC, zm_theFONT);
- HBRUSH oldBrush = (HBRUSH)SelectObject(zm_memDC, brush);
- Rectangle(zm_memDC, 0,0,z_PaneWidth, z_PaneHeight);
- SetBkMode(zm_memDC, TRANSPARENT);
- SIZE stringSize;
- GetTextExtentPoint32(zm_memDC,"OLD",3,&stringSize);
- TextOut(zm_memDC, (z_PaneWidth - stringSize.cx) / 2, (z_PaneHeight - stringSize.cy) / 2, "OLD", 3);
- GdiFlush();
- SelectObject(zm_memDC, oldBrush);
- DeleteObject(brush);
- SelectObject(zm_memDC, oldfont);
- SelectObject(zm_memDC, zm_oldSurface);
- }
-
- if (zm_bRegionEffect)
- {
- HRGN oldRGN;
- oldRGN = CreateRectRgn(0,0,0,0);
- GetWindowRgn(zm_displayInner, oldRGN);
-
- SetWindowRgn(zm_displayInner, clipRgn, FALSE);
- HDC hdc = GetDC(zm_displayInner);
- zm_oldSurface = (HBITMAP)SelectObject(zm_memDC, zm_hBitmapOLD);
- BitBlt(hdc, 0,0,z_PaneWidth, z_PaneHeight, zm_memDC, 0,0, SRCCOPY);
-
- HXREGION* ZclipRgn = InvertRGN(z_TransitionTable[CurrentTransition].m_pSubTypes[CurrentSubType].m_fpTranFunction(rect.left, rect.top, rect.right, rect.bottom, currentPosition),rect.left, rect.top, rect.right, rect.bottom);
- static LARGE_INTEGER QueryPerformanceCounterResult = {0,0};
- static LARGE_INTEGER QueryPerformanceFrequencyResult = {0,0};
-
- QueryPerformanceFrequency(&QueryPerformanceFrequencyResult);
-
- double frequency = ((double)QueryPerformanceFrequencyResult.LowPart + 4294967296.0*QueryPerformanceFrequencyResult.HighPart);
- QueryPerformanceCounter(&QueryPerformanceCounterResult);
-
- double startTime = ((double)QueryPerformanceCounterResult.LowPart + 4294967296.0*QueryPerformanceCounterResult.HighPart)/frequency;
-
- clipRgn = CreateRectRgn(0,0,0,0);
- for(int i=0 ; i<ZclipRgn->numRects ; i++ )
- {
- HRGN tmp = CreateRectRgn(
- ZclipRgn->rects[i].x1,
- ZclipRgn->rects[i].y1,
- ZclipRgn->rects[i].x2,
- ZclipRgn->rects[i].y2
- );
- CombineRgn( clipRgn, clipRgn, tmp, RGN_OR);
- DeleteObject( tmp );
- }
-
- HXDestroyRegion(ZclipRgn);
-
-
- QueryPerformanceCounter(&QueryPerformanceCounterResult);
- double endTime = ((double)QueryPerformanceCounterResult.LowPart + 4294967296.0*QueryPerformanceCounterResult.HighPart)/frequency;
-
- static UINT32 z_nNumTimes = 0;
- static double z_fTotalTime;
- static double z_fAverageTime;
-
- z_nNumTimes++;
- z_fTotalTime += endTime - startTime;
- z_fAverageTime = z_fTotalTime / (double) z_nNumTimes;
- /*
- if (! (z_nNumTimes % 25))
- {
- FILE* f1 = ::fopen("c:\performance.txt", "a+");
- ::fprintf(f1, "WINDRAW2 - BltToPrimary: %d blts. Total CPU time: %f, CPU/Blt: %f -- Blt/s Second Max: %fn", z_nNumTimes, z_fTotalTime, z_fAverageTime, 1.0/z_fAverageTime);
- fclose(f1);
- }
-
- */
-
- HRGN tempRgn = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
- CombineRgn(tempRgn, tempRgn, clipRgn, RGN_XOR);
-
-
- // Print Region Stats
-
- {
- LPRGNDATA lpRgnData;
- DWORD sizeNeeed = GetRegionData(tempRgn, 0, NULL);
- lpRgnData = (LPRGNDATA) new char[sizeNeeed];
- GetRegionData(tempRgn, sizeNeeed, lpRgnData);
- PrintStat(z_PaneWidth + 20, 70, "New Rects:", lpRgnData->rdh.nCount);
- totalrects += lpRgnData->rdh.nCount;
- delete lpRgnData;
- }
-
- SetWindowRgn(zm_displayInner, tempRgn, FALSE);
- SelectObject(zm_memDC, zm_hBitmapNEW);
- BitBlt(hdc, 0,0,z_PaneWidth, z_PaneHeight, zm_memDC, 0,0, SRCCOPY);
- ReleaseDC(zm_displayInner, hdc);
- DeleteObject(clipRgn);
- SelectObject(zm_memDC, zm_oldSurface);
- SetWindowRgn(zm_displayInner, oldRGN, 0);
- }
- else
- {
- // Pixel based effects.
-
- if (!zm_hScratchSurface)
- {
- HDC hdc = GetDC(0);
- zm_hScratchSurface = CreateCompatibleBitmap(hdc, 300,300);
- ReleaseDC(0, hdc);
- }
-
- DoPixelTransition(zm_hBitmapNEW, zm_hBitmapOLD, zm_hScratchSurface, currentPosition);
- HDC hdc = GetDC(zm_displayInner);
- zm_oldSurface = (HBITMAP)SelectObject(zm_memDC, zm_hScratchSurface);
- BitBlt(hdc, 0,0,z_PaneWidth, z_PaneHeight, zm_memDC, 0,0, SRCCOPY);
- ReleaseDC(zm_displayInner, hdc);
- SelectObject(zm_memDC, zm_oldSurface);
- PrintStat(z_PaneWidth + 20, 170, "Frames:", zm_numFrames);
- }
-
- // Print More Stats
- PrintStat(z_PaneWidth + 20, 90, "Sum Rects:", totalrects);
- if (totalrects > zm_maxRects)
- {
- zm_maxRects = totalrects;
- }
- PrintStat(z_PaneWidth + 20, 110, "Max Rects:", zm_maxRects);
- zm_totalCPUTime = zm_totalCPUTime + (currentTime() - startTime);
- PrintStat(z_PaneWidth + 20, 130, "% CPU:", (int) (zm_totalCPUTime*100.0 / (currentTime() - zm_startTime)));
-
- zm_numFrames++;
- PrintStat(z_PaneWidth + 20, 150, "FPS:", (int) (zm_numFrames/ (currentTime() - zm_startTime)));
-
- PrintStat(z_PaneWidth + 20, 170, "Complete:", currentPosition);
- break;
- }
- case WM_COMMAND:
- {
- int wNotifyCode = HIWORD(wParam);
- if (wNotifyCode == CBN_SELCHANGE)
- {
- #ifdef FORWARD
- currentPosition = -5;
- #else
- currentPosition = 1005;
- #endif
- int currentSel = SendMessage(zm_comboHWND, CB_GETCURSEL , 0, 0);
-
- // clear out the previous transitions memory
- HXDestroyRegion(z_TransitionTable[CurrentTransition].m_pSubTypes[CurrentSubType].m_fpTranFunction(0, 0, 0, 0, MATRIX_TRANSITION_DELETE));
-
- CurrentTransition = theTranMap[currentSel].type;
- CurrentSubType = theTranMap[currentSel].subType;
- zm_maxRects = 0;
- zm_startTime = currentTime();
- zm_totalCPUTime = 0;
- zm_numFrames = 0;
- #ifdef NO_GRAPHICS
- double startTime = currentTime();
-
- for (int i = 0; i <= 1000; i += 5)
- {
- DoTransition(i);
- }
-
- double endTime = currentTime();
- PrintStat(z_PaneWidth + 20, 130, "Time (mu):", (int) ((endTime - startTime) * 1000000));
- #endif
- }
- break;
- }
- case WM_DESTROY:
- {
- // clear out the previous transitions memory
- HXDestroyRegion(z_TransitionTable[CurrentTransition].m_pSubTypes[CurrentSubType].m_fpTranFunction(0, 0, 0, 0, MATRIX_TRANSITION_DELETE));
-
- PostQuitMessage(0);
- break;
- }
- }
-
- return (DefWindowProc(hWnd, message, wParam, lParam));
- }
- int WINAPI WinMain( HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow
- )
- {
- // get the size of the window from command line
- char* pCLine = strstr(lpCmdLine,"Width");
- if (pCLine)
- {
- pCLine = strchr(pCLine,'=');
- if (pCLine)
- {
- pCLine++;
- z_PaneWidth = atoi(pCLine);
- }
- }
- pCLine = strstr(lpCmdLine,"Height");
- if (pCLine)
- {
- pCLine = strchr(pCLine,'=');
- if (pCLine)
- {
- pCLine++;
- z_PaneHeight = atoi(pCLine);
- }
- }
-
- WNDCLASS wndClass;
-
- wndClass.style = 0;
- wndClass.lpfnWndProc = CWindowProc;
- wndClass.cbClsExtra = 0;
- wndClass.cbWndExtra = 0;
- wndClass.hInstance = hInstance;
- wndClass.hIcon = NULL;
- wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- wndClass.lpszMenuName = NULL;
- wndClass.lpszClassName = zm_pszWindowClassName;
-
- ::RegisterClass(&wndClass);
-
- wndClass.lpfnWndProc = DefWindowProc;
- wndClass.lpszClassName = "DefWindowProc";
- ::RegisterClass(&wndClass);
-
- ::RegisterClass(&wndClass);
-
- zm_hwnd = CreateWindow(
- zm_pszWindowClassName,
- zm_pszWindowName,
- WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE | WS_SYSMENU,
- 100,
- 100,
- z_PaneWidth + 200,
- z_PaneHeight + 70,
- NULL,
- NULL,
- hInstance,
- NULL);
-
- zm_comboHWND= CreateWindow(
- "COMBOBOX",
- "combo",
- WS_VISIBLE | WS_CHILD | CBS_DROPDOWN | WS_VSCROLL,
- 10,
- 10,
- 400,
- 300,
- zm_hwnd,
- NULL,
- hInstance,
- NULL);
-
- zm_displayOuter = CreateWindow(
- "DefWindowProc",
- "combo",
- WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
- 10,
- 40,
- z_PaneWidth,
- z_PaneHeight,
- zm_hwnd,
- NULL,
- hInstance,
- NULL);
-
- zm_displayInner = CreateWindow(
- "DefWindowProc",
- "combo",
- WS_VISIBLE | WS_CHILD,
- 0,
- 0,
- z_PaneWidth,
- z_PaneHeight,
- zm_displayOuter,
- NULL,
- hInstance,
- NULL);
-
- int count = 0;
- char name[200]; /* Flawfinder: ignore */
- for(int j = 0; j < z_nNumberTransitionTypes; ++j)
- {
- for(int i = 0; i< z_TransitionTable[j].m_nNum; ++i)
- {
- if (count < 200)
- {
- if (z_TransitionTable[j].m_pSubTypes[i].m_pTranName)
- {
- SafeSprintf(name,200, "%s - %s (%d)",z_TransitionTable[j].m_pName,z_TransitionTable[j].m_pSubTypes[i].m_pTranName,z_TransitionTable[j].m_pSubTypes[i].m_SMPTE);
- SendMessage(zm_comboHWND, CB_ADDSTRING, 0, (long)name);
- theTranMap[count].in = count;
- theTranMap[count].type = j;
- theTranMap[count].subType = i;
- count++;
- }
- }
- }
- }
-
- int number = SendMessage(zm_comboHWND, CB_GETCOUNT, 0, 0);
- SendMessage(zm_comboHWND, CB_SETCURSEL, CurrentTransition, 0);
- #ifndef NO_GRAPHICS
- SetTimer(zm_hwnd, 1, 1, NULL);
- #endif
- MSG msg;
- while (GetMessage(&msg,NULL,0,0))
- {
- if (msg.message == WM_QUIT)
- break;
-
- TranslateMessage(&msg);
- // Dispatches message to window
- DispatchMessage(&msg);
- }
-
- return msg.wParam ;
- }
- #endif