收藏 分享(赏)

C语言花朵代码.doc

上传人:buyk185 文档编号:6102853 上传时间:2019-03-27 格式:DOC 页数:5 大小:134KB
下载 相关 举报
C语言花朵代码.doc_第1页
第1页 / 共5页
C语言花朵代码.doc_第2页
第2页 / 共5页
C语言花朵代码.doc_第3页
第3页 / 共5页
C语言花朵代码.doc_第4页
第4页 / 共5页
C语言花朵代码.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、. C 语言绘画花朵代码部分#include #include #define PI 3.14159265LRESULT CALLBACK WindowProcedure ( HWND, UINT, WPARAM, LPARAM );void OnPaint ( HDC );void DrawLine ( HDC, int, int, int, int );void DrawFlower ( HDC, int, int, COLORREF );void DrawTie ( HDC, int, int, COLORREF );int WINAPI WinMain ( HINSTANCE hThi

2、sInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil )char szClassName = TEXT ( “DrawFlower“ );HWND hwnd;MSG msg;WNDCLASSEX wc = 0 ;wc.hInstance = hThisInstance;wc.lpszClassName = szClassName;wc.lpfnWndProc = WindowProcedure;wc.style = CS_DBLCLKS;wc.cbSize = sizeof ( WNDCLASSEX )

3、;wc.hIcon = LoadIcon ( NULL, IDI_APPLICATION );wc.hIconSm = LoadIcon ( NULL, IDI_APPLICATION );wc.hCursor = LoadCursor ( NULL, IDC_ARROW );wc.hbrBackground = ( HBRUSH ) ( COLOR_WINDOW+1 );if ( !RegisterClassEx ( hwnd = CreateWindowEx ( 0, szClassName, szClassName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,

4、 0, CW_USEDEFAULT, 0, HWND_DESKTOP, NULL, hThisInstance, NULL );ShowWindow ( hwnd, nFunsterStil );while ( GetMessage ( DispatchMessage ( return msg.wParam;LRESULT CALLBACK WindowProcedure ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )PAINTSTRUCT ps;HDC hdc;switch ( msg )case WM_PAINT:hdc = Be

5、ginPaint ( hwnd, OnPaint ( hdc );EndPaint ( hwnd, break;case WM_DESTROY:PostQuitMessage ( 0 );break;default:return DefWindowProc ( hwnd, msg, wParam, lParam );return 0;void OnPaint ( HDC hdc )HPEN h;/ 画蝴蝶结DrawTie ( hdc, 195, 354, RGB ( 255,0,255 ) );/ 画枝干h = CreatePen ( PS_SOLID, 1, RGB ( 0,255,0 )

6、);SelectObject ( hdc, h );DrawLine ( hdc, 189, 372, 180, 400 );DrawLine ( hdc, 310, 160, 325, 68 );DrawLine ( hdc, 310, 160, 187, 374 );DrawLine ( hdc, 150, 140, 189, 374 );DrawLine ( hdc, 430, 176, 190, 374 );DrawLine ( hdc, 370, 110, 187, 374 );DrawLine ( hdc, 250, 72, 189, 372 );DrawLine ( hdc, 2

7、53, 192, 190, 374 );DrawLine ( hdc, 189, 372, 187, 400 );DrawLine ( hdc, 189, 372, 182, 400 );DrawLine ( hdc, 189, 372, 200, 120 );DeleteObject ( h );/ 画花朵DrawFlower ( hdc, 320, 160, RGB ( 255,0,0 ) );DrawFlower ( hdc, 200, 120, RGB ( 0,255,0 ) );DrawFlower ( hdc, 150, 140, RGB ( 0,0,255 ) );DrawFlo

8、wer ( hdc, 430, 176, RGB ( 255, 127, 0 ) );DrawFlower ( hdc, 370, 110, RGB ( 239, 179, 52 ) );DrawFlower ( hdc, 250, 72, RGB ( 235, 95, 186 ) );DrawFlower ( hdc, 325, 68, RGB ( 228, 119, 98 ) );DrawFlower ( hdc, 253, 190, RGB ( 247, 169, 117 ) );/ 画花朵void DrawFlower ( HDC hdc, int x, int y, COLORREF

9、 c )int x1, y1, x2, y2;const int d = 30;double a, e;HPEN h;h = CreatePen ( PS_SOLID, 1, c );SelectObject ( hdc, h );for ( a = 0; a 2 * PI; a += PI / 360 )e = d * ( 1 + sin ( a * 5 ) );x1 = ( int ) ( x + e * cos ( a ) );y1 = ( int ) ( y + e * sin ( a ) );x2 = ( int ) ( x + e * cos ( a + PI / 5 ) );y2

10、 = ( int ) ( y + e * sin ( a + PI / 5 ) );DrawLine ( hdc, x1, y1, x2, y2 );DeleteObject ( h );/ 画蝴蝶结void DrawTie ( HDC hdc, int x, int y, COLORREF c )int x1, y1, x2, y2;const int d = 100;double a, e;HPEN h;h = CreatePen ( PS_SOLID, 1, c );SelectObject ( hdc, h );for ( a = 0; a 2 * PI; a += PI / 360

11、)e = d * ( 1 + sin ( a * 4 ) );x1 = ( int ) ( x + e * cos ( a ) );y1 = ( int ) ( y + e * sin ( a ) / 2 );x2 = ( int ) ( x + e * cos ( a + PI / 9 ) );y2 = ( int ) ( y + e * sin ( a + PI / 9 ) / 4.5 );DrawLine ( hdc, x1, y1, x2, y2 );DeleteObject ( h );/画线void DrawLine ( HDC hdc, int x1, int y1, int x2, int y2 )MoveToEx ( hdc, x1, y1, NULL );LineTo ( hdc, x2, y2 );

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 网络科技 > C/C++资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报