【计算机图形学】中点画椭圆
如题,急需,哪位大哥大姐帮忙啦。。。。要考试了。。帮帮我啊。。。我要源程序,全的,不要只写其中一部分的!哥们,你的回答不对啊!测试不出来!...
如题,急需,哪位大哥大姐帮忙啦。。。。
要考试了。。
帮帮我啊。。。
我要源程序,全的,不要只写其中一部分的!
哥们,你的回答不对啊!测试不出来! 展开
要考试了。。
帮帮我啊。。。
我要源程序,全的,不要只写其中一部分的!
哥们,你的回答不对啊!测试不出来! 展开
1个回答
展开全部
#include "stdafx.h"
//�办跑计��
HINSTANCE hInst;
HPEN hPen;
HBRUSH hBru;
POINT poly1[5],poly2[5],poly3[5];
//ㄧΑ��
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void MyPaint(HDC hdc);
//****�祘Α**************************************
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
MyRegisterClass(hInstance);
//磅《�﹍てㄧΑ
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
//瘪�癹伴
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//****)竡の爹�跌怠摸�ㄧΑ*************************
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "canvas";
wcex.hIconSm = NULL;
return RegisterClassEx(&wcex);
}
//****�﹍ㄧΑ*************************************
// 1.��娩�郴翴皑��﹍て
// 2.�ミ礶掸籔礶�
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
HDC hdc;
int i;
const double pi = 3.1415926535;
hInst = hInstance;
hWnd = CreateWindow("canvas", "酶瓜跌怠" , WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
MoveWindow(hWnd,10,10,600,450,true);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
for(i=0;i<=4;i++)
{
poly1[i].x = 100 + 100 * sin(i*72*pi/180);
poly1[i].y = 100 + 100 * cos(i*72*pi/180);
poly2[i].x = poly1[i].x + 300;
poly2[i].y = poly1[i].y;
poly3[i].x = poly1[i].x + 180;
poly3[i].y = poly1[i].y + 200;
}
hPen = CreatePen(PS_SOLID,5,RGB(255,0,0));
hBru = CreateHatchBrush(HS_BDIAGONAL,RGB(0,255,0));
hdc = GetDC(hWnd);
MyPaint(hdc);
ReleaseDC(hWnd,hdc);
return TRUE;
}
//****�璹酶瓜ㄧΑ*********************************
// 酶籹�娩�
void MyPaint(HDC hdc)
{
SelectObject(hdc,hPen);
SelectObject(hdc,hBru);
PolylineTo(hdc,poly1,5);
Polyline(hdc,poly2,5);
Polygon(hdc,poly3,5);
}
//****瘪�矪瞶ㄧΑ***********************************
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT: //跌怠�酶瘪�
hdc = BeginPaint(hWnd, &ps);
MyPaint(hdc);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY: //跌怠挡�瘪�
DeleteObject(hPen);
DeleteObject(hBru);
PostQuitMessage(0);
break;
default: //ㄤウ瘪�
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
//�办跑计��
HINSTANCE hInst;
HPEN hPen;
HBRUSH hBru;
POINT poly1[5],poly2[5],poly3[5];
//ㄧΑ��
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void MyPaint(HDC hdc);
//****�祘Α**************************************
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
MyRegisterClass(hInstance);
//磅《�﹍てㄧΑ
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
//瘪�癹伴
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//****)竡の爹�跌怠摸�ㄧΑ*************************
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "canvas";
wcex.hIconSm = NULL;
return RegisterClassEx(&wcex);
}
//****�﹍ㄧΑ*************************************
// 1.��娩�郴翴皑��﹍て
// 2.�ミ礶掸籔礶�
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
HDC hdc;
int i;
const double pi = 3.1415926535;
hInst = hInstance;
hWnd = CreateWindow("canvas", "酶瓜跌怠" , WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
MoveWindow(hWnd,10,10,600,450,true);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
for(i=0;i<=4;i++)
{
poly1[i].x = 100 + 100 * sin(i*72*pi/180);
poly1[i].y = 100 + 100 * cos(i*72*pi/180);
poly2[i].x = poly1[i].x + 300;
poly2[i].y = poly1[i].y;
poly3[i].x = poly1[i].x + 180;
poly3[i].y = poly1[i].y + 200;
}
hPen = CreatePen(PS_SOLID,5,RGB(255,0,0));
hBru = CreateHatchBrush(HS_BDIAGONAL,RGB(0,255,0));
hdc = GetDC(hWnd);
MyPaint(hdc);
ReleaseDC(hWnd,hdc);
return TRUE;
}
//****�璹酶瓜ㄧΑ*********************************
// 酶籹�娩�
void MyPaint(HDC hdc)
{
SelectObject(hdc,hPen);
SelectObject(hdc,hBru);
PolylineTo(hdc,poly1,5);
Polyline(hdc,poly2,5);
Polygon(hdc,poly3,5);
}
//****瘪�矪瞶ㄧΑ***********************************
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT: //跌怠�酶瘪�
hdc = BeginPaint(hWnd, &ps);
MyPaint(hdc);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY: //跌怠挡�瘪�
DeleteObject(hPen);
DeleteObject(hBru);
PostQuitMessage(0);
break;
default: //ㄤウ瘪�
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询