#include "ImageData.h" #include "GraphBase.h" #include "GraphLow.h" void TRect::Set(int aLeft, int aTop, int aRight, int aBottom) { Left=aLeft; Top=aTop; Right=aRight; Bottom=aBottom; Width=Right-Left+1; Height=Bottom-Top+1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetBySize(int aLeft, int aTop, int aWidth, int aHeight) { Left=aLeft; Top=aTop; Width=aWidth; Height=aHeight; Right=Left+Width-1; Bottom=Top+Height-1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetBy2Point(TPoint aPLT, TPoint aPRB) { Left=aPLT.x; Top=aPLT.y; Right=aPRB.x; Bottom=aPRB.y; Width=Right-Left+1; Height=Bottom-Top+1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetLeftTop(int aL, int aT) { SetLeft(aL); SetTop(aT); CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetLeft(int aL) { Left=aL; Right=Left+Width-1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetTop(int aT) { Top=aT; Bottom=Top+Height-1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetRight(int aR) { Right=aR; Left=Right-Width+1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetBottom(int aB) { Bottom=aB; Top=Bottom-Height+1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetWidth(int aW) { Width=aW; Right=Left+Width-1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TRect::SetHeight(int aH) { Height=aH; Bottom=Top+Height-1; CenterPoint.x=(Left+Right)/2; CenterPoint.y=(Top+Bottom)/2; } void TCircle::Plot4Points(int x, int y) { PixelRender((Center.x + x), (Center.y + y), PenWidth, PenColor); if (x != 0) PixelRender((Center.x - x), (Center.y + y), PenWidth, PenColor); if (y != 0) PixelRender((Center.x + x), (Center.y - y), PenWidth, PenColor); if (x != 0 && y != 0) PixelRender((Center.x - x), (Center.y - y), PenWidth, PenColor); } void TCircle::Plot4PointsFill(int x, int y) { BoxRender2D((Center.x-x), (Center.y+y), (Center.x+x), (Center.y+y), PenColor); BoxRender2D((Center.x-x), (Center.y-y), (Center.x+x), (Center.y-y), PenColor); } void TCircle::Plot8Points(int x, int y) { if(BrushStyle) { Plot4PointsFill(x, y); if (x != y) Plot4PointsFill(y, x); }else{ Plot4Points( x, y); if (x != y) Plot4Points(y, x); } } void TCircle::Render(void) //draw circle { int tmp = static_cast(Radius); int error = (-1 * tmp); unsigned int x = Radius; unsigned int y = 0; // The following while loop may altered to 'while (x > y)' for a // performance benefit, as long as a call to 'plot4points' follows // the body of the loop. This allows for the elimination of the // '(x != y') test in 'plot8points', providing a further benefit. // // For the sake of clarity, this is not shown here. while (x >= y){ Plot8Points(x, y); error += y; ++y; error += y; // The following test may be implemented in assembly language in // most machines by testing the carry flag after adding 'y' to // the value of 'error' in the previous step, since 'error' // nominally has a negative value. if (error >= 0){ --x; error -= x; error -= x; } } } //在指定位置画一个指定大小的圆 //(x,y):中心点 //r :半径 void TCircle::Render2(void) { int a,b; int di; a=0;b=Radius; di=3-(Radius<<1); //判断下个点位置的标志 while(a<=b) { PixelRender(Center.x+a,Center.y-b,PenColor); //5 PixelRender(Center.x+b,Center.y-a,PenColor); //0 PixelRender(Center.x+b,Center.y+a,PenColor); //4 PixelRender(Center.x+a,Center.y+b,PenColor); //6 PixelRender(Center.x-a,Center.y+b,PenColor); //1 PixelRender(Center.x-b,Center.y+a,PenColor); PixelRender(Center.x-a,Center.y-b,PenColor); //2 PixelRender(Center.x-b,Center.y-a,PenColor); //7 a++; //Bresenham algorithm if(di<0)di +=4*a+6; else { di+=10+4*(a-b); b--; } } } void TCircle::sPlot4Points(int cx, int cy, int x, int y, unsigned int aClr) { PixelRender((cx + x), (cy + y), 1, aClr); if (x != 0) PixelRender((cx - x), (cy + y), 1, aClr); if (y != 0) PixelRender((cx + x), (cy - y), 1, aClr); if (x != 0 && y != 0) PixelRender((cx - x), (cy - y), 1, aClr); } void TCircle::sPlot4PointsFill(int cx, int cy, int x, int y, unsigned int aClr) { BoxRender2D((cx-x), (cy+y), (cx+x), (cy+y), aClr); BoxRender2D((cx-x), (cy-y), (cx+x), (cy-y), aClr); } void TCircle::sPlot8Points(int cx, int cy, int x, int y, unsigned int aClr, int IsFill) { if(IsFill) { sPlot4PointsFill(cx, cy, x, y, aClr); if (x != y) sPlot4PointsFill(cx, cy, y, x, aClr); }else{ sPlot4Points(cx, cy, x, y, aClr); if (x != y) sPlot4Points(cx, cy, y, x, aClr); } } void TCircle::sRender(int ax, int ay, int aR, unsigned int aClr, int IsFill) { int tmp = static_cast(aR); int error = (-1 * tmp); unsigned int x = aR; unsigned int y = 0; // The following while loop may altered to 'while (x > y)' for a // performance benefit, as long as a call to 'plot4points' follows // the body of the loop. This allows for the elimination of the // '(x != y') test in 'plot8points', providing a further benefit. // // For the sake of clarity, this is not shown here. while (x >= y){ sPlot8Points(ax, ay, x, y, aClr, IsFill); error += y; ++y; error += y; // The following test may be implemented in assembly language in // most machines by testing the carry flag after adding 'y' to // the value of 'error' in the previous step, since 'error' // nominally has a negative value. if (error >= 0){ --x; error -= x; error -= x; } } } //在指定位置画一个指定大小的圆 //(x,y):中心点 //r :半径 void TCircle::sRender2(int x, int y, int aR, unsigned int aClr) { int a,b; int di; a=0;b=aR; di=3-(aR<<1); //判断下个点位置的标志 while(a<=b) { PixelRender(x+a,y-b,aClr); //5 PixelRender(x+b,y-a,aClr); //0 PixelRender(x+b,y+a,aClr); //4 PixelRender(x+a,y+b,aClr); //6 PixelRender(x-a,y+b,aClr); //1 PixelRender(x-b,y+a,aClr); PixelRender(x-a,y-b,aClr); //2 PixelRender(x-b,y-a,aClr); //7 a++; //Bresenham algorithm if(di<0)di +=4*a+6; else { di+=10+4*(a-b); b--; } } } void TCircle::Plot4PointsQuadrant(int x, int y, int quadrant) { switch(quadrant) { case 0: if (y != 0) PixelRender((Center.x + x), (Center.y - y), PenWidth, PenColor); break; case 1: PixelRender((Center.x + x), (Center.y + y), PenWidth, PenColor); break; case 2: if (x != 0) PixelRender((Center.x - x), (Center.y + y), PenWidth, PenColor); break; case 3: if (x != 0 && y != 0) PixelRender((Center.x - x),(Center.y - y), PenWidth, PenColor); break; } } void TCircle::Plot4PointsFillQuadrant(int x, int y,int quadrant) { switch(quadrant) { case 0: BoxRender2D((Center.x), (Center.y-y), (Center.x+x), (Center.y-y), BrushColor); break; case 1: BoxRender2D((Center.x),(Center.y+y), (Center.x+x), (Center.y+y), BrushColor); break; case 2: BoxRender2D((Center.x-x),(Center.y+y), (Center.x), (Center.y+y), BrushColor); break; case 3: BoxRender2D((Center.x-x),(Center.y-y), (Center.x), (Center.y-y), BrushColor); break; } } void TCircle::Plot8PointsQuadrant(int x, int y, int quadrant) { if(BrushStyle) { Plot4PointsFillQuadrant(x, y, quadrant); if (x != y) Plot4PointsFillQuadrant(y, x, quadrant); }else{ Plot4PointsFillQuadrant(x, y, quadrant); if (x != y) Plot4PointsFillQuadrant(y, x, quadrant); } } void TCircle::RenderQuadrant(int quadrant) //draw circle { int tmp = Radius; signed int error = (-1 * tmp); unsigned int x = Radius; unsigned int y = 0; if(!Radius) { PixelRender(Center.x, Center.y, PenWidth, PenColor); return; } // The following while loop may altered to 'while (x > y)' for a // performance benefit, as long as a call to 'plot4points' follows // the body of the loop. This allows for the elimination of the // '(x != y') test in 'plot8points', providing a further benefit. // // For the sake of clarity, this is not shown here. while (x >= y) { Plot8PointsQuadrant(x, y, quadrant); error += y; ++y; error += y; // The following test may be implemented in assembly language in // most machines by testing the carry flag after adding 'y' to // the value of 'error' in the previous step, since 'error' // nominally has a negative value. if (error >= 0) { --x; error -= x; error -= x; } } } void TCircle::sPlot4PointsFillQuadrant(int ax, int ay, int x, int y, int quadrant, u32 aClr) { switch(quadrant) { case 0: BoxRender2D((ax), (ay-y), (ax+x), (ay-y), aClr); break; case 1: BoxRender2D((ax),(ay+y), (ax+x), (ay+y), aClr); break; case 2: BoxRender2D((ax-x),(ay+y), (ax), (ay+y), aClr); break; case 3: BoxRender2D((ax-x),(ay-y), (ax), (ay-y), aClr); break; } } void TCircle::sPlot8PointsQuadrant(int ax, int ay, int x, int y, int quadrant,u32 aClr) { sPlot4PointsFillQuadrant(ax,ay,x, y, quadrant,aClr); if (x != y) sPlot4PointsFillQuadrant(ax,ay,y, x, quadrant,aClr); } void TCircle::sPlot8PointsFillQuadrant(int ax, int ay, int x, int y, int quadrant, u32 aClr) { sPlot4PointsFillQuadrant(ax,ay,x, y, quadrant,aClr); if (x != y) sPlot4PointsFillQuadrant(ax,ay,y, x, quadrant,aClr); } void TCircle::sRenderQuadrant(int ax, int ay, int aR, int quadrant, u32 aClr, int IsFill) //draw circle { int tmp = aR; signed int error = (-1 * tmp); unsigned int x = aR; unsigned int y = 0; if(!aR) { PixelRender(ax, ay, 1, aClr); return; } // The following while loop may altered to 'while (x > y)' for a // performance benefit, as long as a call to 'plot4points' follows // the body of the loop. This allows for the elimination of the // '(x != y') test in 'plot8points', providing a further benefit. // // For the sake of clarity, this is not shown here. while (x >= y) { if(IsFill) sPlot8PointsFillQuadrant(ax,ay,x, y, quadrant,aClr); else sPlot8PointsQuadrant(ax,ay,x, y, quadrant,aClr); error += y; ++y; error += y; // The following test may be implemented in assembly language in // most machines by testing the carry flag after adding 'y' to // the value of 'error' in the previous step, since 'error' // nominally has a negative value. if (error >= 0) { --x; error -= x; error -= x; } } } void TImageList::SetData(unsigned int aSize, unsigned int aIndex) { unsigned int i,j; if(aSize == 16){ }else if(aSize == 24){ }else if(aSize == 32){ } } void TImageList::LoadFromFlash(unsigned int aSize, unsigned int aIndex) { /* unsigned int i,j; if(aSize == 16){ if(aIndex < dICON16_COUNT){ for(i=0; i<16; i++){ for(j=0; j<16; j++){ Size16[aIndex].HV[i][j] = 0; } } } }else if(aSize == 24){ }else if(aSize == 32){ }*/ } void TImageList::LoadFromFlash(void) { /* unsigned int i; for(i=0;i= yLimit)break; axL = aLeft; for(x=0;x<16;x++){ if(axL >= xLimit){ z = z + 16 - x; Ram_addr += 4 * (16-x); break; } if(TranparrentColor != (*(volatile unsigned int *)(z)) ) *(volatile unsigned int *)(Ram_addr) = (*(volatile unsigned int *)(z)); z += 4; Ram_addr += 4; axL++; } Ram_addr += (800 - 16) *4 ; ayL++; } } }else if(aSize == 22){ if(aIndex < dICON16_COUNT){ } }else if(aSize == 24){ if(aIndex < dICON24_COUNT){ z = FLASH_USER_PIC_24X24 + aIndex * FLASH_USER_PIC_24X24_UINT; TranparrentColor = *(volatile unsigned int *)(z); Ram_addr = ((aTop - 1) * 800 + aLeft) *4 + LcdBaseAddr; ayL = aTop; for(y=0; y<24; y++){ if(ayL >= yLimit)break; axL = aLeft; for(x=0;x<24;x++){ if(axL >= xLimit){ z = z + 24 - x; Ram_addr += 4 * (24-x); break; } if(TranparrentColor != (*(volatile unsigned int *)(z)) ) *(volatile unsigned int *)(Ram_addr) = (*(volatile unsigned int *)(z)); z += 4; Ram_addr += 4; axL++; } Ram_addr += (800 - 24) *4 ; ayL++; } } }else if(aSize == 32){ if(aIndex < dICON32_COUNT){ z = FLASH_USER_PIC_32X32 + aIndex * FLASH_USER_PIC_32X32_UINT; TranparrentColor = *(volatile unsigned int *)(z); Ram_addr = ((aTop - 1) * 800 + aLeft) *4 + LcdBaseAddr; ayL = aTop; for(y=0; y<32; y++){ if(ayL >= yLimit)break; axL = aLeft; for(x=0;x<32;x++){ if(axL >= xLimit){ z = z + 32 - x; Ram_addr += 4 * (32-x); break; } if(TranparrentColor != (*(volatile unsigned int *)(z))) *(volatile unsigned int *)(Ram_addr) = (*(volatile unsigned int *)(z)); z+=4; Ram_addr += 4; axL++; } Ram_addr += (800 - 32) *4 ; ayL++; } } } } unsigned int TImageList::GetSize16Count(void) { return dICON16_COUNT; } unsigned int TImageList::GetSize24Count(void) { return dICON24_COUNT; } unsigned int TImageList::GetSize32Count(void) { return dICON32_COUNT; } void TVScrollBar::sDrawByPoint(int x, int y, int Right, int Bottom, u32 aClr, u32 aBClr, int aItemsCount, int aLineCount, int aTopIndex) { int aW, aH; int RibbonHeight; int RibbonBottom; int RibbonTop; float f1,f2,f3,f4,f5; int CenterPoint; if(aItemsCount <1){ RectFillRender(x, y, Right, Bottom, aBClr); return; } aW = Right - x +1; aH = Bottom - y +1; VertLineRender(x, y, aH, 0xFF808080); VertLineRender(Right, y , aH, 0xFF808080); HorizLineRender(x , y, aW, 0xFF808080); HorizLineRender(x, Bottom, aW, 0xFF808080); if(aItemsCount <= aLineCount){ RibbonTop = y+1; RibbonBottom = Bottom - 1; RibbonHeight = aH - 2; }else{ f1 = static_cast(aTopIndex); f2 = static_cast(aLineCount); f3 = static_cast(aItemsCount); f4 = static_cast(aH-2); f5 = (f1 + (f2/2.0)) / f3 * f4; CenterPoint = (static_cast(f5)) + y +1; RibbonHeight = static_cast(f2 / f3 * f4); if(RibbonHeight < 10)RibbonHeight =10; if(RibbonHeight > (aH-2) )RibbonHeight = aH-2; RibbonTop = CenterPoint - RibbonHeight /2 +1; RibbonBottom = CenterPoint + RibbonHeight /2 +1; if(RibbonTop <= y){ RibbonTop = y+1; RibbonBottom = RibbonTop + RibbonHeight; if(RibbonBottom > (Bottom-1)){ RibbonBottom = Bottom-1; } } if(RibbonBottom > (Bottom-1)){ RibbonBottom = Bottom-1; RibbonTop = RibbonBottom - RibbonHeight; if(RibbonTop <= y){ RibbonTop = y+1; } } } //Draw Vert ScrollBar BackGround RectFillRender(x, y, Right, Bottom, aBClr); //Draw Vert ScrollBar Ribbon RectFillRender(x, RibbonTop, Right, RibbonBottom, aClr); //RectFillRender(x, 90, Right, 160, aClr); } void TVScrollBar::sDrawBySize(int x, int y, int aW, int aH, u32 aClr, u32 aBClr, int aItemsCount, int aLineCount, int aTopIndex) { int Right, Bottom; Right = x + aW -1; Bottom = y + aH -1; sDrawByPoint(x, y, Right, Bottom, aClr, aBClr, aItemsCount, aLineCount, aTopIndex); } void TProgressBar::sDrawByPoint(int x, int y, int Right, int Bottom, int aPercent, int aMax, u32 aClr, u32 aBClr, u32 aTClr) { int aW, aH, x1,y1,x2,y2; float f1,f2,f3,f4; aW = Right - x +1; aH = Bottom - y +1; VertLineRender(x, y, aH, 0xFF808080); VertLineRender(Right, y , aH, 0xFF808080); HorizLineRender(x , y, aW, 0xFF808080); HorizLineRender(x, Bottom, aW, 0xFF808080); aW = aW-2; if(aW < 1)aW = 1; x1 = x+1; y1 = y+1; x2 = Right - 1; y2 = Bottom -1; f1 = static_cast(aPercent); f2 = static_cast(aMax); f3 = static_cast(aW); f4 = f1 / f2 * f3; aW = static_cast(f4); x2 = x1 + aW; RectFillRender(x1, y1, x2, y2, aClr); x2 = Right - 1; x1 = x2 +1; if(x1 < (Right-1)) RectFillRender(x1, y1, x2, y2, aBClr); x1 = x + (aW / 2) - 18; y1 = y + ((aH -24) /2); //TextDigitRender2Right24(x1,y1 ,aTClr, aPercent); } void TProgressBar::sDrawBySize(int x, int y, int aW, int aH, int aPercent, int aMax, u32 aClr, u32 aBClr, u32 aTClr) { int W, x1,y1,x2,y2; int Right, Bottom; float f1,f2,f3,f4; Right = x + aW -1; Bottom = y + aH -1; VertLineRender(x, y, aH, 0xFF808080); VertLineRender(Right, y , aH, 0xFF808080); HorizLineRender(x , y, aW, 0xFF808080); HorizLineRender(x, Bottom, aW, 0xFF808080); W = aW-2; if(W < 1)W = 1; x1 = x+1; y1 = y+1; x2 = Right - 1; y2 = Bottom -1; if(aPercent < 1){ RectFillRender(x1, y1, x2, y2, aBClr); return; } f1 = static_cast(aPercent); f2 = static_cast(aMax); f3 = static_cast(W); f4 = f1 / f2 * f3; W = static_cast(f4); x2 = x1 + W; RectFillRender(x1, y1, x2, y2, aClr); x2 = Right - 1; x1 = x2 +1; if(x1 < (Right-1)) RectFillRender(x1, y1, x2, y2, aBClr); x1 = x + (aW / 2) - 18; y1 = y + ((aH -24) /2); //TextDigitRender3Right24(x1,y1 ,aTClr, aPercent); } void TImage::Render(unsigned int xLimit, unsigned int yLimit) { unsigned int x,y,z; unsigned int Ram_addr; unsigned int i,j,axL,ayL; if(Width > 300)Width = 300; if(Height == 24){ z = FLASH_USER_PIC_LOGO24; TranparrentColor = 0xFF000000; Ram_addr = ((Top - 1) * 800 + Left) *4 + LcdBaseAddr; ayL = Top; for(y=0; y<24; y++){ if(ayL >= yLimit)break; axL = Left; for(x=0;x= xLimit){ z = z + 24 - x; Ram_addr += 4 * (24-x); break; } if(TranparrentColor != (*(volatile unsigned int *)(z)) ) *(volatile unsigned int *)(Ram_addr) = (*(volatile unsigned int *)(z)); z += 4; Ram_addr += 4; axL++; } Ram_addr += (800 - Width) *4 ; ayL++; } }else if(Height == 32){ z = FLASH_USER_PIC_LOGO32; TranparrentColor = 0xFF000000; Ram_addr = ((Top - 1) * 800 + Left) *4 + LcdBaseAddr; ayL = Top; for(y=0; y<32; y++){ if(ayL >= yLimit)break; axL = Left; for(x=0;x= xLimit){ z = z + 32 - x; Ram_addr += 4 * (32-x); break; } if(TranparrentColor != (*(volatile unsigned int *)(z))) *(volatile unsigned int *)(Ram_addr) = (*(volatile unsigned int *)(z)); z+=4; Ram_addr += 4; axL++; } Ram_addr += (800 - Width) *4 ; ayL++; } } } void TRoundSquare::sDrawBySize(int ax, int ay, int aW, int aH, int RoundR, u32 aClr, int Active) { TPoint Lt, Lb, Rt, Rb; Lt.x = ax + RoundR; Lt.y = ay + RoundR; Lb.x = Lt.x; Lb.y = ay + aH -1 - RoundR; Rt.x = ax + aW -1 - RoundR; Rt.y = Lt.y; Rb.x = Rt.x; Rb.y = Lb.y; TCircle::sRenderQuadrant(Lt.x, Lt.y, RoundR, 3, aClr, 1); TCircle::sRenderQuadrant(Rt.x, Rt.y, RoundR, 0, aClr, 1); TCircle::sRenderQuadrant(Lb.x, Lb.y, RoundR, 2, aClr, 1); TCircle::sRenderQuadrant(Rb.x, Rb.y, RoundR, 1, aClr, 1); BoxRender2D((ax), (ay+RoundR-1), (ax+aW-1), (ay+aH-1-RoundR), aClr); BoxRender2D((ax+RoundR-1), (ay), (ax+aW-1-RoundR), (ay+RoundR-1), aClr); BoxRender2D((ax+RoundR-1), (ay+aH-1-RoundR), (ax+aW-1-RoundR), (ay+aH-1), aClr); if(Active){ TPoint Gp; const int PenWidth = (aW * aH) / 200 ; const int OffSet0 = (aW * aH) / 120; const int OffSet1 = OffSet0 * 23 / 10; Gp.x = ax + (aW * 10 / 45); Gp.y = ay + (aH / 2); LineRender(Gp.x, Gp.y, Gp.x +OffSet0, Gp.y +OffSet0, PenWidth, clNearBlack); LineRender(Gp.x +OffSet0, Gp.y +OffSet0, Gp.x +OffSet0 + OffSet1, Gp.y +OffSet0 - OffSet1, PenWidth, clNearBlack); } } void TRoundSquare::sSelected(int ax, int ay, int aW, int aH, int aThick, u32 aColor) { int x,y; const int Thick = aThick; TPoint rP[4]; rP[0].x = ax - Thick; rP[0].y = ay -Thick; //Left Top rP[1].x = ax +aW -1 +1; rP[1].y = rP[0].y; //Right Top rP[2].x = rP[0].x; rP[2].y = ay + aH -1; //Left Bottom rP[3].x = rP[1].x; rP[3].y = rP[2].y; //Right Bottom for(int i=0; i<4; i++){ for(x=0; x=StartH; h-=2){ VertLineRender(x2, y2, h, aClr); x2++; y2++; WidthHasDarw ++; } return WidthHasDarw; } int TTriangleLeftRight::sDrawLeftByHight(int x, int y, int aH, unsigned int aClr) { int x2,y2,IsOdd; int WidthHasDarw; int StartH; if(aH & 0x00000001){ StartH =1; IsOdd = 1; y2 = y + (aH/2); }else{ StartH =2; IsOdd = 0; y2 = y + (aH/2) -1; } WidthHasDarw = 0; x2 = x; for(int h=StartH; h<=aH; h+=2){ VertLineRender(x2, y2, h, aClr); y2--; x2++; WidthHasDarw ++; } WidthHasDarw += aH /5; return WidthHasDarw; } int TTriangleLeftRight::sDrawRightByHight(int x, int y, int aH, unsigned int aClr) { int x2,y2,IsOdd; int WidthHasDarw; int StartH; if(aH & 0x00000001){ StartH =1; IsOdd = 1; y2 = y + (aH/2); }else{ StartH =2; IsOdd = 0; y2 = y + (aH/2) -1; } WidthHasDarw = 0; x2 = x; y2 = y; for(int h=aH; h>=StartH; h-=2){ VertLineRender(x2, y2, h, aClr); x2++; y2++; WidthHasDarw ++; } return WidthHasDarw; }