Q:
用GDI+繪製出如的圖形
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); } }}
參數資訊:
g :繪圖表面
x,y :繪製位置
radius:同心圓半徑
angle :位移角度(基於最內層同心圓)
layer :同心圓層數
測試案例:
RenderEllipses(e.Graphics, 220, 220, 50, 60, 4);