#include #include struct point { float x; float y; }; int sort_get_index(float tab[], int top, float val) { int i; for(i=0; i= val) return i; } return top; } void sort_insert_at(float tab[], int i, int top, float val) { int j; for(j=top; j>i; j--) { tab[j] = tab[j-1]; } tab[i] = val; } void sort_insert(float tab[], int top, float val) { sort_insert_at(tab, sort_get_index(tab, top, val), top, val); } int nb_columns() { return 32; } int nb_lines() { return 16; } void grid_init(char grid[], char pixel) { int i; for(i=0; i= nb_columns() || y >= nb_lines()) { printf("Point (%d, %d) is out of range\n", x, y); exit(1); } grid[(nb_lines() - y - 1) * nb_columns() + x] = pixel; } void plot_vline(char grid[], int x, float fy0, float fy1, char pixel) { int y0 = fy0 + 0.5; int y1 = fy1 + 0.5; int y; if(y0 - 0.5 == fy0) y0--; for(y=y0; y<=y1; y++){ plot_point(grid, x, y, pixel); } } void plot_poly_sweep(char grid[], struct point p[], int n, int x, char pixel) { printf("sweep %d:\n", x); } void plot_poly(char grid[], struct point p[], int n, char pixel) { int i; for(i=0; i