鱼C论坛

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

这太极怎么 涂色

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

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

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

x


                               
登录/注册后可看大图

大佬 帮忙讲讲 谢谢了


                               
登录/注册后可看大图

#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;
        MSG  msg;
        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[128];
        static int xClient, yClient;
        static POINT apt[4];

        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[0].x = xClient / 2;
                        apt[0].y = 0;
                        apt[2].x = xClient/2-yClient/2;
                        apt[2].y = yClient / 2;
                        apt[1].x = xClient / 2 + yClient / 2;
                        apt[1].y = yClient / 2;
                        apt[3].x = xClient / 2;
                        apt[3].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);

}

怎么涂色

怎么涂色
想知道小甲鱼最近在做啥?请访问 -> 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-6-18 15:22

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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