110,532
社区成员
发帖
与我相关
我的任务
分享
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen pen = new Pen(Brushes.Blue);
//初始半径
float r0 = 20;
//圆心
float x0 = 140;
float y0 = 140;
//圆的宽度和高度
float width = 0;
float height = 0;
float x = 100;
float y = 100;
//圆半径的递增数量
float d = 2 * r0;
//画圆
for (int i = 0; i < 3; i++)
{
//计算当前圆的宽度和高度
width = (r0 + d * i) * 2;
height = (r0 + d * i) * 2;
//计算当前圆的左上角顶点坐标
x = x0 - width / 2;
y = y0 - height / 2;
//画圆
g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawEllipse(pen, x, y, width, height);
}
//画刻度条
pen.Color = Color.Black;//黑笔画线
g.DrawLine(pen, x0 - 5 * r0 - 2 * r0 / 5, y0, x0 - 3 * r0 / 5, y0);//线条
//画刻度
for (int j = 0; j < 8; j++)
{
for (int i = 0; i < 13; i++)
{
if (i % 6 == 0)
{
g.DrawLine(pen, x0 - 5 * r0 - 2 * r0 / 5 + 2 * r0 * i / 5, (float)(y0 - 1.5 * r0 / 5), x0 - 5 * r0 - 2 * r0 / 5 + 2 * r0 * i / 5, (float)(y0 + 1.5 * r0 / 5));
}
else
{
g.DrawLine(pen, x0 - 5 * r0 - 2 * r0 / 5 + 2 * r0 * i / 5, y0 - r0 / 5, x0 - 5 * r0 - 2 * r0 / 5 + 2 * r0 * i / 5, y0 + r0 / 5);
}
}
}
}