]> gitweb.michael.orlitzky.com - charm-bypass.git/commitdiff
index.html.in: use svg_to_client() in center_text()
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Sep 2025 03:33:55 +0000 (23:33 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Sep 2025 03:39:37 +0000 (23:39 -0400)
The center_text() function was the first place that a coordinate
change was needed, though it was in the other direction, client to
SVG. Now that we have the svg_to_client() factor, we divide by it to
get the client_to_svg factor.

index.html.in

index a9e7c9b7a8ec60335458bcd74188749918c2d3f2..ad58d2313d4c410d56bd24bf28c1c0b41daa2176 100644 (file)
          * element and compare it to the width of the background
          * element's client rect. Since the size of the background is
          * fixed, this should give us a multiplier that turns client rect
-         * distances (what we have) into SVG distances (what we want) */
-        const svg_width = parseFloat(bg.getAttribute("width"));
-        const client_width = r1.width;
-        const client_to_svg = svg_width / client_width;
+         * distances (what we have) into SVG distances (what we want). */
 
         /* Convert hdelta from client rect to SVG coordinates */
-        const svg_hdelta = hdelta * client_to_svg;
+        const svg_hdelta = hdelta / svg_to_client();
 
         /* Since this <text> element has an "x" attribute it's easier for
          * us to shift that than it is to mess with the "left" style. */