1 #define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION
2 #include "stb_herringbone_wang_tile.h"
4 #define STB_IMAGE_WRITE_IMPLEMENTATION
5 #include "stb_image_write.h"
7 // e 12 1 1 1 1 1 1 4 4
9 int main(int argc
, char **argv
)
11 stbhw_config c
= { 0 };
12 int w
,h
, num_colors
,i
;
15 if (argc
== 1) goto usage
;
16 if (argc
< 3) goto error
;
20 if (argc
< 8 || argc
> 10)
27 if (argc
< 10 || argc
> 12)
37 c
.short_side_len
= atoi(argv
[3]);
38 for (i
=0; i
< num_colors
; ++i
)
39 c
.num_color
[i
] = atoi(argv
[4+i
]);
45 c
.num_vary_x
= atoi(argv
[4+i
]);
47 c
.num_vary_y
= atoi(argv
[5+i
]);
49 stbhw_get_template_size(&c
, &w
, &h
);
51 data
= (unsigned char *) malloc(w
*h
*3);
53 if (stbhw_make_template(&c
, data
, w
, h
, w
*3))
54 stbi_write_png(argv
[1], w
, h
, 3, data
, w
*3);
56 fprintf(stderr
, "Error: %s\n", stbhw_get_last_error());
60 fputs("Invalid command-line arguments\n\n", stderr
);
62 fputs("Usage (see source for corner & edge type definitions):\n\n", stderr
);
63 fputs("herringbone_generator {outfile} c {sidelen} {c0} {c1} {c2} {c3} [{vx} {vy}]\n"
64 " {outfile} -- filename that template will be written to as PNG\n"
65 " {sidelen} -- length of short side of rectangle in pixels\n"
66 " {c0} -- number of colors for corner type 0\n"
67 " {c1} -- number of colors for corner type 1\n"
68 " {c2} -- number of colors for corner type 2\n"
69 " {c3} -- number of colors for corner type 3\n"
70 " {vx} -- number of color-duplicating variations horizontally in template\n"
71 " {vy} -- number of color-duplicating variations vertically in template\n"
74 fputs("herringbone_generator {outfile} e {sidelen} {e0} {e1} {e2} {e3} {e4} {e5} [{vx} {vy}]\n"
75 " {outfile} -- filename that template will be written to as PNG\n"
76 " {sidelen} -- length of short side of rectangle in pixels\n"
77 " {e0} -- number of colors for edge type 0\n"
78 " {e1} -- number of colors for edge type 1\n"
79 " {e2} -- number of colors for edge type 2\n"
80 " {e3} -- number of colors for edge type 3\n"
81 " {e4} -- number of colors for edge type 4\n"
82 " {e5} -- number of colors for edge type 5\n"
83 " {vx} -- number of color-duplicating variations horizontally in template\n"
84 " {vy} -- number of color-duplicating variations vertically in template\n"