C# 線性漸變圓
阿新 • • 發佈:2021-01-21
。
Thread t = new Thread(() => { for (int i = 0; i < 360; i++) { Thread.Sleep(100); double dblsin = Math.Sin(Math.PI * (i + 1) / 180); double dblcos = Math.Cos(Math.PI * (i + 1) / 180);int y = 100 + Convert.ToInt32(Math.Floor(50 * dblsin)); int x = 100 + Convert.ToInt32(Math.Floor(50 * dblcos)); Point p1 = new Point(x, y); double dblsin2 = Math.Sin(Math.PI * (180 + (i + 1)) / 180); double dblcos2 = Math.Cos(Math.PI * (180+ (i + 1)) / 180); int y2 = 100 + Convert.ToInt32(Math.Floor(50 * dblsin2)); int x2 = 100 + Convert.ToInt32(Math.Floor(50 * dblcos2)); Point p2 = new Point(x2, y2); using (Brush aGradientBrush = new LinearGradientBrush(p1, p2, Color.Blue, Color.White)) {using (Pen aGradientPen = new Pen(aGradientBrush, 1)) { g.DrawLine(aGradientPen, p1, p2); } } } }); t.Start();
。