📄 扫买哦.cpp.txt
字号:
int SsDraw::FillArea(int x, int y, COLORREF newColor)
{
int xl,xr;
BOOL spanNeedFill;
CPoint pt,pp;
stack<CPoint> stk;
pt.x = x; pt.y = y;
stk.push(pt);
COLORREF oldColor = GetPixel(pt);
if(oldColor == -1)
return -1;
while(!stk.empty())
{
pt = stk.top();
stk.pop();
pp.y=pt.y;
pp.x=pt.x;
while(GetPixel(pp)==oldColor) //向右填充
{
PutPixel(pp.x, pp.y);
pp.x++;
Sleep(m_Delay/2);
}
xr = pp.x-1;
pp.x = pt.x-1;
while(GetPixel(pp)==oldColor) //向左填充
{
PutPixel(pp.x, pp.y);
pp.x--;
Sleep(m_Delay/2);
}
xl = pp.x+1;
//处理上面一条扫描线
pp.x = xl;
pp.y = pp.y+1;
while(pp.x<xr)
{
spanNeedFill=FALSE;
while(GetPixel(pp)==oldColor)
{
spanNeedFill=TRUE;
pp.x++;
}
if(spanNeedFill)
{
pt.x=pp.x-1;pt.y=pp.y;
stk.push(pt);
spanNeedFill=FALSE;
}
while(GetPixel(pp)!=oldColor && pp.x<xr)
pp.x++;
}//End of while(i<xr)
//处理下面一条扫描线,代码与处理上面一条扫描线类似
pp.x = xl;
pp.y = pp.y-2;
while(pp.x<xr)
{
spanNeedFill=FALSE;
while(GetPixel(pp)==oldColor)
{
spanNeedFill=TRUE;
pp.x++;
}
if(spanNeedFill)
{
pt.x=pp.x-1;
pt.y=pp.y;
stk.push(pt);
spanNeedFill=FALSE;
}
while(GetPixel(pp)!=oldColor && pp.x<xr)
pp.x++;
}//End of while(i<xr)
}//End of while(!isstackempty())
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -