-
大小: 59KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-06-15
- 語言: C#
- 標(biāo)簽:
資源簡介
最近遇到一個(gè)需要畫一個(gè)傾斜的橢圓的問題,一般常見的解決辦法都是旋轉(zhuǎn)坐標(biāo)系,這個(gè)方法是當(dāng)時(shí)沒有學(xué)過旋轉(zhuǎn)坐標(biāo)系時(shí)想出的解決辦法,既然橢圓能旋轉(zhuǎn)其他圖形也不在話下,可以上傳提供借鑒一下,希望能有所幫助。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Drawing.Drawing2D;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?Ellipse
{
????public?partial?class?Form1?:?Form
????{
????????PointF?xyPoint?=?new?PointF();
????????PointF?centerPoint?=?new?PointF();
????????PointF?movePoint?=?new?PointF();
????????PointF?xiePointF=new?PointF();
????????PointF?xiedPointF?=?new?PointF();
????????private?double?perAngle?=?0;
????????private?double?nowAngle;
????????private?double?moveAngle;
????????PointF[]?pointFs=new?PointF[201];
????????PointF[]?pointFs1=new?PointF[201];
????????PointF[]?xiePointFs=new?PointF[201];
????????PointF[]?xiePointFs1?=?new?PointF[201];
????????private?float?a?=200;
????????private?float?b?=100;
????????private?float?stepLength?=?2;
????????private?float?xLength?=?0;
????????private?float?yLength?=?0;
????????private?float?dbYlength?=?0;
????????private?float?xiedLength?=?0;
????????private?int?angle?=?0;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?panel1_Paint(object?sender?PaintEventArgs?e)
????????{
????????????
????????}
????????private?void?panel1_MouseClick(object?sender?MouseEventArgs?e)
????????{
????????????if?(e.Button?!=?MouseButtons.Left)
????????????{
????????????????return;
????????????}
????????????if?(this.textBox1.Text?==?““)
????????????{
????????????????this.errorProvider1.SetError(this.textBox1?“請(qǐng)輸入傾斜的角度“);
????????????????return;
????????????}
????????????else
????????????{
????????????????this.errorProvider1.SetError(this.textBox1?““);
????????????}
????????????xyPoint.X?=?this.panel1.Width/2-200;
????????????xyPoint.Y?=?this.panel1.Height/2-100;
????????????centerPoint.X?=?xyPoint.X?+?a;
????????????centerPoint.Y?=?xyPoint.Y?+?b;
????????????Graphics?graphics?=?this.panel1.CreateGraphics();
????????????graphics.SmoothingMode?=?SmoothingMode.HighQuality;
????????????graphics.Clear(this.panel1.BackColor);
????????????Pen?pen?=?new?Pen(Color.Red);
????????????for?(int?index?=?0;?index?????????????{
????????????????movePoint.X?=?index?*?stepLength?+?xyPoint.X;
????????????????xLength?=?centerPoint.X?-?movePoint.X;
????????????????yLength?=?(float)(Math.Sqrt((1?-?(xLength?*?xLength)?/?40000)?*?10000));
????????????????movePoint.Y?=?b?-?yLength?+?xyPoint.Y;
????????????????pointFs[index]?=?movePoint;
????????????}
????????????graphics.DrawCurve(pen?pointFs?1.5f);
????????????for?(int?index?=?0;?index?????????????{
????????????????dbYlength?=?centerPoint.Y?-?pointFs[index].Y;
????????????????pointFs1[index].Y?=?centerPoint.Y?+?dbYlength;
????????????????pointFs1[index].X?=?pointFs[index].X;
????????????}
????????????graphics.DrawCurve(pen?pointFs1?1.5f);
????????????for?(int?index?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-07-14?16:02??Ellipse\
?????文件?????????990??2015-07-13?12:40??Ellipse.sln
?????文件???????34816??2015-08-01?23:23??Ellipse.v12.suo
?????文件?????????187??2015-07-13?12:40??Ellipse\App.config
?????目錄???????????0??2015-07-13?12:40??Ellipse\bin\
?????目錄???????????0??2015-07-13?13:04??Ellipse\bin\Debug\
?????文件???????16896??2015-08-01?23:23??Ellipse\bin\Debug\Ellipse.exe
?????文件?????????187??2015-07-13?12:40??Ellipse\bin\Debug\Ellipse.exe.config
?????文件???????30208??2015-08-01?23:23??Ellipse\bin\Debug\Ellipse.pdb
?????文件???????24224??2015-08-01?23:23??Ellipse\bin\Debug\Ellipse.vshost.exe
?????文件?????????187??2015-07-13?12:40??Ellipse\bin\Debug\Ellipse.vshost.exe.config
?????文件?????????490??2013-06-18?20:28??Ellipse\bin\Debug\Ellipse.vshost.exe.manifest
?????文件????????3794??2015-07-13?13:04??Ellipse\Ellipse.csproj
?????文件???????14790??2015-07-14?16:02??Ellipse\Form1.cs
?????文件????????5394??2015-07-14?15:55??Ellipse\Form1.Designer.cs
?????文件????????6019??2015-07-14?15:55??Ellipse\Form1.resx
?????目錄???????????0??2015-07-13?12:40??Ellipse\obj\
?????目錄???????????0??2015-08-01?23:23??Ellipse\obj\Debug\
?????文件????????1453??2015-07-13?20:50??Ellipse\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????6911??2015-07-13?12:40??Ellipse\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????555??2015-08-01?23:23??Ellipse\obj\Debug\Ellipse.csproj.FileListAbsolute.txt
?????文件?????????977??2015-07-14?15:55??Ellipse\obj\Debug\Ellipse.csproj.GenerateResource.Cache
?????文件????????2211??2015-07-13?13:04??Ellipse\obj\Debug\Ellipse.csprojResolveAssemblyReference.cache
?????文件???????16896??2015-08-01?23:23??Ellipse\obj\Debug\Ellipse.exe
?????文件?????????180??2015-07-14?15:55??Ellipse\obj\Debug\Ellipse.Form1.resources
?????文件???????30208??2015-08-01?23:23??Ellipse\obj\Debug\Ellipse.pdb
?????文件?????????180??2015-07-13?13:04??Ellipse\obj\Debug\Ellipse.Properties.Resources.resources
?????文件???????????0??2015-07-13?12:40??Ellipse\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件???????????0??2015-07-13?12:40??Ellipse\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件???????????0??2015-07-13?12:40??Ellipse\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????目錄???????????0??2015-07-13?12:40??Ellipse\obj\Debug\TempPE\
............此處省略7個(gè)文件信息
評(píng)論
共有 條評(píng)論