使用以下代码绘制椭圆:
graphGraphics = e.Graphics;
graphGraphics.FillEllipse(new SolidBrush(Color.White), this.graphBoundries);
graphGraphics.DrawEllipse(graphPen, this.graphBoundries);
我在这张图上有一条线,它现在正好通过它。我想改变线条高度以适应椭圆的边界,如下所示它不会通过椭圆:
http://i1379.photobucket.com/albums/ah134/fac7orx2/circlewithlinehelp_zps280d9e76.png
有没有人知道这样做的算法?或者甚至可能只是如何获得椭圆的边界而不仅仅是矩形边界?
答案 0 :(得分:2)
要扩展我的评论,请尝试使用此类(未经测试的)代码:
graphGraphics = e.Graphics;
graphGraphics.FillEllipse(new SolidBrush(Color.White), this.graphBoundries);
graphGraphics.DrawEllipse(graphPen, this.graphBoundries);
GraphicsPath clipPath = new GraphicsPath();
clipPath.AddEllipse(this.graphBoundaries);
graphGraphics.SetClip(clipPath, CombineMode.Replace);
// draw your line