?? 基于visual c++的gdi常用坐標(biāo)系統(tǒng)及應(yīng)用 (2).htm
字號(hào):
<DIV>}</DIV></TD></TR></TBODY></TABLE></DIV>
<P> <B><BR></B>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><B> <IMG alt=基于VisualC++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用(2)
src="基于Visual C++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用 (2).files/1011530693.gif"
border=1><BR> 圖五、代碼效果圖</B> </DIV></TD></TR></TBODY></TABLE></P>
<DIV><BR> 需要注意的是,你也可以相對(duì)于客戶區(qū)域來(lái)指定坐標(biāo)原點(diǎn)<BR> <BR>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>
<DIV>void CExoDraw1View::OnPaint() </DIV>
<DIV>{</DIV>
<DIV> CPaintDC dc(this); //繪圖的設(shè)備上下文;</DIV>
<DIV> CRect Recto;</DIV>
<DIV> //獲取客戶區(qū)尺寸;</DIV>
<DIV> GetClientRect(&Recto);</DIV>
<DIV> dc.SetViewportOrg(Recto.Width() / 2, Recto.Height() / 2);</DIV>
<DIV> // A circle whose center is at the origin (0, 0)</DIV>
<DIV> dc.Ellipse(-50, -50, 50, 50);</DIV>
<DIV> // A line that starts at (0, 0) and ends at (100, 100)</DIV>
<DIV> dc.MoveTo(0, 0);</DIV>
<DIV> dc.LineTo(100, 100);</DIV>
<DIV>}</DIV></TD></TR></TBODY></TABLE><BR></DIV>
<P>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG alt=基于VisualC++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用(2)
src="基于Visual C++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用 (2).files/2468559300.gif"
border=1><BR> <B>圖六、代碼效果圖</B> </DIV></TD></TR></TBODY></TABLE></P>
<DIV><BR> 現(xiàn)在你已了解了如何設(shè)置坐標(biāo)原點(diǎn),讓我們來(lái)將(380,220)點(diǎn)作為坐標(biāo)原點(diǎn),并繪制出笛卡爾的坐標(biāo)軸:<BR> <BR>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>
<DIV>void CExoDraw1View::OnPaint() </DIV>
<DIV>{</DIV>
<DIV> CPaintDC dc(this); // device context for painting</DIV>
<DIV> CRect Recto;</DIV>
<DIV> dc.SetViewportOrg(380, 220);</DIV>
<DIV> // Use a red pen</DIV>
<DIV> CPen PenRed(PS_SOLID, 1, RGB(255, 0, 0));</DIV>
<DIV> dc.SelectObject(PenRed);</DIV>
<DIV> // A circle whose center is at the origin (0, 0)</DIV>
<DIV> dc.Ellipse(-100, -100, 100, 100);</DIV>
<DIV> // Use a blue pen</DIV>
<DIV> CPen PenBlue(PS_SOLID, 1, RGB(0, 0, 255));</DIV>
<DIV> dc.SelectObject(PenBlue);</DIV>
<DIV> // Horizontal axis</DIV>
<DIV> dc.MoveTo(-380, 0);</DIV>
<DIV> dc.LineTo(380, 0);</DIV>
<DIV> // Vertical axis</DIV>
<DIV> dc.MoveTo(0, -220);</DIV>
<DIV> dc.LineTo(0, 220);</DIV>
<DIV>}</DIV></TD></TR></TBODY></TABLE><BR></DIV>
<P>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG alt=基于VisualC++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用(2)
src="基于Visual C++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用 (2).files/490570559.gif"
border=1><BR> <B>圖七、代碼效果圖</B> </DIV></TD></TR></TBODY></TABLE></P>
<DIV><BR> 正如已經(jīng)看到的,SetViewportOrg()函數(shù)可以更改設(shè)備上下文的坐標(biāo)原點(diǎn),同時(shí),它也用來(lái)規(guī)定坐標(biāo)軸的正方向,即水平軸向右,垂直軸向下:<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center>
<DIV><IMG alt=基于VisualC++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用(2)
src="基于Visual C++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用 (2).files/3687739776.gif"
border=1><BR></DIV> <B>圖八、坐標(biāo)軸示意圖</B> </DIV></TD></TR></TBODY></TABLE></DIV>
<DIV><BR> 為了說(shuō)明這一點(diǎn),下面來(lái)繪制一條黃色的45度角的直線:</DIV>
<P> </P>
<DIV>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>
<DIV>void CExoDraw1View::OnPaint() </DIV>
<DIV>{</DIV>
<DIV> CPaintDC dc(this); // device context for painting</DIV>
<DIV> dc.SetViewportOrg(380, 220);</DIV>
<DIV> // Use a red pen</DIV>
<DIV> CPen PenRed(PS_SOLID, 1, RGB(255, 0, 0));</DIV>
<DIV> dc.SelectObject(PenRed);</DIV>
<DIV> // A circle whose center is at the origin (0, 0)</DIV>
<DIV> dc.Ellipse(-100, -100, 100, 100);</DIV>
<DIV> // Use a blue pen</DIV>
<DIV> CPen PenBlue(PS_SOLID, 1, RGB(0, 0, 255));</DIV>
<DIV> dc.SelectObject(PenBlue);</DIV>
<DIV> // Horizontal axis</DIV>
<DIV> dc.MoveTo(-380, 0);</DIV>
<DIV> dc.LineTo(380, 0);</DIV>
<DIV> // Vertical axis</DIV>
<DIV> dc.MoveTo(0, -220);</DIV>
<DIV> dc.LineTo(0, 220);</DIV>
<DIV> // An orange pen</DIV>
<DIV> CPen PenOrange(PS_SOLID, 1, RGB(255, 128, 0));</DIV>
<DIV> dc.SelectObject(PenOrange);</DIV>
<DIV> // A diagonal line at 45 degrees</DIV>
<DIV> dc.MoveTo(0, 0);</DIV>
<DIV> dc.LineTo(120, 120);</DIV>
<DIV>}</DIV></TD></TR></TBODY></TABLE><BR></DIV>
<P>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG alt=基于VisualC++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用(2)
src="基于Visual C++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用 (2).files/3133031468.gif"
border=1><BR> <B>圖九、代碼效果圖</B> </DIV></TD></TR></TBODY></TABLE></P>
<DIV><BR> 正如你所看到的,我們的直線沒(méi)有在45度位置,而是位于坐標(biāo)系統(tǒng)的第四象限,造成這種情況的原因是默認(rèn)的坐標(biāo)系統(tǒng)。</DIV>
<DIV></DIV>
<DIV><SPAN id=_function_code_page>
<P align=right><A style="FONT-SIZE: 14px"
href="http://tech.sina.com.cn/s/2005-06-20/1143640450.shtml">[上一頁(yè)]</A> <A
href="http://tech.sina.com.cn/s/2005-06-20/1143640450.shtml">[1]</A> [2] <A
href="http://tech.sina.com.cn/s/2005-06-20/1143640457.shtml">[3]</A> <A
href="http://tech.sina.com.cn/s/2005-06-20/1143640458.shtml">[4]</A> <A
href="http://tech.sina.com.cn/s/2005-06-20/1143640459.shtml">[5]</A> <A
style="FONT-SIZE: 14px"
href="http://tech.sina.com.cn/s/2005-06-20/1143640457.shtml">[下一頁(yè)]</A></P></SPAN>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR></TR></TBODY></TABLE><BR clear=all>
<TABLE cellSpacing=0 cellPadding=0 width=565 border=0>
<TBODY>
<TR>
<TD class=f14 vAlign=top height=30> 點(diǎn)擊此處查詢<A
href="http://chanews.sina.com.cn/s.cgi?k=keyword&c=2&k=Visual"
target=_blank C>全部<FONT color=red>Visual C</FONT>新聞</A>
</TD></TR></TBODY></TABLE></DIV></FONT></TD></TR></TBODY></TABLE></DIV><BR>
<TABLE cellSpacing=0 cellPadding=0 width=580 border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=580 border=0>
<TBODY>
<TR>
<TD>
<FORM name=from_
action=http://mms.sina.com.cn/xmlmms/xmlmmsQue.php method=post
target=_blank><INPUT type=hidden
value=http://rss.sina.com.cn/mms/tech/14/96/68/2-1-640456.xml
name=xmlCfg> <INPUT type=hidden value=100001 name=sourceFrom>
<INPUT type=hidden value=442 name=from> </TD></FORM>
<TD align=right>【<A
href="http://comment.news.sina.com.cn/cgi-bin/comment/comment.cgi?channel=kj&newsid=640450">評(píng)論</A>】【<A
href="http://forum.tech.sina.com.cn/cgi-bin/tree.cgi?gid=23&fid=288">應(yīng)用軟件論壇</A>】【<A
title=收藏的網(wǎng)頁(yè)將被永久的保存到ViVi收藏夾http://vivi.sina.com.cn
href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=tech.sina.com.cn&title='+escape(d.title)+'&url='+escape(d.location.href)+'&desc='+escape(t),'vivi','scrollbars=no,width=460,height=450,left=75,top=20,status=no,resizable=yes'));vivi.focus();">收藏此頁(yè)</A>】【<A
href="javascript:doZoom(16)">大</A> <A
href="javascript:doZoom(14)">中</A> <A
href="javascript:doZoom(12)">小</A>】【<A
href="javascript:from_.submit()">多種方式看新聞</A>】【<A
href="http://www.sina.com.cn/ddt/" target=_blank>下載點(diǎn)點(diǎn)通</A>】【<A
href="javascript:doPrint()">打印</A>】【<A
href="javascript:window.close()">關(guān)閉</A>】</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=565 border=0>
<TBODY>
<TR>
<TD height=19></TD></TR>
<TR>
<TD bgColor=#c6c9d1 height=1></TD></TR>
<TR>
<TD height=10></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=560 border=0>
<TBODY>
<TR>
<TD><!-- 正文底部小通欄 -->
<TABLE cellSpacing=0 cellPadding=0 width=585 align=center
border=0><TBODY>
<TR>
<TD><!--科技頻道內(nèi)頁(yè)底部小通欄開(kāi)始--><!--96086D89A9D3-->
<OBJECT
codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0
height=50 width=585
classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="movie" VALUE="http://ad4.sina.com.cn/200505/31/19724.swf"><PARAM NAME="quality" VALUE="high"><PARAM NAME="wmode" VALUE="opaque">
<EMBED src="http://ad4.sina.com.cn/200505/31/19724.swf"
quality=high WIDTH="585" HEIGHT="50"
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT><!--$$ weixing/2005-6-20 ~ 2005-6-22/B $--><!--科技頻道內(nèi)頁(yè)底部小通欄結(jié)束--></TD></TR>
<TR>
<TD
height=5></TD></TR></TBODY></TABLE><!--Adforward Begin:測(cè)試勿刪--><IFRAME
marginWidth=0 marginHeight=0
src="基于Visual C++的GDI常用坐標(biāo)系統(tǒng)及應(yīng)用 (2).files/adfshow.htm" frameBorder=0
width=1 scrolling=no
height=1>
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://153.adsina.allyes.com/main/adfshow?user=AFP6_for_SINA|Tech|TechPIP&db=sina&local=yes&js=on"></SCRIPT>
<NOSCRIPT><A HREF="http://153.adsina.allyes.com/main/adfclick?user=AFP6_for_SINA|Tech|TechPIP&db=sina"><IMG SRC="http://153.adsina.allyes.com/main/adfshow?user=AFP6_for_SINA|Tech|TechPIP&db=sina" WIDTH=1 HEIGHT=1 BORDER=0></a></NOSCRIPT></IFRAME><!--Adforward End--></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=0 width=560 border=0>
<TBODY>
<TR>
<TD>
<DIV id=PublicRelation1 style="DISPLAY: none" name="PublicRelation">
<TABLE>
<TBODY>
<TR>
<TD> </TD>
<TD class=f14>
<P><!--要求文字在17字以內(nèi)!--><!--科技新聞內(nèi)頁(yè)文字鏈01開(kāi)始--><!--721C1770C53A--><A
href="http://ad.cn.doubleclick.net/clk;17068092;11418269;i?http://www-900.ibm.com/cn/servers/eserver/bladecenter/index.shtml"
target=_blank><FONT color=red>IBM刀片買六贈(zèng)一,現(xiàn)在開(kāi)刃</FONT></A><!--$$ weixing/2005-6-16 ~ 2005-6-16/B $-->
<!--科技新聞內(nèi)頁(yè)文字鏈01結(jié)束--> <!--科技新聞內(nèi)頁(yè)文字鏈02開(kāi)始--><!--32E1711D03D4--><A
href="http://noshow.adsina.allyes.com/main/adfclick?db=sina&bid=12405,33258,33298&cid=0,0,0&sid=33031&advid=1924&camid=6377&show=ignore&url=http://www.aigo.com/huodong/securitymoon/"
target=_blank><FONT color=red>愛(ài)國(guó)者關(guān)注您數(shù)據(jù)安全!</FONT></A><!--$$ weixing/2005-6-20 ~ 2005-6-21/B $-->
<!--科技新聞內(nèi)頁(yè)文字鏈02結(jié)束--></P></TD></TR></TBODY></TABLE></DIV>
<SCRIPT>
//<!--廣告發(fā)布-->
<!--
if (checkPubTime(getPubTime()))
{
PublicRelation1.style.display="";
}
-->
</SCRIPT>
<DIV id=links>
<TABLE cellSpacing=0 cellPadding=0 width=562 border=0>
<TBODY>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -