#include #include #include "util.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(struct point_t p1, struct point_t p2) { double dx = p1.x-p2.x; double dy = p1.y-p2.y; return sqrt(dx*dx + dy*dy); }