📄 tlines.h
字号:
#ifndef TLINESH
#define TLINESH
#include "ScreenSave.h"
#include <time.h>
#include <stdlib.h>
#define NumOfPoint 4 //顶点个数
#define NumOfPolygan 6 //每次擦去擦去前NumOfPolygan的那条线
struct TPOINT //定义储存顶点的结构类型
{
int x,y; //横,纵坐标
int vx,vy; //横,纵向速度
int Oldx[NumOfPolygan],Oldy[NumOfPolygan]; //前NumOfPolygan个坐标
};
struct TCOLOR //定义储存颜色的结构类型
{
int nRed;
int nGreen;
int nBlue;
};
class TLines //定义此类,便于画任意多个多边形
{
private:
TPOINT pt[NumOfPoint]; //定义储存顶点的结构变量
TCOLOR color; //定义储存颜色的结构变量
public:
TLines() //构造函数
{ //初始化横,纵坐标; 横,纵向速度
for (int i=0;i<NumOfPoint;i++) {
pt[i].x = 20+rand()*400/RAND_MAX; pt[i].vx = rand()*10/RAND_MAX+1;
pt[i].y = 30+rand()*400/RAND_MAX; pt[i].vy = rand()*10/RAND_MAX+1;
for (int j=0;j<NumOfPolygan;j++) {
pt[i].Oldx[j] = pt[i].x;
pt[i].Oldy[j] = pt[i].y;
}
}
//初始化颜色
color.nRed = rand()*255/RAND_MAX;
color.nGreen = rand()*255/RAND_MAX;
color.nBlue = rand()*255/RAND_MAX;
}
void Draw(HWND hwnd); //画线,整个程序写的最关键函数
void ChangeColor(); //改变颜色
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -