From 270dd272f5fd2e9c7e178ba31c561e41d820608a Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 16 May 2022 22:26:38 -0700 Subject: web: display svg overflow --- web/web_svg.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'web/web_svg.c') diff --git a/web/web_svg.c b/web/web_svg.c index 485583d..8714e69 100644 --- a/web/web_svg.c +++ b/web/web_svg.c @@ -188,27 +188,24 @@ static void draw_board() static void create_board() { + char buf[512]; + struct dom_elem *e = svg_elem_init("svg", 2); dom_elem_add_attr(e, "id", "dartboard"); - char *viewbox; - asprintf(&viewbox, "0 0 %f %f", DIAMETER, DIAMETER); - dom_elem_add_attr(e, "viewBox", viewbox); - free(viewbox); + sprintf(buf, "0 0 %f %f", DIAMETER, DIAMETER); + dom_elem_add_attr(e, "viewBox", buf); dom_append_elemv("#dartboard-container", 1, &e); struct dom_elem **elemv = malloc(2 * sizeof(*elemv)); int elemc = 0; - char *transform; - asprintf(&transform, "translate(%f %f) scale(1 -1)", - DIAMETER/2, DIAMETER/2); + sprintf(buf, "translate(%f %f) scale(1 -1)", DIAMETER/2, DIAMETER/2); for (int i = 0; i < 2; ++i) { struct dom_elem *e = svg_elem_init("g", 2); dom_elem_add_attr(e, "class", i ? "overlay" : "base"); - dom_elem_add_attr(e, "transform", transform); + dom_elem_add_attr(e, "transform", buf); elemv[elemc++] = e; } - free(transform); dom_append_elemv("#dartboard", elemc, elemv); -- cgit v1.2.3-70-g09d2