⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 start.cpp

📁 一个LED楼宇亮化同步控制源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	{
		dc2.MoveTo(X,     Y);//第一条线
		dc2.LineTo(nWndX, Y);

		dc2.MoveTo(X,     Y + nHigh/4);//第二条线
		dc2.LineTo(nWndX, Y + nHigh/4);

		dc2.MoveTo(X,	  Y + nHigh/2);//第三条线
		dc2.LineTo(nWndX, Y + nHigh/2);

		dc2.MoveTo(X,	  Y + 3*nHigh/4);//第四条线
		dc2.LineTo(nWndX, Y + 3*nHigh/4);		
		Y = Y + 1;	
		Sleep(5);
	}
	Y	  = m_staPointy[index];
	Sleep(100);

	DeleteObject(pen);
	DeleteObject(penBlack);
	ReleaseDC(&dc1);
	ReleaseDC(&dc2);
}

void Cstart::AccBottmToTop(int index, int order)//积木从下到上
{
	int x = m_staPointx[index];
	int y = m_staPointy[index];
	int m_nWndX = m_staPointx[index] + m_iWidth[index];
	int m_nWndY = m_staPointy[index] + m_iHigh[index];

	CClientDC dc(this);
	CPen pen, penBlack;
	pen.CreatePen(PS_SOLID, 1, m_rgbColor[index][order].Color());
	penBlack.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	int n =10;	
	int OldLine = 0;

	for (int i = m_iHigh[index]; i>=0; i--)
	{
		for (int j = 0; j < i; j++)
		{
            dc.SelectObject(&penBlack);
			dc.MoveTo(x, m_nWndY - OldLine);
			dc.LineTo(m_nWndX, m_nWndY - OldLine);

			dc.SelectObject(&pen);
			dc.MoveTo(x, m_nWndY - j);
			dc.LineTo(m_nWndX, m_nWndY - j);

			OldLine = j;
			Sleep(1);
		}
		OldLine = 0;
	}
	DeleteObject(pen);
	DeleteObject(penBlack);
	ReleaseDC(&dc);
}


void Cstart::AccLeftToRight(int index, int order)//积木从左到右
{
	int x = m_staPointx[index];
	int y = m_staPointy[index];
	int m_nWndY = m_staPointy[index] + m_iHigh[index];

	CClientDC dc(this);
	CPen pen, penBlack;
	pen.CreatePen(PS_SOLID, 1, m_rgbColor[index][order].Color());
	penBlack.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	int n =10;	
	int OldLine = 0;
	for (int i = m_iWidth[index];i>=0;i--)
	{
		for (int j = 0;j < i;j++)
		{
            dc.SelectObject(&penBlack);
			dc.MoveTo(x+OldLine, y);
			dc.LineTo(x+OldLine, m_nWndY);

			dc.SelectObject(&pen);			
			dc.MoveTo(x+j, y);
			dc.LineTo(x+j, m_nWndY);

			OldLine = j;
			Sleep(1);
		}
		OldLine = 0;
	}
	DeleteObject(pen);
	DeleteObject(penBlack);
	ReleaseDC(&dc);
}

void Cstart::AccRightToLeft(int index, int order)//积木从右到左
{
	int x = m_staPointx[index];
	int y = m_staPointy[index];
	int m_nWndX = m_staPointx[index] + m_iWidth[index];
	int m_nWndY = m_staPointy[index] + m_iHigh[index];

	CClientDC dc(this);
	CPen pen, penBlack;
	pen.CreatePen(PS_SOLID, 1, m_rgbColor[index][order].Color());
	penBlack.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	int n =10;	
	int OldLine = 0;
	for (int i = m_iWidth[index];i>=0;i--)
	{
		for (int j = 0;j < i;j++)
		{
            dc.SelectObject(&penBlack);
			dc.MoveTo(m_nWndX - OldLine, y);
			dc.LineTo(m_nWndX - OldLine, m_nWndY);

			dc.SelectObject(&pen);			
			dc.MoveTo(m_nWndX-j, y);
			dc.LineTo(m_nWndX-j, m_nWndY);

			OldLine = j;
			Sleep(1);
		}
		OldLine = 0;
	}
	DeleteObject(pen);
	DeleteObject(penBlack);
	ReleaseDC(&dc);
}

void Cstart::RunDot(int index, int order)//单点滚动
{
	CClientDC dc(this);
	CPen pen, penBlack;
	pen.CreatePen(PS_SOLID, 1, m_rgbColor[index][order].Color());
	penBlack.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));

	int x      = m_staPointx[index];
	int y      = m_staPointy[index];
	int nWidth = m_iWidth[index];
	int nHigh  = m_iHigh[index];
	int nWndX  = m_staPointx[index] + m_iWidth[index];
	int nWndY  = m_staPointy[index] + m_iHigh[index];
	
	while (x <= nWndX)
	{
		dc.SetPixel(x, y, m_rgbColor[index][order].Color());
		dc.SetPixel(x + 1, y, m_rgbColor[index][order].Color());
		Sleep(1);
		dc.SetPixel(x, y, RGB(0, 0, 0));
		dc.SetPixel(x + 1, y , RGB(0, 0, 0));
		x = x + 1;
	}
	x = m_staPointx[index];
	while (y <= nWndY)
	{
		dc.SetPixel(nWndX, y, m_rgbColor[index][order].Color());
		dc.SetPixel(nWndX, y + 1, m_rgbColor[index][order].Color());
		Sleep(1);
		dc.SetPixel(nWndX, y, RGB(0, 0, 0));
		dc.SetPixel(nWndX, y + 1, RGB(0, 0, 0));
		y = y + 1;
	}
	y = m_staPointy[index];

	while (x <= nWndX)
	{
		dc.SetPixel(nWndX, nWndY, m_rgbColor[index][order].Color());
		dc.SetPixel(nWndX - 1, nWndY, m_rgbColor[index][order].Color());
		Sleep(1);
		dc.SetPixel(nWndX, nWndY, RGB(0, 0, 0));
		dc.SetPixel(nWndX - 1, nWndY , RGB(0, 0, 0));
		nWndX = nWndX - 1;
	}
	nWndX = m_staPointx[index] + m_iWidth[index];

	while (y <= nWndY)
	{
		dc.SetPixel(x, nWndY, m_rgbColor[index][order].Color());
		dc.SetPixel(x,  nWndY - 1, m_rgbColor[index][order].Color());
		Sleep(1);
		dc.SetPixel(x, nWndY, RGB(0, 0, 0));
		dc.SetPixel(x , nWndY - 1, RGB(0, 0, 0));
		nWndY = nWndY - 1;
	}
	nWndY = m_staPointy[index] + m_iHigh[index];
	DeleteObject(pen);
	DeleteObject(penBlack);
	ReleaseDC(&dc);
}


void Cstart::RunLine(int index, int order)
{
	CClientDC dc(this);
	CPen pen, penBlack;

	pen.CreatePen(PS_SOLID, 1, m_rgbColor[index][order].Color());
	penBlack.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));

	int X = 0, Y = 0, nSegWidth = 0, nSegHigh = 0, nWidth = 0, nHigh = 0, nWndX = 0, nWndY = 0;
	X = m_staPointx[index];
	Y = m_staPointy[index];
	nWidth = m_iWidth[index];
	nHigh  = m_iHigh[index];
	nSegWidth = m_iWidth[index] / 5;
	nSegHigh  = m_iHigh[index]  / 5;
	nWndX  = m_staPointx[index] + m_iWidth[index];
	nWndY  = m_staPointy[index] + m_iHigh[index];

	for (int n = 0; n < 10; n++)
	{
		int tempX = 0, tempY = 0;
		tempY = Y + nSegHigh;
		dc.SelectObject(&pen);
		dc.MoveTo(X, Y);
		dc.LineTo(X, tempY);
		Sleep(20);
		while (tempY < nWndY)
		{
			tempY = tempY - nSegHigh/2;			
			dc.SelectObject(&penBlack);
			dc.MoveTo(X, Y);
			dc.LineTo(X, tempY);
			Sleep(20);	
			dc.SelectObject(&pen);
			dc.MoveTo(X, tempY);
			tempY = tempY + nSegHigh;	
			dc.LineTo(X, tempY);
		}
		dc.SelectObject(&penBlack);
		dc.MoveTo(X, Y);
		dc.LineTo(X, nWndY);

		tempX = X + nSegWidth;
		dc.SelectObject(&pen);
		dc.MoveTo(X, nWndY);
		dc.LineTo(tempX, nWndY);
		Sleep(20);
		while (tempX < nWndX)
		{
			tempX = tempX - nSegWidth/2;
			dc.SelectObject(&penBlack);
			dc.MoveTo(X, nWndY);
			dc.LineTo(tempX, nWndY);
			Sleep(20);

			dc.SelectObject(&pen);
			dc.MoveTo(tempX, nWndY);
			tempX = tempX + nSegWidth;
			dc.LineTo(tempX, nWndY);
		}
		dc.SelectObject(&penBlack);
		dc.MoveTo(X, nWndY);
		dc.LineTo(nWndX, nWndY);

		tempY = nWndY - nSegHigh;
		dc.SelectObject(&pen);
		dc.MoveTo(nWndX, nWndY);
		dc.LineTo(nWndX, tempY);
		Sleep(20);
		while (Y < tempY)
		{
			tempY = tempY + nSegHigh/2;
			dc.SelectObject(&penBlack);
			dc.MoveTo(nWndX, nWndY);
			dc.LineTo(nWndX, tempY);
			Sleep(20);

			dc.SelectObject(&pen);
			dc.MoveTo(nWndX, tempY);
			tempY = tempY - nSegHigh;
			dc.LineTo(nWndX, tempY);
		}
		dc.SelectObject(&penBlack);
		dc.MoveTo(nWndX, nWndY);
		dc.LineTo(nWndX, Y);

		tempX = nWndX - nSegWidth;
		dc.SelectObject(&pen);
		dc.MoveTo(nWndX, Y);
		dc.LineTo(tempX, Y);
		Sleep(20);
		while (X < tempX)
		{
			tempX = tempX + nSegWidth/2;
			dc.SelectObject(&penBlack);
			dc.MoveTo(nWndX, Y);
			dc.LineTo(tempX, Y);
			Sleep(20);

			dc.SelectObject(&pen);
			dc.MoveTo(tempX, Y);
			tempX = tempX - nSegWidth;
			dc.LineTo(tempX, Y);
		}
		
		dc.SelectObject(&penBlack);
		dc.MoveTo(nWndX, Y);
		dc.LineTo(X, Y);
	}
	DeleteObject(pen);
	DeleteObject(penBlack);
	ReleaseDC(&dc);
}


void Cstart::RoundRunOutToIn(int index, int order)
{
	CClientDC dc(this);

	int x = 0, y = 0, m_nWndX = 0, m_nWndY = 0;
	int i =0, j = 0;

	while ( (i<= (m_iWidth[index]/2) ) && (j<= (m_iHigh[index]/2) ) )
	{
		x = m_staPointx[index] + i;
		y = m_staPointy[index] + j;
		m_nWndX = m_staPointx[index] + m_iWidth[index] - i;
		m_nWndY = m_staPointy[index] + m_iHigh[index]  - j;

		{	
			Sleep(100);
			while (x <= m_nWndX)
			{	
				dc.SetPixel(x, y, m_rgbColor[index][order].Color());//反向转x
				x = x + 1;
			}
			Sleep(100);

			while (y <= m_nWndY)
			{
				dc.SetPixel(m_nWndX , y, m_rgbColor[index][order].Color());//右边y反向
				y = y + 1;
			}
			Sleep(100);

			x = m_staPointx[index] + i;
			while (x <= m_nWndX)
			{
	
				dc.SetPixel(m_nWndX, m_nWndY , m_rgbColor[index][order].Color());//下边x	
				m_nWndX = m_nWndX - 1;;
			}

			Sleep(100);
			y = m_staPointy[index] + j;
			while (y < m_nWndY)
			{
				dc.SetPixel(x, m_nWndY , m_rgbColor[index][order].Color());//左边x
				m_nWndY = m_nWndY - 1;
			}
		}
		i = i + 2;
		j = j + 2;
	}

	ReleaseDC(&dc);
}

void Cstart::RoundRunOutToInColor(int index, int order)//盒子从外到里颜色变幻
{
	CClientDC dc(this);

	int x = 0, y = 0, m_nWndX = 0, m_nWndY = 0;
	int i =0, j = 0, nPen = 0;
	
	COLORREF ArrRGB[7];
	ArrRGB[0] = RGB(255, 0, 0);
	ArrRGB[1] = RGB(128, 128, 0);
	ArrRGB[2] = RGB(255, 255, 0);
	ArrRGB[3] = RGB(0, 255, 0);
	ArrRGB[4] = RGB(0, 0, 255,);
	ArrRGB[5] = RGB(192, 192, 192);
	ArrRGB[6] = RGB(128, 0, 0);
	
	while ( (i<= (m_iWidth[index]/2) ) && (j<= (m_iHigh[index]/2) ) )
	{
		x = m_staPointx[index] + i;
		y = m_staPointy[index] + j;
		m_nWndX = m_staPointx[index] + m_iWidth[index] - i;
		m_nWndY = m_staPointy[index] + m_iHigh[index]  - j;

		{	
			Sleep(100);
			while (x <= m_nWndX)
			{	
				dc.SetPixel(x, y, ArrRGB[nPen]);//反向转x
				x = x + 1;
			}
			Sleep(100);

			while (y <= m_nWndY)
			{
				dc.SetPixel(m_nWndX , y, ArrRGB[nPen]);//右边y反向
				y = y + 1;
			}
			Sleep(100);

			x = m_staPointx[index] + i;
			while (x <= m_nWndX)
			{
	
				dc.SetPixel(m_nWndX, m_nWndY ,ArrRGB[nPen]);//下边x	
				m_nWndX = m_nWndX - 1;;
			}

			Sleep(100);
			y = m_staPointy[index] + j;
			while (y < m_nWndY)
			{
				dc.SetPixel(x, m_nWndY , ArrRGB[nPen]);//左边x
				m_nWndY = m_nWndY - 1;
			}
		}
		i = i + 2;
		j = j + 2;
		nPen = (nPen + 1) % 7;	
	}

	ReleaseDC(&dc);
}

void Cstart::RoundRunInToOut(int index, int order)//盒子从里到外
{
	CClientDC dc(this);

	int i = 0, j =0;
	int X = 0, Y = 0,  nWndX = 0, nWndY = 0;
	int CoordinateXAdd = 0, CoordinateXSub = 0, CoordinateYAdd = 0, CoordinateYSub = 0;
	X = m_staPointx[index];
	Y = m_staPointy[index];
	CoordinateXAdd = CoordinateXSub = m_staPointx[index] + (int)(m_iWidth[index]/2);//矩形中点坐标X
	CoordinateYAdd = CoordinateYSub =  m_staPointy[index] + (int)(m_iHigh[index]/2);//矩形中点坐标Y

	while ( (X <= CoordinateXSub)&&(Y <= CoordinateYSub) )
	{
		{
			Sleep(50);
			int x = CoordinateXSub;
			while (x <= CoordinateXAdd)
			{
				dc.SetPixel(x ,CoordinateYSub, m_rgbColor[index][order].Color());
				x = x  + 1;
			}

		}
		CoordinateXSub = CoordinateXSub - 2;
		CoordinateXAdd = CoordinateXAdd + 2;
		CoordinateYSub = CoordinateYSub - 2;
		CoordinateYAdd = CoordinateYAdd + 2;

	}
	CoordinateXAdd = CoordinateXSub = m_staPointx[index] + (int)(m_iWidth[index]/2);
	CoordinateYAdd = CoordinateYSub =  m_staPointy[index] + (int)(m_iHigh[index]/2);

	while ( (X <= CoordinateXSub) && (Y <= CoordinateYSub) )
	{
		{
			Sleep(50);
			int y =  CoordinateYSub;
			while (y <= CoordinateYAdd)
			{
				dc.SetPixel(CoordinateXAdd, y, m_rgbColor[index][order].Color());
				y = y + 1;
			}	

		}
		CoordinateXSub = CoordinateXSub - 2;
		CoordinateXAdd = CoordinateXAdd + 2;
		CoordinateYSub = CoordinateYSub - 2;
		CoordinateYAdd = CoordinateYAdd + 2;

	}
	CoordinateXAdd = CoordinateXSub = m_staPointx[index] + (int)(m_iWidth[index]/2);//矩形中点坐标X
	CoordinateYAdd = CoordinateYSub =  m_staPointy[index] + (int)(m_iHigh[index]/2);//矩形中点坐标Y

	while ( (X <= CoordinateXSub) && (Y <= CoordinateYSub) )
	{
		{

			Sleep(50);
		     int x = CoordinateXAdd;
			while ( CoordinateXSub <= 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -