blob: 0bbe88052b5f41a1784332397da353f20bdf28aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include <math.h>
#include <stdlib.h>
#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);
}
|