这太极怎么 涂色
static/image/hrline/line4.png
大佬 帮忙讲讲 谢谢了
static/image/hrline/line7.png
#include <windows.h>
#include <strsafe.h>
#include <math.h>
#define NUM 1000
#define PI 3.14
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstcance, PSTR lpCmdLine, int iCmdShow)
{
HWND hwnd;
MSGmsg;
WNDCLASS wndclass;
//窗口类名
WCHAR szClassName[] = TEXT("FristWindow");
//初始化窗口类
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hInstance = hInstance;
wndclass.lpszClassName = szClassName;
wndclass.lpszMenuName = NULL;
//注册窗口类
if (!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("本程序只能在 WINDOWS NT 框架上运行!!!"), TEXT("提示信息:"), MB_OK | MB_ICONERROR);
return 0;
}
//创建窗口
hwnd = CreateWindow(szClassName, TEXT("FristWindow"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
//显示并更新窗口
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
//消息循环
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
WCHAR szBuffer;
static int xClient, yClient;
static POINT apt;
switch (msg)
{
case WM_SIZE:
xClient = LOWORD(lParam);
yClient = HIWORD(lParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
SetPixelV(hdc,xClient/2,yClient/2, RGB(255,0,0));
if (yClient < xClient)
{
//SelectObject(hdc, GetStockObject(BLACK_BRUSH));
Ellipse(hdc, xClient/2-yClient/2, 0, xClient/2+yClient/2, yClient);
apt.x = xClient / 2;
apt.y = 0;
apt.x = xClient/2-yClient/2;
apt.y = yClient / 2;
apt.x = xClient / 2 + yClient / 2;
apt.y = yClient / 2;
apt.x = xClient / 2;
apt.y = yClient;
//SelectObject(hdc, GetStockObject(WHITE_BRUSH));
PolyBezier(hdc, apt, 4);
SelectObject(hdc, GetStockObject(WHITE_BRUSH));
Ellipse(hdc,xClient/2-20,yClient/4-20 ,xClient/2+20,yClient/4+20);
SelectObject(hdc, GetStockObject(BLACK_BRUSH));
Ellipse(hdc, xClient / 2 - 20, 3*yClient / 4 - 20, xClient / 2 + 20, 3*yClient / 4 + 20);
}
//结束绘画
/* MoveToEx(hdc, 0, yClient / 2, 0);
LineTo(hdc, xClient, yClient / 2);
MoveToEx(hdc, xClient / 2, 0, 0);
LineTo(hdc, xClient / 2, yClient);*/
EndPaint(hwnd, &ps);
break;
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
} 你这个太极不标准啊,中间的线是cos函数么,先涂左边的半圆(黑色),至于cos函数的曲线,以中心为基线,创建一个多边形的区域,在将这个区域涂成白色 参考我的画法:
http://bbs.fishc.com/thread-92556-1-1.html
页:
[1]