鱼C论坛

 找回密码
 立即注册
查看: 2313|回复: 2

这太极怎么 涂色

[复制链接]
发表于 2017-10-16 20:37:22 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x


                               
登录/注册后可看大图

大佬 帮忙讲讲 谢谢了


                               
登录/注册后可看大图


  1. #include <windows.h>
  2. #include <strsafe.h>
  3. #include <math.h>

  4. #define NUM 1000
  5. #define PI 3.14

  6. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

  7. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstcance, PSTR lpCmdLine, int iCmdShow)
  8. {
  9.         HWND hwnd;
  10.         MSG  msg;
  11.         WNDCLASS wndclass;

  12.         //窗口类名
  13.         WCHAR szClassName[] = TEXT("FristWindow");

  14.         //初始化窗口类
  15.         wndclass.style = CS_HREDRAW | CS_VREDRAW;
  16.         wndclass.lpfnWndProc = WndProc;
  17.         wndclass.cbClsExtra = 0;
  18.         wndclass.cbWndExtra = 0;
  19.         wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  20.         wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  21.         wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  22.         wndclass.hInstance = hInstance;
  23.         wndclass.lpszClassName = szClassName;
  24.         wndclass.lpszMenuName = NULL;

  25.         //注册窗口类
  26.         if (!RegisterClass(&wndclass))
  27.         {
  28.                 MessageBox(NULL, TEXT("本程序只能在 WINDOWS NT 框架上运行!!!"), TEXT("提示信息:"), MB_OK | MB_ICONERROR);
  29.                 return 0;
  30.         }

  31.         //创建窗口
  32.         hwnd = CreateWindow(szClassName, TEXT("FristWindow"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);


  33.         //显示并更新窗口
  34.         ShowWindow(hwnd, iCmdShow);
  35.         UpdateWindow(hwnd);

  36.         //消息循环
  37.         while (GetMessage(&msg, NULL, 0, 0))
  38.         {
  39.                 TranslateMessage(&msg);
  40.                 DispatchMessage(&msg);
  41.         }

  42.         return msg.wParam;
  43. }

  44. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  45. {

  46.         HDC                                hdc;
  47.         PAINTSTRUCT                ps;
  48.         RECT                        rect;
  49.         WCHAR szBuffer[128];
  50.         static int xClient, yClient;
  51.         static POINT apt[4];

  52.         switch (msg)
  53.         {
  54.         case WM_SIZE:
  55.                 xClient = LOWORD(lParam);
  56.                 yClient = HIWORD(lParam);

  57.                 return 0;



  58.         case WM_PAINT:
  59.                 hdc = BeginPaint(hwnd, &ps);
  60.                 GetClientRect(hwnd, &rect);



  61.                 SetPixelV(hdc,xClient/2,yClient/2, RGB(255,0,0));
  62.             if (yClient < xClient)
  63.                 {
  64.                         //SelectObject(hdc, GetStockObject(BLACK_BRUSH));
  65.                         Ellipse(hdc, xClient/2-yClient/2, 0, xClient/2+yClient/2, yClient);
  66.                         apt[0].x = xClient / 2;
  67.                         apt[0].y = 0;
  68.                         apt[2].x = xClient/2-yClient/2;
  69.                         apt[2].y = yClient / 2;
  70.                         apt[1].x = xClient / 2 + yClient / 2;
  71.                         apt[1].y = yClient / 2;
  72.                         apt[3].x = xClient / 2;
  73.                         apt[3].y = yClient;
  74.                         //SelectObject(hdc, GetStockObject(WHITE_BRUSH));
  75.                         PolyBezier(hdc, apt, 4);

  76.                         SelectObject(hdc, GetStockObject(WHITE_BRUSH));
  77.                         Ellipse(hdc,xClient/2-20,yClient/4-20 ,xClient/2+20,yClient/4+20);
  78.                         SelectObject(hdc, GetStockObject(BLACK_BRUSH));
  79.                         Ellipse(hdc, xClient / 2 - 20, 3*yClient / 4 - 20, xClient / 2 + 20, 3*yClient / 4 + 20);
  80.                 }

  81.                 //结束绘画
  82.         /*        MoveToEx(hdc, 0, yClient / 2, 0);
  83.                 LineTo(hdc, xClient, yClient / 2);
  84.                 MoveToEx(hdc, xClient / 2, 0, 0);
  85.                 LineTo(hdc, xClient / 2, yClient);*/

  86.                 EndPaint(hwnd, &ps);
  87.                 break;

  88.         case WM_CLOSE:
  89.                 PostQuitMessage(0);
  90.                 break;
  91.         }

  92.         return DefWindowProc(hwnd, msg, wParam, lParam);

  93. }
复制代码

怎么涂色

怎么涂色
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-10-20 18:41:16 | 显示全部楼层
你这个太极不标准啊,中间的线是cos函数么,先涂左边的半圆(黑色),至于cos函数的曲线,以中心为基线,创建一个多边形的区域,在将这个区域涂成白色
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-10-27 16:18:10 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-28 22:06

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表