坐标转换

基础知识:设备坐标系统属性

其他知识:GDI映射模式

视口与窗口坐标转换公式:

以下代码都需要该代码支持:

 1 //int wmId, wmEvent;
 2     PAINTSTRUCT ps;
 3     HDC hdc;
 4     static int cxClient, cyClient;
 5     static HPEN hPen,oldHPen;
 6     static int cxChar, cxCpas, cyChar;
 7     TEXTMETRIC tm;
 8 
 9     switch (message)
10     {
11     //case WM_COMMAND:
12     //    wmId    = LOWORD(wParam);
13     //    wmEvent = HIWORD(wParam);
14     //    // 分析菜单选择: 
15     //    switch (wmId)
16     //    {
17     //    case IDM_ABOUT:
18     //        DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
19     //        break;
20     //    case IDM_EXIT:
21     //        DestroyWindow(hWnd);
22     //        break;
23     //    default:
24     //        return DefWindowProc(hWnd, message, wParam, lParam);
25     //    }
26     //    break;
27     case WM_CREATE:
28         hPen = CreatePen(PS_DASH, 0, RGB(255, 0, 0));
29         hdc = GetDC(hWnd);
30         GetTextMetrics(hdc, &tm);
31         cxChar = tm.tmAveCharWidth;
32         cxCpas = (tm.tmPitchAndFamily & 1 ? 3 : 2)*cxChar / 2;
33         cyChar = tm.tmHeight + tm.tmExternalLeading;
34         ReleaseDC(hWnd, hdc);
35     case WM_SIZE:
36         cxClient = LOWORD(lParam);
37         cyClient = HIWORD(lParam);
38         return 0;
View Code

原点设置在窗口中间通过更改矩形坐标实现居中

1 //原点设置在窗口中间通过更改矩形坐标实现居中
2         oldHPen = (HPEN)SelectObject(hdc, hPen);
3         MoveToEx(hdc, cxClient / 2, 0, NULL);
4         LineTo(hdc, cxClient / 2, cyClient);
5         MoveToEx(hdc, 0, cyClient / 2,NULL);
6         LineTo(hdc, cxClient, cyClient / 2);
7         SelectObject(hdc, oldHPen);
8         SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);
9         Rectangle(hdc, -50, 50, 50, -50);
View Code

通过设置原点使矩形实现居中

1 //通过设置原点使矩形实现居中
2         oldHPen = (HPEN)SelectObject(hdc, hPen);
3         MoveToEx(hdc, cxClient / 2, 0, NULL);
4         LineTo(hdc, cxClient / 2, cyClient);
5         MoveToEx(hdc, 0, cyClient / 2,NULL);
6         LineTo(hdc, cxClient, cyClient / 2);
7         SelectObject(hdc, oldHPen);
8         SetViewportOrgEx(hdc, (cxClient / 2)-150, (cyClient / 2)-150, NULL);
9         Rectangle(hdc, 100, 100, 200, 200);
View Code

通过更改TextOut的y轴实现hello的垂直输出

//通过更改TextOut的y轴实现hello的垂直输出
        oldHPen = (HPEN)SelectObject(hdc, hPen);
        MoveToEx(hdc, cxClient / 2, 0, NULL);
        LineTo(hdc, cxClient / 2, cyClient);
        MoveToEx(hdc, 0, cyClient / 2,NULL);
        LineTo(hdc, cxClient, cyClient / 2);
        SelectObject(hdc, oldHPen);
        for(int t = 0,y; t < 5;++t)
        {
            y = cyChar*t;
            TextOut(hdc, 0, y, TEXT("hello"), 5);
        }
View Code

通过更改视口的原点实现hello的垂直输出

 1 //通过更改视口的原点实现hello的垂直输出
 2         oldHPen = (HPEN) SelectObject(hdc, hPen);
 3         MoveToEx(hdc, cxClient / 2, 0, NULL);
 4         LineTo(hdc, cxClient / 2, cyClient);
 5         MoveToEx(hdc, 0, cyClient / 2, NULL);
 6         LineTo(hdc, cxClient, cyClient / 2);
 7         SelectObject(hdc, oldHPen);
 8         for(int t = 0, y; t < 5; ++t)
 9         {
10             y = cyChar*t;
11             SetViewportOrgEx(hdc, 0, y, NULL);
12             TextOut(hdc, 0, 0, TEXT("hello"), 5);
13         }
View Code

通过更改视口原点的x轴实现hello的横排列输出

 1 //通过更改视口原点的x轴实现hello的横排列输出
 2         oldHPen = (HPEN) SelectObject(hdc, hPen);
 3         MoveToEx(hdc, cxClient / 2, 0, NULL);
 4         LineTo(hdc, cxClient / 2, cyClient);
 5         MoveToEx(hdc, 0, cyClient / 2, NULL);
 6         LineTo(hdc, cxClient, cyClient / 2);
 7         SelectObject(hdc, oldHPen);
 8         for(int t = 0, x; t < 5; ++t)
 9         {
10             x = 50*t;
11             SetViewportOrgEx(hdc, x, 0, NULL);
12             TextOut(hdc, 0, 0, TEXT("hello"), 5);
13         }
View Code

设置窗口原更改Rectanglex轴和y轴实现居中

 1 //设置窗口原更改Rectanglex轴和y轴实现居中
 2         oldHPen = (HPEN)SelectObject(hdc, hPen);
 3         MoveToEx(hdc, cxClient / 2, 0, NULL);
 4         LineTo(hdc, cxClient / 2, cyClient);
 5         MoveToEx(hdc, 0, cyClient / 2,NULL);
 6         LineTo(hdc, cxClient, cyClient / 2);
 7         SelectObject(hdc, oldHPen);
 8         POINT apt;
 9         apt.x = cxClient;
10         apt.y = cyClient;
11         DPtoLP(hdc, &apt, 1);
12         SetWindowOrgEx(hdc, -apt.x / 2, -apt.y / 2, NULL);
13         Rectangle(hdc, -50, 50, 50, -50);
View Code

设置窗口原点实现Rectangle居中

 1 //设置窗口原点实现Rectangle居中
 2         oldHPen = (HPEN) SelectObject(hdc, hPen);
 3         MoveToEx(hdc, cxClient / 2, 0, NULL);
 4         LineTo(hdc, cxClient / 2, cyClient);
 5         MoveToEx(hdc, 0, cyClient / 2, NULL);
 6         LineTo(hdc, cxClient, cyClient / 2);
 7         SelectObject(hdc, oldHPen);
 8         POINT apt;
 9         apt.x = cxClient;
10         apt.y = cyClient;
11         DPtoLP(hdc, &apt, 1);
12         SetWindowOrgEx(hdc, -apt.x / 2+50, -apt.y / 2+50, NULL);
13         Rectangle(hdc, 0, 0, 100, 100);
View Code

非MM_TEXT映射下的坐标转换更改Rectangle坐标轴

 1 //非MM_TEXT映射下的坐标转换更改Rectangle坐标轴
 2         SetMapMode(hdc, MM_LOMETRIC);
 3         oldHPen = (HPEN) SelectObject(hdc, hPen);
 4         POINT pt;
 5         pt.x = cxClient;
 6         pt.y = cyClient;
 7         DPtoLP(hdc, &pt, 1);
 8         MoveToEx(hdc, pt.x/2, 0, NULL);
 9         LineTo(hdc, pt.x / 2, pt.y);
10         MoveToEx(hdc, 0, pt.y / 2, NULL);
11         LineTo(hdc, pt.x, pt.y / 2);
12         SelectObject(hdc, oldHPen);
13         SetWindowOrgEx(hdc, -pt.x / 2, -pt.y / 2, NULL);
14         Rectangle(hdc, -50, 50, 50, -50);
View Code

非MM_TEXT映射下的坐标转换更改原点实现Rectangle居中

 1 //非MM_TEXT映射下的坐标转换更改原点实现Rectangle居中
 2         SetMapMode(hdc, MM_LOMETRIC);
 3         oldHPen = (HPEN) SelectObject(hdc, hPen);
 4         POINT pt;
 5         pt.x = cxClient;
 6         pt.y = cyClient;
 7         DPtoLP(hdc, &pt, 1);
 8         MoveToEx(hdc, pt.x/2, 0, NULL);
 9         LineTo(hdc, pt.x / 2, pt.y);
10         MoveToEx(hdc, 0, pt.y / 2, NULL);
11         LineTo(hdc, pt.x, pt.y / 2);
12         SelectObject(hdc, oldHPen);
13         SetWindowOrgEx(hdc, -pt.x / 2+50, -pt.y / 2+50, NULL);
14         Rectangle(hdc, 0,0, 100, 100);
View Code

等待更新……

转载于:https://www.cnblogs.com/2016Study/p/5428850.html

内容概要:本文深入解析了扣子COZE AI编程及其详细应用代码案例,旨在帮助读者理解新一代低门槛智能体开发范式。文章从五个维度展开:关键概念、核心技巧、典型应用场景、详细代码案例分析以及未来发展趋势。首先介绍了扣子COZE的核心概念,如Bot、Workflow、Plugin、Memory和Knowledge。接着分享了意图识别、函数调用链、动态Prompt、渐进式发布及监控可观测等核心技巧。然后列举了企业内部智能客服、电商导购助手、教育领域AI助教和金融行业合规质检等应用场景。最后,通过构建“会议纪要智能助手”的详细代码案例,展示了从需求描述、技术方案、Workflow节点拆解到调试与上线的全过程,并展望了多智能体协作、本地私有部署、Agent2Agent协议、边缘计算插件和实时RAG等未来发展方向。; 适合人群:对AI编程感兴趣的开发者,尤其是希望快速落地AI产品的技术人员。; 使用场景及目标:①学习如何使用扣子COZE构建生产级智能体;②掌握智能体实例、自动化流程、扩展能力和知识库的使用方法;③通过实际案例理解如何实现会议纪要智能助手的功能,包括触发器设置、下载节点、LLM节点Prompt设计、Code节点处理和邮件节点配置。; 阅读建议:本文不仅提供了理论知识,还包含了详细的代码案例,建议读者结合实际业务需求进行实践,逐步掌握扣子COZE的各项功能,并关注其未来的发展趋势。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值