#include #include #include #include #define WIDTH 1280 #define HEIGHT 720 #define SEED 8081 #define POINTS 20 static int seed_offset = 1; struct point { int x; int y; }; double dist_p1_p2(int p1x, int p1y, int p2x, int p2y){ double pA, pB; pA = p1x - p2x; pB = p1y - p2y; return sqrt(pA * pA + pB * pB); } void draw_pixel(Display * di, Window wi, GC gc, int x, int y, int color){ XSetForeground(di, gc, color); XDrawPoint(di, wi, gc, x, y); } float rand_0_1(){ int o0; float o0f, r; srand(SEED+seed_offset++); // define random initial seed o0 = rand(); o0f = (float) o0; r = o0f / RAND_MAX; return (r); } double * sort(double * arr){ int arr_size = POINTS; int i,j, aux; for (i=0; i arr[j]){ aux = arr[j]; arr[j] = arr[i]; arr[i] = aux; } } } } int map (int value, int min, int max, int map_min, int map_max){ double R = (double) (map_max - map_min) / (double) (max - min); double y = map_min + (value * R) + R; return (int) y; } void worley_noise(Display * di, Window wi, GC gc){ int x, y, i; int c; int noise_space[WIDTH][HEIGHT]; double dist[POINTS], sdist[POINTS]; struct point p[POINTS]; for (x=0; x