填充直角图中两条曲线之间的空间
本文关键字:两条 曲线 之间 空间 填充 | 更新日期: 2023-09-27 17:53:44
在我的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);
List<PointF> joinedCurves = new List<PointF>();
joinedCurves.AddRange(u);
jointCurves.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);