小练习(c#):画很多圆
程序员文章站
2022-05-21 09:30:31
...
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 WindowsFormsApplication1_003Cs语言基础
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Random random = new Random();
Color getRandomColor()
{
return Color.FromArgb(
random.Next(256),
random.Next(256),
random.Next(256)
);
}
private void btnHy_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
int x = this.Width / 2;
int y = this.Height / 2;
for (int r = 1; r <= 100; r++)
{
g.DrawEllipse(
new Pen(getRandomColor(),2),
x-r,y-r,2*r,2*r
);
}
g.Dispose();
}
}
}
上一篇: UI组件——SwipeRefreshLayout学习笔记
下一篇: webgl实现画圆