Q:
Use GDI + to draw an image such
Refer: http://bbs.csdn.net/topics/390546290
A:
public void RenderEllipses(Graphics g, float x, float y, float radius, float angle, int layer){ float inflateRadius = -radius / 4; for (int i = 1; i <= layer; i++) { float A = angle / i; int count = (int)Math.Round(360 / A); for (int j = 0; j < count; j++) { float R = radius * i; float rx = (float)Math.Cos(A * Math.PI / 180 * j) * R + x; float ry = (float)Math.Sin(A * Math.PI / 180 * j) * R + y; RectangleF bound = new RectangleF(rx, ry, radius, radius); using (Brush brush = new SolidBrush(Color.LightGray)) g.FillEllipse(brush, bound); using (Pen pen = new Pen(Color.Black, 1)) g.DrawEllipse(pen, bound); bound.Inflate(inflateRadius, inflateRadius); using (Brush brush = new SolidBrush(Color.Orange)) g.FillEllipse(brush, bound); using (Pen pen = new Pen(Color.Black, 1)) g.DrawEllipse(pen, bound); } }}
Parameter information:
G: drawing surface
X, Y: Drawing position
RADIUS: concentric circle radius
Angle: offset angle (based on the innermost concentric circle)
Layer: Number of concentric circles
Test cases:
Renderellipses (E. Graphics, 220,220, 50, 60, 4 );