{"id":157,"date":"2021-01-17T07:58:12","date_gmt":"2021-01-16T23:58:12","guid":{"rendered":"http:\/\/liyanliang.net\/?p=157"},"modified":"2021-01-17T08:06:46","modified_gmt":"2021-01-17T00:06:46","slug":"%e7%bb%99%e4%b8%8d%e8%a7%84%e5%88%99%e7%9a%84%e5%a4%9a%e8%be%b9%e5%bd%a2%e9%97%ad%e5%90%88%e5%8c%ba%e5%9f%9f%e5%a1%ab%e5%85%85%e9%a2%9c%e8%89%b2","status":"publish","type":"post","link":"http:\/\/liyanliang.net\/index.php\/2021\/01\/17\/%e7%bb%99%e4%b8%8d%e8%a7%84%e5%88%99%e7%9a%84%e5%a4%9a%e8%be%b9%e5%bd%a2%e9%97%ad%e5%90%88%e5%8c%ba%e5%9f%9f%e5%a1%ab%e5%85%85%e9%a2%9c%e8%89%b2\/","title":{"rendered":"\u7ed9\u4e0d\u89c4\u5219\u7684\u591a\u8fb9\u5f62\u95ed\u5408\u533a\u57df\u586b\u5145\u989c\u8272"},"content":{"rendered":"\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#i\"><span class=\"toc_number toc_depth_1\">1<\/span> \u95ee\u9898\u63cf\u8ff0\uff1a<\/a><\/li><li><a href=\"#i-2\"><span class=\"toc_number toc_depth_1\">2<\/span> \u5b9e\u73b0\u7684\u5b8c\u6574\u4ee3\u7801\uff1a<\/a><\/li><\/ul><\/div>\n<h1 class=\"wp-block-heading\"><span id=\"i\">\u95ee\u9898\u63cf\u8ff0\uff1a<\/span><\/h1>\n\n\n\n<p>\u73b0\u6709\u591a\u4e2a\u7531\u7ebf\u6bb5line\u6c47\u6210\u7684\u95ed\u5408\u533a\u57df\uff0c\u5c06\u6bcf\u4e2a\u533a\u57df\u4f7f\u7528\u4e0d\u540c\u7684\u989c\u8272\u586b\u5145\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span id=\"i-2\"><strong>\u5b9e\u73b0\u7684\u5b8c\u6574\u4ee3\u7801\uff1a<\/strong><\/span><\/h1>\n\n\n\n<pre class=\"wp-block-preformatted\"><code data-enlighter-language=\"cpp\" class=\"EnlighterJSRAW\">\/\/\u7ed8\u5236\u56fe\u5f62\n \u00a0 \u00a0\/\/ find the client area\n \u00a0 \u00a0CRect rect;\n \u00a0 \u00a0GetClientRect(rect);\n \u00a0 \u00a0\/\/ draw with a thick blue pen\n \u00a0 \u00a0CPen penBlue(PS_SOLID, 2, RGB(0, 0, 255));\n \u00a0 \u00a0CPen* pOldPen = pDC->SelectObject(&amp;penBlue);\n \u00a0 \u00a0int colorIndexR;\n \u00a0 \u00a0int colorIndexG;\n \u00a0 \u00a0int colorIndexB;\n \u00a0 \u00a0CBrush *pOldBrush;\n \u00a0 \u00a0for (unsigned int i = 0;i &lt; m_minClosedArea.size(); i++) \u00a0\/\/m_minClosedArea\u96c6\u5408\u4e3a\u591a\u4e2a\u6709\u7ebf\u6bb5\u56f4\u6210\u7684\u95ed\u5408\u533a\u57df\n \u00a0  {\n \u00a0 \u00a0 \u00a0 \u00a0vector&lt;CLine> m_oneClosedArea= m_minClosedArea[i];\/\/\u95ed\u5408\u533a\u57dfA\n \u00a0 \u00a0 \u00a0 \u00a0int nSize = (int)m_oneClosedArea.size(); \/\/\u95ed\u5408\u533a\u57df\u7684\u7ebf\u6bb5\u6570\u91cf(\u70b9\u6570\u91cf)\n \u00a0 \u00a0 \u00a0 \u00a0CPolyline m_polyline;\n \u00a0 \u00a0 \u00a0 \u00a0CPoint pts[100];\n \u00a0 \u00a0\n \u00a0 \u00a0 \u00a0 \u00a0\/\/\u5c06\u95ed\u5408\u533a\u57dfA\u4e2d\u7684\u70b9\u5b58\u653e\u5728pts\u4e2d\n \u00a0 \u00a0 \u00a0 \u00a0for (unsigned int j=0; j&lt;m_oneClosedArea.size(); j++) \n \u00a0 \u00a0 \u00a0  { \u00a0 \u00a0 \u00a0 \u00a0\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Point m_ptStart = m_oneClosedArea[j].getStartPoint(); \u00a0 \u00a0 \u00a0 \u00a0\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0int x1 = (int)m_ptStart.x;\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0int y1 = (int)m_ptStart.y;\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0pts[j].SetPoint(x1,-y1);\n \u00a0 \u00a0 \u00a0  }\n \n \u00a0 \u00a0 \u00a0 \u00a0colorIndexR = (i*50 - 50)%256; \/\/\u989c\u8272\u7d22\u5f15\n \u00a0 \u00a0 \u00a0 \u00a0colorIndexG = (i*100 + 100)%256; \/\/\u989c\u8272\u7d22\u5f15\n \u00a0 \u00a0 \u00a0 \u00a0colorIndexB = (i*200 - 200)%256; \/\/\u989c\u8272\u7d22\u5f15\n \n \u00a0 \u00a0 \u00a0 \u00a0CBrush brushColor(RGB(colorIndexR,colorIndexG, colorIndexB)); \/\/\u5b9a\u4e49\u753b\u5237\u7684\u989c\u8272\n \u00a0 \u00a0 \u00a0 \u00a0pOldBrush = pDC->SelectObject(&amp;brushColor); \/\/\u5c06\u753b\u5237\u989c\u8272\u8d4b\u4e88*pDC\n \u00a0 \u00a0 \u00a0 \u00a0pDC->Polygon(pts, nSize); \u00a0\/\/\u7ed8\u5236\u591a\u8fb9\u5f62\n \n \u00a0 \u00a0 \u00a0 \u00a0pDC->SelectObject(&amp;pOldPen); \u00a0 \u00a0\n \u00a0 \u00a0 \u00a0 \u00a0pDC->SelectObject(pOldBrush);\n \u00a0  }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 \u95ee\u9898\u63cf\u8ff0\uff1a2 \u5b9e\u73b0\u7684\u5b8c\u6574\u4ee3\u7801\uff1a \u95ee\u9898\u63cf\u8ff0\uff1a \u73b0\u6709\u591a\u4e2a\u7531\u7ebf\u6bb5line\u6c47\u6210\u7684\u95ed\u5408\u533a\u57df\uff0c\u5c06\u6bcf\u4e2a\u533a\u57df\u4f7f\u7528\u4e0d\u540c\u7684\u989c\u8272\u586b\u5145\u3002 \u5b9e\u73b0\u7684\u5b8c\u6574\u4ee3\u7801\uff1a \/\/\u7ed8\u5236\u56fe\u5f62 \u00a0 \u00a0\/\/ find the client area \u00a0 \u00a0CRect rect; \u00a0 \u00a0GetClientRect(rect); \u00a0 \u00a0\/\/ draw with a thick blue pen \u00a0 \u00a0CPen penBlue(PS_SOLID, 2, RGB(0, 0, 255)); \u00a0 \u00a0CPen* pOldPen = pDC->SelectObject(&amp;penBlue); \u00a0 \u00a0int colorIndexR; \u00a0 \u00a0int colorIndexG; \u00a0 \u00a0int colorIndexB; \u00a0 \u00a0CBrush *pOldBrush; \u00a0 \u00a0for (unsigned int i = 0;i &lt; m_minClosedArea.size(); i++) \u00a0\/\/m_minClosedArea\u96c6\u5408\u4e3a\u591a\u4e2a\u6709\u7ebf\u6bb5\u56f4\u6210\u7684\u95ed\u5408\u533a\u57df \u00a0 { \u00a0 \u00a0 \u00a0 \u00a0vector&lt;CLine> m_oneClosedAr&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/liyanliang.net\/index.php\/2021\/01\/17\/%e7%bb%99%e4%b8%8d%e8%a7%84%e5%88%99%e7%9a%84%e5%a4%9a%e8%be%b9%e5%bd%a2%e9%97%ad%e5%90%88%e5%8c%ba%e5%9f%9f%e5%a1%ab%e5%85%85%e9%a2%9c%e8%89%b2\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-157","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":1,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":158,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions\/158"}],"wp:attachment":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}