summaryrefslogtreecommitdiff
path: root/web/web_svg.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/web_svg.c')
-rw-r--r--web/web_svg.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/web/web_svg.c b/web/web_svg.c
index 3d3288c..ffdd104 100644
--- a/web/web_svg.c
+++ b/web/web_svg.c
@@ -28,14 +28,14 @@ static inline struct elem *svg_elem_init(char *name, int size_attrs)
// draws a ring if angles are equal
struct elem *gen_arc(double a1, double a2, double r1, double r2, char *col)
{
- struct ccoords cc1 = pol_to_cart((struct pcoords){
- .a = (a1 == a2 ? 1 : a2), .r = r1 });
- struct ccoords cc2 = pol_to_cart((struct pcoords){
- .a = (a1 == a2 ? 0 : a1), .r = r1 });
- struct ccoords cc3 = pol_to_cart((struct pcoords){
- .a = (a1 == a2 ? 0 : a1), .r = r2 });
- struct ccoords cc4 = pol_to_cart((struct pcoords){
- .a = (a1 == a2 ? 1 : a2), .r = r2 });
+ struct ccoords cc1 = pol_to_cart(
+ (struct pcoords){ .a = (a1 == a2 ? 1 : a2), .r = r1 });
+ struct ccoords cc2 = pol_to_cart(
+ (struct pcoords){ .a = (a1 == a2 ? 0 : a1), .r = r1 });
+ struct ccoords cc3 = pol_to_cart(
+ (struct pcoords){ .a = (a1 == a2 ? 0 : a1), .r = r2 });
+ struct ccoords cc4 = pol_to_cart(
+ (struct pcoords){ .a = (a1 == a2 ? 1 : a2), .r = r2 });
struct elem *e = svg_elem_init("path", 2);
elem_add_attr(e, "fill", col);
@@ -100,22 +100,24 @@ int draw_spider(int elemc, struct elem **elemv)
{
for (int i = 5; i > 1; --i) {
elemv[elemc++] = gen_ring(OUTER_DISTS[i], WIRE_WIDTH, C_WIRE);
- elemv[elemc++] = gen_ring(OUTER_DISTS[i], WIRE_WIDTH/2, C_WIRE_INNER);
+ elemv[elemc++] = gen_ring(OUTER_DISTS[i], WIRE_WIDTH/2,
+ C_WIRE_INNER);
}
for (int i = 0; i < NUM_SECTORS; ++i) {
double a = 90 - i*SECTOR_WIDTH - SECTOR_WIDTH/2;
if (a < 0) a += 360;
- elemv[elemc++] = gen_line(a, OUTER_DISTS[1], OUTER_DISTS[5] + 10,
- WIRE_WIDTH, C_WIRE);
- elemv[elemc++] = gen_line(a, OUTER_DISTS[1], OUTER_DISTS[5] + 10,
- WIRE_WIDTH/2, C_WIRE_INNER);
+ elemv[elemc++] = gen_line(a, OUTER_DISTS[1],
+ OUTER_DISTS[5] + 10, WIRE_WIDTH, C_WIRE);
+ elemv[elemc++] = gen_line(a, OUTER_DISTS[1],
+ OUTER_DISTS[5] + 10, WIRE_WIDTH/2, C_WIRE_INNER);
}
for (int i = 1; i >= 0; --i) {
elemv[elemc++] = gen_ring(OUTER_DISTS[i], WIRE_WIDTH, C_WIRE);
- elemv[elemc++] = gen_ring(OUTER_DISTS[i], WIRE_WIDTH/2, C_WIRE_INNER);
+ elemv[elemc++] = gen_ring(OUTER_DISTS[i], WIRE_WIDTH/2,
+ C_WIRE_INNER);
}
return elemc;
@@ -123,7 +125,8 @@ int draw_spider(int elemc, struct elem **elemv)
int draw_numbers(int elemc, struct elem **elemv)
{
- elemv[elemc++] = gen_ring(DIAMETER/2 - WIRE_WIDTH*4, WIRE_WIDTH, "#ddd");
+ elemv[elemc++] = gen_ring(DIAMETER/2 - WIRE_WIDTH*4, WIRE_WIDTH,
+ "#ddd");
int r = DIAMETER/2 - 33/2;
for (int i = 0; i < 20; ++i) {
@@ -136,7 +139,8 @@ int draw_numbers(int elemc, struct elem **elemv)
char buf[512];
double a = 90 - i*SECTOR_WIDTH;
if (a < 0) a += 360;
- struct ccoords cc = pol_to_cart((struct pcoords){ .a = a, .r = r });
+ struct ccoords cc = pol_to_cart(
+ (struct pcoords){ .a = a, .r = r });
sprintf(buf, "scale(1 -1) translate(%f %f) rotate(%f)",
cc.x, -cc.y, a <= 180 ? 90 -a : 270 -a);
elem_add_attr(e, "transform", buf);
@@ -159,8 +163,10 @@ void svg_draw_board()
for (int j = 0; j < NUM_SECTORS; ++j) {
double a = 90 - j*SECTOR_WIDTH;
if (a < 0) a += 360;
- elemv[elemc++] = gen_segment(a, OUTER_DISTS[i-1], OUTER_DISTS[i],
- i%2 ? (j%2 ? C_GREEN : C_RED) : (j%2 ? C_WHITE : C_BLACK));
+ elemv[elemc++] = gen_segment(a, OUTER_DISTS[i-1],
+ OUTER_DISTS[i],
+ i % 2 ? (j % 2 ? C_GREEN : C_RED) :
+ (j % 2 ? C_WHITE : C_BLACK));
}
}