填充笛卡尔图中两条曲线之间的空间

发布于 2024-11-04 08:20:07 字数 1079 浏览 1 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩世 2024-11-11 08:20:07
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);
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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文