47 lines
903 B
C
47 lines
903 B
C
#include <stdio.h>
|
|
|
|
typedef struct Vertex {
|
|
int x;
|
|
int y;
|
|
} Vertex;
|
|
|
|
typedef Vertex Polygon;
|
|
|
|
void svg_start(int w, int h) {
|
|
printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
printf("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"%d\" height=\"%d\">", w, h);
|
|
}
|
|
|
|
void svg_end() {
|
|
printf("</svg>");
|
|
}
|
|
|
|
void svg_line(Vertex* a, Vertex* b) {
|
|
printf("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke=\"black\" />", a->x, a->y, b->x, b->y);
|
|
}
|
|
|
|
void roads(Polygon* quartier) {
|
|
quartier = quartier;
|
|
Vertex center = { .x=400, .y=300 };
|
|
svg_line(¢er, &(quartier[0]));
|
|
}
|
|
|
|
int main() {
|
|
Vertex points[] = {
|
|
{ .x=10, .y=10 },
|
|
{ .x=790, .y=10 },
|
|
{ .x=600, .y=300 },
|
|
{ .x=790, .y=590 },
|
|
{ .x=10, .y=590 },
|
|
};
|
|
int n = 5;
|
|
svg_start(800,600);
|
|
int i;
|
|
for (i = 0; i < n; i++) {
|
|
svg_line(&(points[i]), &(points[(i+1)%n]));
|
|
}
|
|
roads(points);
|
|
svg_end();
|
|
return 0;
|
|
}
|