#include "svg.h" void print_pattern_svg(FILE *out, struct print_params params, struct pattern *pattern) { // Init variables. double horizontal = 100 / (pattern->type.height + 1); double vertical = 100 / (pattern->type.width + 1); int hd = horizontal; // Horizontal distance int vd = vertical; // Vertical distance // Print fprintf(out, ""); fprintf(out, ""); if (params.print_code) { char code[128]; pattern_nums_to_str(code, pattern); fprintf(out, "Code:%s", code); } if (params.print_count) fprintf(out, "Count:%d", params.count); if (params.print_author) fprintf(out, "adriansopar.hu"); // TODO: Print text! // Print points. for (int y = 0; y < pattern->type.height; y++) { for (int x = 0; x < pattern->type.width; x++) { fprintf(out, "", (double)(x + 1) * hd, (double)(y + 1) * vd, 3); } } // Print pattern. struct coord prev; for (int i = 0; i < pattern->length; i++) { struct coord current = pattern->path[i]; fprintf(out, "", (double)(current.x + 1) * hd, (double)(current.y + 1) * vd); if (i > 0) fprintf(out, "", (double)(prev.x + 1) * hd, (double)(prev.y + 1) * vd, (double)(current.x + 1) * hd, (double)(current.y + 1) * vd); prev = current; } fprintf(out, ""); }