用C#绘制实时曲线图
用C#绘制实时曲线图
set { height = value; }
}
/// <SUMMARY>
/// 图片的宽度
/// </SUMMARY>
public int Width
{
get { return width; }
set { width = value; }
}
/// <SUMMARY>
/// 构造函数,指定生成的曲线图的宽度和高度
/// </SUMMARY>
/// <PARAM name="width">要生成的曲线图的宽度</PARAM>
/// <PARAM name="height">要生成的曲线图的高度</PARAM>
public RealTimeImageMaker(int width, int height):this(width,height,Color.Gray,Color.Blue)
{
}
/// <SUMMARY>
/// 构造函数,指定生成的曲线图的宽度、高度及背景色和前景色
/// </SUMMARY>
/// <PARAM name="width">要生成的曲线图的宽度</PARAM>
/// <PARAM name="height">要生成的曲线图的高度</PARAM>
/// <PARAM name="backColor">曲线图背景色</PARAM>
/// <PARAM name="foreColor">曲线图前景色</PARAM>
public RealTimeImageMaker(int width, int height, Color backColor, Color foreColor)
{
this.width = width;
this.height = height;
this.backColor = backColor;
this.foreColor = foreColor;
pointList = new Point[width];
Point tempPoint;
//初始化曲线上的所有点坐标
for (int i = 0; i < width; i++)
{
tempPoint = new Point();
//曲线的横坐标沿x轴依次递增,在横向位置上每个像素都有一个点
tempPoint.X = i;
//曲线上每个点的纵坐标随机生成,但保证在显示区域之内
tempPoint.Y = random.Next() % height;
pointList = tempPoint;
}
}


