[Intel-gfx] [PATCH i-g-t 16/16] plot: Add an example of the plotting API

Damien Lespiau damien.lespiau at intel.com
Mon Jul 6 05:35:44 PDT 2015


Unfortunately, I didn't manage to make the image inclusion work...

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 lib/igt_plot.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/lib/igt_plot.c b/lib/igt_plot.c
index b3d4bc7..bc7bce1 100644
--- a/lib/igt_plot.c
+++ b/lib/igt_plot.c
@@ -43,7 +43,34 @@
  * @include: igt_plots.h
  *
  * A drawing is better than a long speech. Plotting data can reveal surprises
- * and the igt_plot_t object let you do just that.
+ * and igt_plot_t lets you do just that.
+ *
+ * To draw a plot, one needs to populate 2 #igt_vector_t for the X and Y axis
+ * and draw the result.
+ *
+ * |[
+ * static double f(double x)
+ * {
+ *        return sin(2 * M_PI * x);
+ * }
+ *
+ * void draw_plot(void)
+ * {
+ *        igt_vector_t *x, *y;
+ *        igt_plot_t plot;
+ *
+ *        x = igt_vector_linear(-1.0, 1.0, 200);
+ *        y = igt_vector_map(x, f);
+ *
+ *        igt_plot_init(&plot, 800, 600);
+ *        igt_plot_set_title(&plot, "f(x) = sin(2πx)");
+ *        igt_plot_axis_set_title(&plot.x_axis, "x");
+ *        igt_plot_axis_set_title(&plot.y_axis, "f(x)");
+ *        igt_plot_set_color(&plot, 0.0, 0.0, 1.0, 1.0);
+ *        igt_plot_draw(&plot, x, y);
+ *        igt_plot_write(&plot, "test_simple_plot.png");
+ * }
+ * ]|
  */
 
 /* snap to pixel */
-- 
2.1.0



More information about the Intel-gfx mailing list