示例#1
0
 /// <summary>
 /// 将数据列表用自定义函数可视化,自定义函数的参数分别为(x, x_min, x_max),返回值为对应的颜色
 /// </summary>
 /// <param name="data">需要可视化的数据</param>
 /// <param name="offset">需要可视化的数据起始点</param>
 /// <param name="data_count">需要可视化的数据数量</param>
 /// <param name="bar_length">条带的总宽度</param>
 /// <param name="y">条带的y坐标</param>
 /// <param name="height">条带的高</param>
 /// <param name="data_min">数据中的最小可能值</param>
 /// <param name="data_max">数据中的最大可能值</param>
 /// <param name="func">自定义函数</param>
 public static void ArrayCustomPlot(double[] data, int offset, int data_count, float bar_length, float y, float height, double data_min, double data_max, Func <double, double, double, Color> func)
 {
     DX2D.Render = () =>
     {
         float pix_per_data = bar_length / data_count;
         if (pix_per_data > 1)                                    //每个数据点占据了超过1个像素
         {
             int block_width = Convert.ToInt32(pix_per_data + 1); //上取整保证中间不漏像素
             for (int n = offset; n < data_count; n++)
             {
                 DX2D.Shape.ImportRect(n * block_width, y, block_width, height, func(data[n], data_min, data_max));
             }
         }
         else
         {
             for (int n = offset; n < data_count; n++)
             {
                 DX2D.Shape.ImportRect(pix_per_data * n, y, pix_per_data, height, func(data[n], data_min, data_max));
             }
         }
     };
     DX2D.Present();
 }
示例#2
0
 /// <summary>
 /// 将数据列表用自定义函数可视化,自定义函数的参数分别为(x, x_min, x_max),返回值为对应的颜色
 /// </summary>
 /// <param name="data">需要可视化的数据</param>
 /// <param name="bar_length">条带的总宽度</param>
 /// <param name="y">条带的y坐标</param>
 /// <param name="height">条带的高</param>
 /// <param name="data_min">数据中的最小可能值</param>
 /// <param name="data_max">数据中的最大可能值</param>
 /// <param name="func">自定义函数</param>
 public static void ArrayCustomPlot(double[] data, float bar_length, float y, float height, double data_min, double data_max, Func <double, double, double, Color> func)
 {
     DX2D.Render = () =>
     {
         float pix_per_data = bar_length / data.Length;
         if (true)
         {
             int block_width = Convert.ToInt32(pix_per_data);
             for (int n = 0; n < data.Length; n++)
             {
                 DX2D.Shape.ImportRect(n * block_width, y, block_width, height, func(data[n], data_min, data_max));
             }
         }
         else
         {
             for (int n = 0; n < data.Length; n++)
             {
                 DX2D.Shape.ImportRect(pix_per_data * n, y, pix_per_data, height, func(data[n], data_min, data_max));
             }
         }
     };
     DX2D.Present();
 }
示例#3
0
 /// <summary>
 /// 绘制一块给定颜色的矩形
 /// </summary>
 /// <param name="x">左上角的x坐标</param>
 /// <param name="y">左上角的y坐标</param>
 /// <param name="width">宽度</param>
 /// <param name="height">高度</param>
 /// <param name="color">颜色</param>
 public static void DrawRect(float x, float y, float width, float height, Color color)
 {
     DX2D.Render = () => DX2D.Shape.ImportRect(x, y, width, height, color);
     DX2D.Present();
 }
示例#4
0
 /// <summary>
 /// 绘制一条给定颜色的实线
 /// </summary>
 /// <param name="x1">端点1的x坐标</param>
 /// <param name="y1">端点1的y坐标</param>
 /// <param name="x2">端点2的x坐标</param>
 /// <param name="y2">端点2的y坐标</param>
 /// <param name="color">实线的颜色</param>
 public static void DrawLine(float x1, float y1, float x2, float y2, Color color)
 {
     DX2D.Render = () => DX2D.Shape.ImportLine(x1, y1, x2, y2, color);
     DX2D.Present();
 }