日期:2014-05-18  浏览次数:21001 次

c# 如何在图片上绘制带有坐标的函数曲线?
c#   如何在图片上绘制带有坐标的函数曲线?在Graphics上绘图,然后用放到Picturebox里,找不到背景属性呀!


------解决方案--------------------
直接在Picturebox中画就可以,坐标根据实际数值和绘图区域的比例,自己画
------解决方案--------------------
C# code

private void pictureBox_Paint(object sender, PaintEventArgs e)
{            
    Graphics g = e.Graphics;
    Color color = new Color();
    color = Color.FromArgb(128, Color.FromArgb(0, 255, 0));//设置透明度 绿 默认     
    SolidBrush brush = new SolidBrush(color);
    
    
    Queue<Point> array = new Queue<Point>();
    string[] list = points.Split('|'); //坐标数据
    if (list.Length >= 3)
    {
        for (int j = 0; j < list.Length; j++)
        {
            int x = Convert.ToInt32(list[j].Split(',')[0]);
            int y = Convert.ToInt32(list[j].Split(',')[1]);
            array.Enqueue(new Point(x, y));
        }
    }    
    
    g.FillPolygon(brush, array.ToArray());
    brush.Dispose();
}