填充笛卡尔图中两条曲线之间的空间
我在 WinForms 程序中感受笛卡尔图中两条曲线之间的空间时遇到一些困难。
基本上我有两条曲线,我使用这种方法将它们绘制在位图上:
public Bitmap DrawEnvelope(PointF[] u, PointF[] d)
{
g = Graphics.FromImage(box);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
Pen pengraph = new Pen(Color.FromArgb(50, 0 ,0 ,200), 1F);
pengraph.Alignment = PenAlignment.Center;
g.DrawCurve(pengraph, u, 0); //uperline
g.DrawCurve(pengraph, d, 0); //downline
g.Dispose();
return box;
}
现在我想用颜色填充这两条曲线之间的空间。这怎么能做到呢?
我查了一下MSDN,发现了像FillClosedCurve这样的方法。但在这种情况下它对我没有帮助。
谢谢。
由 Akh 的评论解决
joinedCurves.AddRange(u);
joinedCurves.AddRange(d.Reverse());
PointF[] fillPoints = joinedCurves.ToArray();
SolidBrush fillBrush = new SolidBrush(Color.FromArgb(50, 0, 0, 200));
FillMode newFillMode = FillMode.Alternate;
g.FillClosedCurve(fillBrush, fillPoints, newFillMode, 0);
I am having some difficulties for feeling the space between two curves in a carthesian graph in my WinForms program.
Basicly I have two curves that I draw them on a bitmap using this method:
public Bitmap DrawEnvelope(PointF[] u, PointF[] d)
{
g = Graphics.FromImage(box);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
Pen pengraph = new Pen(Color.FromArgb(50, 0 ,0 ,200), 1F);
pengraph.Alignment = PenAlignment.Center;
g.DrawCurve(pengraph, u, 0); //uperline
g.DrawCurve(pengraph, d, 0); //downline
g.Dispose();
return box;
}
Now I want to fill the space between these two curves with a color. How can this be done?
I looked in MSDN and found a method like FillClosedCurve. but it does not help me in this case.
Thanks.
Solved by Akh's comment
joinedCurves.AddRange(u);
joinedCurves.AddRange(d.Reverse());
PointF[] fillPoints = joinedCurves.ToArray();
SolidBrush fillBrush = new SolidBrush(Color.FromArgb(50, 0, 0, 200));
FillMode newFillMode = FillMode.Alternate;
g.FillClosedCurve(fillBrush, fillPoints, newFillMode, 0);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)