Fill space between two curves in cartesian graph
I am having some difficulties for feeling the space between two cu开发者_运维技巧rves 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);
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);
精彩评论