//全局变量
HPEN hPen;
HBRUSH hBru[4];
int sBru[4] = { HS_VERTICAL, HS_HORIZONTAL, HS_CROSS, HS_DIAGCROSS };

 


//--------------------------------------------MyPaint() 函数---------------------------------------------------
//绘制图形
//-------------------------------------------------------------------------------------------------------------
void MyPaint(HDC hdc)
{
hPen = CreatePen(PS_SOLID, 3, RGB(rand() % 255, rand() % 255, rand() % 255));
for (int i = 0; i <= 3; i++)
{
hBru[i] = CreateHatchBrush(sBru[i], RGB(rand() % 255, rand() % 255, rand() % 255));
}

SelectObject(hdc, hPen);

SelectObject(hdc, hBru[0]);
Ellipse(hdc, 20, 20, 270, 150);
TextOut(hdc, 120, 160, "椭圆形", strlen("椭圆形"));

SelectObject(hdc, hBru[1]);
RoundRect(hdc, 300, 20, 550, 150, 30, 30);
TextOut(hdc, 400, 160, "圆角矩形", strlen("圆角矩形"));

SelectObject(hdc, hBru[2]);
Pie(hdc,
20, //外围左上点x坐标
220, //外围左上点y坐标
270, //外围右下点x坐标
340, //外围右下点y坐标
50, //起点x坐标
50, //起点y坐标
200, //终点x坐标
200); //终点y坐标
TextOut(hdc, 120, 350, "扇形", strlen("扇形"));

SelectObject(hdc, hBru[3]);
Chord(hdc, 300, 210, 550, 340, 50, 50, 600, 300);
TextOut(hdc, 400, 350, "弓形", strlen("弓形"));


SelectObject(hdc, hBru[1]);
RoundRect(hdc,
20, //矩形左上x坐标
400,//矩形左上y坐标
550, //矩形右下x坐标
500, //矩形右下y坐标
0, //圆角上椭的长度
50); //圆角上椭圆的高
TextOut(hdc, 220, 520, "直角矩形", strlen("直角矩形"));

}

 

如需整体运行框架,请点击: 游戏框架

游戏开发的梦想

梦开始的地方

posted on 2015-11-21 22:18  zishen  阅读(668)  评论(0编辑  收藏  举报