資源簡介
貝澤爾曲線 C# 2008實現(xiàn)。實現(xiàn)方法是利用貝澤爾曲線的數(shù)學(xué)定義。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?ChapterFour
{
????public?partial?class?ChapterFour?:?Form
????{
????????private?int?pointNum;
????????private?List?points;
????????private?Point?[]pointp;
????????public?ChapterFour()
????????{
????????????pointNum?=?0;
????????????points?=?new?List();
????????????InitializeComponent();
????????????this.polygonButton.Enabled?=?false;
????????????this.drawButton.Enabled?=?false;
????????????this.cleanButton.Enabled?=?false;
????????}
????????public?void?Bezier(List?p?int?n)?//生成Bezier曲線
????????{
????????????Point?CurrentP;
????????????int?x?y?i?j?k?=?512;
????????????double?t?t1?u?v;
????????????double?temp?temp1?temp2?bi;
????????????Graphics?myGraphics?=?this.drawingLabel.CreateGraphics();
????????????Pen?myPen?=?new?Pen(Color.Blue?1);
????????????CurrentP?=?p.ElementAt(0);
????????????t?=?1.0?/?k;
????????????for?(j?=?1;?j?????????????{
????????????????t1?=?j?*?t;
????????????????u?=?t1;
????????????????v?=?1?-?u;
????????????????x?=?0;
????????????????y?=?0;
????????????????for?(i?=?0;?i?<=?n;?i++)
????????????????{
????????????????????temp?=?(double)fac(n)?/?fac(i)?/?fac(n?-?i);
????????????????????temp1?=?powi(u?i);
????????????????????temp2?=?powi(v?n?-?i);
????????????????????bi?=?temp?*?temp1?*?temp2;
????????????????????x?=?(int)((double)x?+?bi?*?(double)p.ElementAt(i).X);
????????????????????y?=?(int)((double)y?+?bi?*?(double)p.ElementAt(i).Y);
????????????????}
????????????????myGraphics.DrawLine(myPen?CurrentP.X?CurrentP.Y?x?y);
????????????????CurrentP?=?new?Point(x?y);
????????????}
????????????myGraphics.DrawLine(myPen?CurrentP.X?CurrentP.Y?p.ElementAt(n).X?p.ElementAt(n).Y);
????????}
????????private?void?drawingLabel_Click(object?sender?EventArgs?e)
????????{
????????????Point?CurrentPoint;
????????????Graphics?myGraphics?=?this.drawingLabel.CreateGraphics();
????????????Pen?myPen?=?new?Pen(Color.Red?1);
????????????this.polygonButton.Enabled?=?true;
????????????if(pointNum?==?0)
????????????????myGraphics.DrawString(“當(dāng)前狀態(tài):確定特征多邊形頂點,按“生成特征多邊形”鍵,生成特征多邊形“?new?Font(“黑體“?10?Fontstyle.Bold)?new?SolidBrush(Color.Black)?0?20);
????????????CurrentPoint?=?PointToClient(Control.MousePosition);
????????????points.Add(CurrentPoint);
????????????pointNum?+=?1;
????????????myGraphics.DrawLine(myPen?CurrentPoint.X?-?2?CurrentPoint.Y?-?2?CurrentPoint.X?+?2?CurrentPoint.Y?+?2);
????????????myGraphics.DrawLine(myPen?CurrentPoint.X?-?2?CurrentPoint.Y?+?2?CurrentPoint.X?+?2?CurrentPoint.Y?-?2);
????????????
????????}
????????private?void?polygonButton_Click(object?sender?EventArgs?e)
????????{
????????????String?strPointNum?strBezierFac;
????????????Graphics?myGraphics?=?this.drawingLabel.CreateGra
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-10-19?19:05??ChapterFour\
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\
?????文件?????????927??2011-10-15?11:31??ChapterFour\ChapterFour.sln
?????文件???????15360??2011-10-19?19:06??ChapterFour\ChapterFour.suo
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\bin\
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\bin\Debug\
?????文件???????13312??2011-10-15?14:19??ChapterFour\ChapterFour\bin\Debug\ChapterFour.exe
?????文件???????28160??2011-10-15?14:19??ChapterFour\ChapterFour\bin\Debug\ChapterFour.pdb
?????文件???????14328??2011-10-19?19:06??ChapterFour\ChapterFour\bin\Debug\ChapterFour.vshost.exe
?????文件?????????490??2007-07-21?02:33??ChapterFour\ChapterFour\bin\Debug\ChapterFour.vshost.exe.manifest
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\bin\Release\
?????文件????????6226??2011-10-15?14:19??ChapterFour\ChapterFour\ChapterFour.cs
?????文件????????3763??2011-10-15?11:36??ChapterFour\ChapterFour\ChapterFour.csproj
?????文件??????????74??2011-10-15?11:31??ChapterFour\ChapterFour\ChapterFour.csproj.user
?????文件????????7550??2011-10-15?13:56??ChapterFour\ChapterFour\ChapterFour.Designer.cs
?????文件????????5814??2011-10-15?13:56??ChapterFour\ChapterFour\ChapterFour.resx
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\obj\
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\obj\Debug\
?????文件?????????180??2011-10-15?13:56??ChapterFour\ChapterFour\obj\Debug\ChapterFour.ChapterFour.resources
?????文件?????????670??2011-10-19?19:06??ChapterFour\ChapterFour\obj\Debug\ChapterFour.csproj.FileListAbsolute.txt
?????文件?????????853??2011-10-15?13:56??ChapterFour\ChapterFour\obj\Debug\ChapterFour.csproj.GenerateResource.Cache
?????文件???????13312??2011-10-15?14:19??ChapterFour\ChapterFour\obj\Debug\ChapterFour.exe
?????文件???????28160??2011-10-15?14:19??ChapterFour\ChapterFour\obj\Debug\ChapterFour.pdb
?????文件?????????180??2011-10-15?11:36??ChapterFour\ChapterFour\obj\Debug\ChapterFour.Properties.Resources.resources
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\obj\Debug\Refactor\
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\obj\Debug\TempPE\
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\obj\Release\
?????文件?????????498??2011-10-15?11:31??ChapterFour\ChapterFour\Program.cs
?????目錄???????????0??2011-10-19?19:05??ChapterFour\ChapterFour\Properties\
?????文件????????1378??2011-10-15?11:30??ChapterFour\ChapterFour\Properties\AssemblyInfo.cs
?????文件????????2873??2011-10-15?11:30??ChapterFour\ChapterFour\Properties\Resources.Designer.cs
............此處省略3個文件信息
- 上一篇:C#任務(wù)隊列的實現(xiàn)
- 下一篇:C#開發(fā)之洪水淹沒
評論
共有 條評論