]> git.cworth.org Git - acre/blobdiff - acre.h
Add preliminary implementation of acre
[acre] / acre.h
diff --git a/acre.h b/acre.h
new file mode 100644 (file)
index 0000000..0a39df9
--- /dev/null
+++ b/acre.h
@@ -0,0 +1,76 @@
+/* acre - A cairo-based library for creating plots and charts.
+ *
+ * Copyright © 2009 Carl Worth <cworth@cworth.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef ACRE_H
+#define ACRE_H
+
+#include <cairo.h>
+
+typedef struct _acre acre_t;
+typedef struct _acre_data acre_data_t;
+
+/* Create a new, empty plot. */
+acre_t *
+acre_create (void);
+
+/* Destroy a plot. */
+void
+acre_destroy (acre_t *acre);
+
+void
+acre_set_title (acre_t *acre, const char *title);
+
+void
+acre_set_x_axis_label (acre_t *acre, const char *label);
+
+void
+acre_set_y_axis_label (acre_t *acre, const char *label);
+
+/* Add a dataset to the plot. The plot assumes ownership of the
+ * dataset so it is not necessary to call acre_data_destroy on it. */
+void
+acre_add_data (acre_t *acre, acre_data_t *data);
+
+/* Draw the plot to the given cairo context within a user-space
+ * rectangle from (0, 0) to (width, height). This size includes all
+ * space for extra-plot elements (such as the title, the axis labels,
+ * etc.)
+ */
+void
+acre_draw (acre_t *acre, cairo_t *cr, double width, double height);
+
+/* Create a new dataset---a collection of (x, y) datapoints. A single
+ * plot can contain multiple datasets, (see acre_add_data). */
+acre_data_t *
+acre_data_create (void);
+
+/* Destroy an acre dataset. Do not call this function if the dataset
+ * has been added to an acre_t plot with acre_add_data. */
+void
+acre_data_destroy (acre_data_t *data);
+
+/* Set the label for this dataset (to appear in the plot's key). */
+void
+acre_data_set_name (acre_data_t *data, const char *name);
+
+/* Add a datapoint to the given dataset. */
+void
+acre_data_add_point_2d (acre_data_t *data, double x, double y);
+
+#endif /* ACRE_H */