summaryrefslogtreecommitdiff
path: root/experimental/tectonics/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'experimental/tectonics/util.c')
-rw-r--r--experimental/tectonics/util.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/experimental/tectonics/util.c b/experimental/tectonics/util.c
new file mode 100644
index 0000000..a0a32a3
--- /dev/null
+++ b/experimental/tectonics/util.c
@@ -0,0 +1,25 @@
+#include <math.h>
+
+#include "tectonics.h"
+
+void get_cairo_size(cairo_t *cr, int *width, int *height)
+{
+ cairo_surface_t *surface = cairo_get_target(cr);
+ *width = cairo_image_surface_get_width(surface);
+ *height = cairo_image_surface_get_height(surface);
+}
+
+
+double rand01()
+{
+ return ((double) rand())/RAND_MAX;
+}
+
+
+double distance(double x0, double y0, double x1, double y1)
+{
+ double dx = x1-x0;
+ double dy = y1-y0;
+
+ return sqrt(dx*dx + dy*dy);
+}