ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
![](https://box.kancloud.cn/a940cc6febaf93530c027fc90e6a452c_512x461.png)``` case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); HPEN hPen; HPEN hPenOld; hPen = CreatePen(PS_SOLID, 3, RGB(255, 0, 0)); hPenOld = (HPEN)SelectObject(hdc, hPen); // MoveToEx(hdc, 20, 10, NULL); // LineTo(hdc, 200, 100); SelectObject(hdc, hPenOld); // DeleteObject(hPen); // TODO: 在此处添加使用 hdc 的任何绘图代码... // double slope = 0.7;// 0.65;// 0.6123;// 0.6;// 0.75;// 当斜率大于1的时候,绘图要反转,即以y和 DeltaY为循环变量! //1.75;// 0.75;// deltY/deltX=1.45 即斜率(y2-y1)/(x2-x1)=1.75 int x100 = 1000;// 100; int x500 = 5000;// 500; int y100 = 1000;// 100; int y400 = 4000;// 400; MoveToEx(hdc, 50, 10, NULL); Ellipse(hdc, 1, 1, x100 / 100, y100 / 100);// , x500 / 10, y400 / 10);//这是光源 // 15, 15, 130, 130); Rectangle(hdc, x100/10, y100/10, x500/10, y400/10); INT64 maxY; maxY = 2 ^ 63 - 1; INT64 x1 = 100; double dx1 = (double)x1; INT64 x2 = x1; double dx2 = (double)x2; INT64 y1 = 100; double dy1 = (double)y1; INT64 y2 = y1; double dy2 = (double)y2; int flagx = 1; int flagy = 1; int flagy0 = 0;// -1; //flagy0比较晦涩难懂, 有时精密计算的结果是 y2多次等于边界 y400等,当是第一次的时候 就反转 // //for (INT64 ii = 100; ii < 99999; ++ii) {//for110 for (INT64 ii = 100; ii < 999999; ++ii) {//for110 //for (INT64 ii = 100; ii < 9999999; ++ii) {//for110 //x1 = ixi;// / 10; //精密到 0.1 //dx1 = (double)x1; aboutFlag: int needDrawflag = 0; //x1 = (int)dx1; if (x100 >= (x1/1) ) { //if (100 == (x1/10) ) { flagx = 1; needDrawflag = 1; } if (x500 <= (x1/1)) {//if (x500 == (x1/10)) { flagx = -1; needDrawflag = 1; } y1 = (int)dy1;//把y的坐标找出来变成整数 if (y100 >= y1) {//if (y100 == y1) { flagy = 1; needDrawflag = 1; } //if (0==flagy0 && y400 == (int)(y1/1) ) { //if (y400 == (int)(y1/10) || (4000==(int)y1 ) ) { if ( y400 <= (int)y1) { //(int)(y1 / 1)) { flagy = -1; flagy0 = 2; needDrawflag = 1; } if (100 == x1 && 100 == y1) { flagx = 1; flagy = 1; needDrawflag = 1; } //这个点特殊,这是光源,或笛卡尔坐标原点 //aboutFlag-End; if (1 == needDrawflag) { needDrawflag = 0; //about 颜色 hPen = CreatePen(PS_SOLID, 1, RGB(55, 200, 0)); hPenOld = (HPEN)SelectObject(hdc, hPen); //MoveToEx(hdc, 20, 10, NULL); // LineTo(hdc, 200, 100); // SelectObject(hdc, hPenOld); //about 颜色-End LineTo(hdc, x1/10,y1/10); SelectObject(hdc, hPenOld); } label_Y_as_aVar: x2 = x1 + (flagx) * 1; dx2 = dx1 + (flagx) * 1; INT64 deltaX = labs(long(x2 - x1)); dy2 = (flagy)*deltaX*slope + dy1; // SetPixel(hdc, (x2/10), (int)(dy2/10), RGB(1, 200, 0)); // labelEnd990: x1 = x2; dx1 = dx2; if (y1 != y2) { flagy0 = 0; }//此举回复反转开关 y1 = y2; dy1 = dy2; }//for110 // // EndPaint(hWnd, &ps); }//case WM_PAINT: break; case WM_DESTROY: ``` 运行结果 (左上角小圆象征光源) ![](https://box.kancloud.cn/1b957b8e5fd6c6c55e96956570607ea6_520x466.jpg) 用时:不到1秒,(0.1秒?) 当: for (INT64 ii = 100; ii < 2999999; ++ii) {// 6个九9 时:for110 //999999 ![](https://box.kancloud.cn/a940cc6febaf93530c027fc90e6a452c_512x461.png) 7个九: ![](https://box.kancloud.cn/9b778dbf9c0622b038128b9f3ea5ad40_512x455.png) 彻底被“着色” 并且用时不到一秒钟 测试笔记本电脑: macbookPro2011(I7CPU,8G内存)