C# 调整行高为椭圆
C# make line height adjust to ellipse
有一个椭圆是用下面的代码画的:
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
有人知道执行此操作的算法吗?或者甚至可能如何只获得椭圆的边界而不仅仅是矩形边界?
要扩展我的评论,请尝试这样的(未经测试的)代码:
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
有一个椭圆是用下面的代码画的:
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
有人知道执行此操作的算法吗?或者甚至可能如何只获得椭圆的边界而不仅仅是矩形边界?
要扩展我的评论,请尝试这样的(未经测试的)代码:
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