0
我的代碼繪製了一個圓,然後是從圓的中心到圓的半徑大小的一條線,並且線正在移動1個角度。如何在移動的線後畫一條線索?
現在我想讓這條線在雷達效應之後留下一些線索/痕跡。
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
anglecounter += 1;
double x = pictureBox1.Size.Width/2 + 256 *Math.Cos(anglecounter * Math.PI/180);
double y = pictureBox1.Size.Height/2 +256 * Math.Sin(anglecounter * Math.PI/180);
CloudEnteringAlert.Paint(e.Graphics, factor, distance);
e.Graphics.DrawLine(
new Pen(Color.Red, 2f),
new Point(pictureBox1.Size.Width/2, pictureBox1.Size.Height/2),
new Point((int)x, (int)y));
e.Graphics.DrawEllipse(
new Pen(Color.Red, 2f),
0, 0, pictureBox1.Size.Width, pictureBox1.Size.Height);
}
我該怎麼做?
編輯**
這就是我現在做的我加了窗體頂部:
PointF _pt = new PointF(0F, 0F);
PointF _pt2 = new PointF(1F, 1F);
PointF _pt3 = new PointF(2F, 2F);
Color _lineColor = Color.FromArgb(0, 255, 0);
private double anglecounter1;
然後Paint事件現在這個樣子:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
anglecounter += 1;
anglecounter1 += 0.5;
double x = pictureBox1.Size.Width/2 + 256 *Math.Cos(anglecounter * Math.PI/180);
double y = pictureBox1.Size.Height/2 +256 * Math.Sin(anglecounter * Math.PI/180);
double x1 = pictureBox1.Size.Width/2 + 256 * Math.Cos(anglecounter1 * Math.PI/180);
double y1 = pictureBox1.Size.Height/2 + 256 * Math.Sin(anglecounter1 * Math.PI/180);
CloudEnteringAlert.Paint(e.Graphics, factor, distance);
e.Graphics.DrawLine(
new Pen(Color.Red, 2f),
new Point(pictureBox1.Size.Width/2, pictureBox1.Size.Height/2),
new Point((int)x, (int)y));
e.Graphics.DrawEllipse(
new Pen(Color.Red, 2f),
0, 0, pictureBox1.Size.Width, pictureBox1.Size.Height);
// create the fade path and gradient
GraphicsPath gp = new GraphicsPath(FillMode.Winding);
gp.AddLine(new PointF((float)(pictureBox1.Size.Width/2), (float)(pictureBox1.Size.Height/2)),new PointF((float)x1,(float)y1));
gp.AddCurve(new PointF[] { _pt2, _pt3, _pt });
gp.AddLine(new PointF((float)x, (float)y), new PointF((float)(pictureBox1.Size.Width/2), (float)(pictureBox1.Size.Height/2)));
PathGradientBrush pgb = new PathGradientBrush(gp);
pgb.CenterPoint = new PointF((float)x1, (float)y1);
pgb.CenterColor = Color.FromArgb(128, _lineColor);
pgb.SurroundColors = new Color[] { Color.Empty };
// draw the fade path
e.Graphics.FillPath(pgb, gp);
}
但如果我在這種情況下沒有錯,那麼線索越慢,那麼線越快。跟蹤/追蹤也在線後面,但也在線前。林不知道,但那就是我看到的。那麼,什麼是錯的?
代替繪製一個半徑的,畫兩條與僅稍微不同的角度。用小一點的角度畫一個比另一個稍微淡一點的。人眼將完成其餘的工作。 – Jon
也許從這裏開始:http://msdn.microsoft.com/en-us/library/7fswd1t7(v=vs.110).aspx –
創建一個餅圖片對象(可能是一個弧+三角形)並填充一個漸變這改變了alpha通道 – clcto