private float degree = 0;
private Image defaultImg = null;//外面的大圆
//字数限制,删减了一部分不重要的
private void button1_Click(object sender, EventArgs e)
{
Image img = new Bitmap(240, 240);
float ell = 0;
float.TryParse(textBox1.Text, out ell);
ell = ell == 0 ? 60 : ell;
using (Graphics g = Graphics.FromImage(img))
{
g.DrawImage(defaultImg, 0, 0);
GraphicsState gs = g.Save();
degree += ell;
PointF Xy = GetCurrentXY(degree, 110, new PointF(115, 115));
g.DrawEllipse(new Pen(new SolidBrush(Color.Blue), 1), Xy.X, Xy.Y, 1, 1);//小点
g.DrawEllipse(new Pen(new SolidBrush(Color.Blue), 1), Xy.X, Xy.Y, 10, 10);//小圆
g.Restore(gs);
g.Flush();
}
pictureBox1.Image = img;
}
//参数分别为:旋转到的度数、大圆半径,大圆中心点(需要减去小圆半径,因为绘制是从起点而不是中心点)
private PointF GetCurrentXY(float degree, float r, PointF centerXY)
{
PointF pf = new PointF();
double radian = (2 * Math.PI / 360f) * degree;
pf.X = centerXY.X + (float)Math.Sin(radian) * r;
pf.Y = centerXY.Y - (float)Math.Cos(radian) * r;
return pf;
}