<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Luigi,</p>
    <p>your hint, only to use the "positive quadrant" led me to this
      ugly workaround until mpost's svg output is debugged:</p>
    <p>def korrektur =<br>
      z1 = llcorner currentpicture ;<br>
      numeric dw, dh ;<br>
      if x1 < 0: dw := abs x1; else: dw := 0 fi ;<br>
      if y1 < 0: dh := abs y1; else: dh := 0 fi ;<br>
      currentpicture := currentpicture shifted (dw,dh) ;<br>
      enddef ;<br>
      outputformat := "svg";<br>
      outputtemplate := "%j-%c-corrected.%{outputformat}";<br>
      for i = 17 upto 23 :<br>
      beginfig(i)<br>
      fill fullcircle scaled i withcolor red ;<br>
      korrektur ;<br>
      endfig ;<br>
      endfor ;<br>
      end</p>
    <p>(seems to work so far...)<br>
    </p>
    <p>Thank you for your work on METAPOST.</p>
    <p>Greetings Lutz<br>
    </p>
    <div class="moz-cite-prefix">Am 19.01.2023 um 09:15 schrieb luigi
      scarso:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAG5iGsA5pxU6KUYBqSS39b+Tf-eNYS352PnVNEg1Z5e_8j8nNw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr"><br>
        </div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Wed, 18 Jan 2023 at
            13:04, luigi scarso <<a
              href="mailto:luigi.scarso@gmail.com"
              moz-do-not-send="true" class="moz-txt-link-freetext">luigi.scarso@gmail.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <div dir="ltr">
              <div dir="ltr"><br>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Wed, 18 Jan 2023 at
                  12:53, Lutz Haseloff <<a
                    href="mailto:lutz.haseloff@toppkieker.info"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">lutz.haseloff@toppkieker.info</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px
                  0px 0.8ex;border-left:1px solid
                  rgb(204,204,204);padding-left:1ex">
                  <div>
                    <p>Hi Luigi,</p>
                    <p>I tested a bit further.</p>
                    <p>MP:</p>
                    <p>outputformat := "svg";<br>
                      outputtemplate := "%j-%c.%{outputformat}";<br>
                      beginfig(19)<br>
                      fill fullcircle scaled 19 withcolor red ;<br>
                      endfig;<br>
                      end<br>
                    </p>
                    <p>SVG:</p>
                    <p><?xml version="1.0"?><br>
                      <!-- Created by MetaPost 2.02 on
                      2023.01.18:1229 --><br>
                      <svg version="1.1" xmlns=<a
                        href="http://www.w3.org/2000/svg"
                        target="_blank" moz-do-not-send="true">"http://www.w3.org/2000/svg"</a>
                      xmlns:xlink=<a href="http://www.w3.org/1999/xlink"
                        target="_blank" moz-do-not-send="true">"http://www.w3.org/1999/xlink"</a>
                      width="19.000000" height="19.000000" viewBox="0 0
                      19.000000 19.000000"><br>
                      <!-- Original BoundingBox: -9.500000 -9.500000
                      9.500000 9.500000 --><br>
                        <path d="M18.500000 9.000000 (should be 19.0
                      9.5) ... 11.519557 -0.500000 (should be 0) ...
                      -0.500000 9.000000 (should be 0) ... ,18.500000
                      9.000000Z" style="fill:
                      rgb(100.000000%,0.000000%,0.000000%);stroke:
                      none;"></path><br>
                      </svg><br>
                    </p>
                    <p>It seems, that the path d is not correctly
                      transformed from the ps hires boundingbox (-9.5
                      -9.5 9.5 9.5) to the svg viewbox (0 0 19 19).</p>
                    <p>With even sizes ( say 20) it works ok.</p>
                    <p><br>
                    </p>
                  </div>
                </blockquote>
                <div><br>
                </div>
                <div>indeed, I was looking at it ... this evening can
                  check it better</div>
                <div><br>
                </div>
                <div>--</div>
                <div>luigi</div>
                <div><br>
                </div>
                <div> </div>
              </div>
            </div>
          </blockquote>
          <div><br>
          </div>
          <div>looking at this now, maybe the integer dx and dy are not
            ok.</div>
          <div><br>
          </div>
          <div>@ We often need to print a pair of coordinates. <br>
            <br>
            Because of bugs in svg rendering software, it is necessary
            to <br>
            change the point coordinates so that there are all in the
            "positive" <br>
            quadrant of the SVG field. This means an shift and a
            vertical flip.<br>
            <br>
            The two correction values are calculated by the function
            that writes<br>
            the initial |<svg>| tag, and  are stored in two
            globals:<br>
            <br>
            @<Globals@>=<br>
            integer dx;<br>
            integer dy;<br>
            <br>
            @ @c<br>
            void mp_svg_pair_out (MP mp,double x, double y) { <br>
              mp_svg_store_double(mp, (x+mp->svg->dx));<br>
              append_char(' ');<br>
              mp_svg_store_double(mp, (-(y+mp->svg->dy)));<br>
            }</div>
          <div><br>
            If I use double, i.e.</div>
          <div>@<Globals@>=<br>
            double dx;<br>
            double dy;<br>
          </div>
          <div><br>
          </div>
          <div>I have now</div>
          <div><br>
          </div>
          <div><?xml version="1.0"?><br>
            <!-- Created by MetaPost 2.02 on 2023.01.19:0912 --><br>
            <svg version="1.1" xmlns="<a
              href="http://www.w3.org/2000/svg" moz-do-not-send="true"
              class="moz-txt-link-freetext">http://www.w3.org/2000/svg</a>"
            xmlns:xlink="<a href="http://www.w3.org/1999/xlink"
              moz-do-not-send="true" class="moz-txt-link-freetext">http://www.w3.org/1999/xlink</a>"
            width="19.000000" height="19.000000" viewBox="0 0 19.000000
            19.000000"><br>
            <!-- Original BoundingBox: -9.500000 -9.500000 9.500000
            9.500000 --><br>
              <path d="M19.000000 9.500000C19.000000
            6.980331,17.998917 4.564163,16.217377 2.782623C14.435837
            1.001083,12.019669 -0.000000,9.500000 -0.000000C6.980331
            -0.000000,4.564163 1.001083,2.782623 2.782623C1.001083
            4.564163,0.000000 6.980331,0.000000 9.500000C0.000000
            12.019669,1.001083 14.435837,2.782623 16.217377C4.564163
            17.998917,6.980331 19.000000,9.500000 19.000000C12.019669
            19.000000,14.435837 17.998917,16.217377 16.217377C17.998917
            14.435837,19.000000 12.019669,19.000000 9.500000Z"
            style="fill: rgb(100.000000%,0.000000%,0.000000%);stroke:
            none;"></path><br>
            </svg><br>
            <br>
          </div>
          <div>--</div>
          <div>luigi</div>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">--
<a class="moz-txt-link-freetext" href="http://tug.org/metapost/">http://tug.org/metapost/</a></pre>
    </blockquote>
  </body>
</html>