<?xml version="1.0" encoding="utf-8"?>
<svg
  version="1.1"
  viewBox="0 0 800 800"
  width="800" height="800"
  style="margin:auto"{# center svg image #}
  xmlns="http://www.w3.org/2000/svg"
  xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
  inkscape:label="pallas-pattern{% if simple %}.simple{% endif %}{% if doublelines %}.doublelines{% endif %}{% if roundlines %}.roundlines{% endif %}{% if nocircles %}.nocircles{% endif %}{% if boxes %}.boxes{% endif %}"
>
  <defs>
    <clipPath id="clip-image">
      <rect width="100%" height="100%"/>
    </clipPath>
  </defs>
  <g inkscape:label="clipped image" clip-path="url(#clip-image)">

    {% if pallas %}
    <g inkscape:label="pallas key: center cross, top-right square" stroke-width="2" fill="none" stroke="black">
      <g inkscape:label="simple pattern">
        <g inkscape:label="single lines orthogonal: single lines outside squares">
          <g>
            <title>top right</title>
            <path d="M 700 100 L 700 300"/>
            <path d="M 500 100 L 500 300"/>
            <path d="M 500 300 L 700 300"/>
            <path d="M 500 100 L 700 100"/>
          </g>
        </g>
        <g inkscape:label="single lines diagonal">
          <path inkscape:label="center bottom-left to top-right" d="M 500 300 L 300 500"/>
          <path inkscape:label="center top-left to bottom-right" d="M 500 500 L 300 300"/>
        </g>
      </g>
    </g>
    {% endif %}

    <g fill="none" stroke="#000" stroke-width="2" inkscape:label="lines">

      {% if roundlines %}
      <g inkscape:label="roundlines pattern">
        <g inkscape:label="crosses">
          <use href="#cross-lines" transform="translate( 400  400)" inkscape:label="bottom-right"/>
          <use href="#cross-lines" transform="translate(   0  400)" inkscape:label="bottom-center"/>
          <use href="#cross-lines" transform="translate(-400  400)" inkscape:label="bottom-left"/>
          <use href="#cross-lines" transform="translate( 400    0)" inkscape:label="center-right"/>
          <g id="cross-lines" inkscape:label="center-center">
            <!-- math.sqrt(2)*100 = 141.4213562373095 -->
            <path inkscape:label="left" d="m 300 300 a 141.4213562373095 141.4213562373095 0 0 1 41.4213562373095 100 141.4213562373095 141.4213562373095 0 0 1 -41.4213562373095 100"/>
            <path inkscape:label="right" d="m 500 500 a 141.4213562373095 141.4213562373095 0 0 1 0 -200"/>
            <path inkscape:label="top" d="m 500 300 a 141.4213562373095 141.4213562373095 0 0 1 -100 41.4213562373095 141.4213562373095 141.4213562373095 0 0 1 -100 -41.4213562373095"/>
            <path inkscape:label="bottom" d="m 300 500 a 141.4213562373095 141.4213562373095 0 0 1 200 0"/>
          </g>
          <use href="#cross-lines" transform="translate(-400    0)" inkscape:label="center-left"/>
          <use href="#cross-lines" transform="translate( 400 -400)" inkscape:label="top-right"/>
          <use href="#cross-lines" transform="translate(   0 -400)" inkscape:label="top-center"/>
          <use href="#cross-lines" transform="translate(-400 -400)" inkscape:label="top-left"/>
        </g>
        <g inkscape:label="circles">
          <!-- math.sqrt(2)*100 = 141.4213562373095 -->
          <circle cx="600" cy="600" r="141.4213562373095" inkscape:label="bottom-right"/>
          <circle cx="200" cy="600" r="141.4213562373095" inkscape:label="bottom-left"/>
          <circle cx="600" cy="200" r="141.4213562373095" inkscape:label="top-right"/>
          <circle cx="200" cy="200" r="141.4213562373095" inkscape:label="top-left"/>
        </g>
      </g>
      {% endif %}

      {% if doublelines %}
      <g inkscape:label="doublelines pattern">
        <g inkscape:label="single lines">
          <g inkscape:label="single lines center">
            <path inkscape:label="right" d="M 500 360 L 500 440"/>
            <path inkscape:label="left" d="M 300 360 L 300 440"/>
            <path inkscape:label="bottom" d="M 440 500 L 360 500"/>
            <path inkscape:label="top" d="M 360 300 L 440 300"/>
          </g>
          <g inkscape:label="single lines offscreen squares">
            <!-- single lines center + translate by 400 -->
            <g inkscape:label="right" transform="translate(400 0)">
              <path inkscape:label="left" d="M 300 360 L 300 440"/>
              <path inkscape:label="bottom" d="M 440 500 L 360 500"/>
              <path inkscape:label="top" d="M 360 300 L 440 300"/>
            </g>
            <g inkscape:label="left" transform="translate(-400 0)">
              <path inkscape:label="right" d="M 500 360 L 500 440"/>
              <path inkscape:label="bottom" d="M 440 500 L 360 500"/>
              <path inkscape:label="top" d="M 360 300 L 440 300"/>
            </g>
            <g inkscape:label="top" transform="translate(0 -400)">
              <path inkscape:label="right" d="M 500 360 L 500 440"/>
              <path inkscape:label="left" d="M 300 360 L 300 440"/>
              <path inkscape:label="bottom" d="M 440 500 L 360 500"/>
              <!--
              <path inkscape:label="top" d="M 360 300 L 440 300"/>
              -->
            </g>
            <g inkscape:label="bottom" transform="translate(0 400)">
              <path inkscape:label="right" d="M 500 360 L 500 440"/>
              <path inkscape:label="left" d="M 300 360 L 300 440"/>
              <path inkscape:label="top" d="M 360 300 L 440 300"/>
            </g>
            <g inkscape:label="top left" transform="translate(-400 -400)">
              <path inkscape:label="right" d="M 500 360 L 500 440"/>
              <path inkscape:label="bottom" d="M 440 500 L 360 500"/>
            </g>
            <g inkscape:label="top right" transform="translate(400 -400)">
              <path inkscape:label="left" d="M 300 360 L 300 440"/>
              <path inkscape:label="bottom" d="M 440 500 L 360 500"/>
            </g>
            <g inkscape:label="bottom left" transform="translate(-400 400)">
              <path inkscape:label="right" d="M 500 360 L 500 440"/>
              <path inkscape:label="top" d="M 360 300 L 440 300"/>
            </g>
            <g inkscape:label="bottom right" transform="translate(400 400)">
              <path inkscape:label="left" d="M 300 360 L 300 440"/>
              <path inkscape:label="top" d="M 360 300 L 440 300"/>
            </g>
          </g>
        </g>
        <g inkscape:label="double lines">

          <g inkscape:label="double lines outside squares">
            <!-- copy paste. different transform values -->
            <g inkscape:label="top left" transform="translate(-200 -200)">
              <title>top-left double lines</title>
              <path inkscape:label="right left" d="M 490 360 L 490 440"/>
              <path inkscape:label="right right" d="M 510 360 L 510 440"/>

              <path inkscape:label="left left" d="M 290 360 L 290 440"/>
              <path inkscape:label="left right" d="M 310 360 L 310 440"/>

              <path inkscape:label="bottom top" d="M 440 490 L 360 490"/>
              <path inkscape:label="bottom bottom" d="M 440 510 L 360 510"/>

              <path inkscape:label="top bottom" d="M 360 310 L 440 310"/>
              <path inkscape:label="top top" d="M 360 290 L 440 290"/>
            </g>

            <g inkscape:label="top left" transform="translate(200 -200)">
              <title>top-left double lines</title>
              <path inkscape:label="right left" d="M 490 360 L 490 440"/>
              <path inkscape:label="right right" d="M 510 360 L 510 440"/>

              <path inkscape:label="left left" d="M 290 360 L 290 440"/>
              <path inkscape:label="left right" d="M 310 360 L 310 440"/>

              <path inkscape:label="bottom top" d="M 440 490 L 360 490"/>
              <path inkscape:label="bottom bottom" d="M 440 510 L 360 510"/>

              <path inkscape:label="top bottom" d="M 360 310 L 440 310"/>
              <path inkscape:label="top top" d="M 360 290 L 440 290"/>
            </g>

            <g inkscape:label="top left" transform="translate(-200 200)">
              <title>top-left double lines</title>
              <path inkscape:label="right left" d="M 490 360 L 490 440"/>
              <path inkscape:label="right right" d="M 510 360 L 510 440"/>

              <path inkscape:label="left left" d="M 290 360 L 290 440"/>
              <path inkscape:label="left right" d="M 310 360 L 310 440"/>

              <path inkscape:label="bottom top" d="M 440 490 L 360 490"/>
              <path inkscape:label="bottom bottom" d="M 440 510 L 360 510"/>

              <path inkscape:label="top bottom" d="M 360 310 L 440 310"/>
              <path inkscape:label="top top" d="M 360 290 L 440 290"/>
            </g>

            <g inkscape:label="top left" transform="translate(200 200)">
              <title>top-left double lines</title>
              <path inkscape:label="right left" d="M 490 360 L 490 440"/>
              <path inkscape:label="right right" d="M 510 360 L 510 440"/>

              <path inkscape:label="left left" d="M 290 360 L 290 440"/>
              <path inkscape:label="left right" d="M 310 360 L 310 440"/>

              <path inkscape:label="bottom top" d="M 440 490 L 360 490"/>
              <path inkscape:label="bottom bottom" d="M 440 510 L 360 510"/>

              <path inkscape:label="top bottom" d="M 360 310 L 440 310"/>
              <path inkscape:label="top top" d="M 360 290 L 440 290"/>
            </g>
          </g>
        </g>
      </g>
      {% endif %}

      {% if simple %}
      <g inkscape:label="simple pattern">
        <g inkscape:label="single lines orthogonal: single lines outside squares">
          <g>
            <title>bottom left</title>
            <path inkscape:label="right" d="M 300 560 L 300 640"/>
            <path inkscape:label="left" d="M 100 560 L 100 640"/>
            <path inkscape:label="bottom" d="M 160 700 L 240 700"/>
            <path inkscape:label="top" d="M 160 500 L 240 500"/>
          </g>
          <g>
            <title>bottom right</title>
            <path inkscape:label="right" d="M 700 560 L 700 640"/>
            <path inkscape:label="left" d="M 500 560 L 500 640"/>
            <path inkscape:label="bottom" d="M 560 700 L 640 700"/>
            <path inkscape:label="top" d="M 560 500 L 640 500"/>
          </g>
          <g>
            <title>top right</title>
            <!-- TODO add titles -->
            <path d="M 700 160 L 700 240"/>
            <path d="M 500 160 L 500 240"/>
            <path d="M 560 300 L 640 300"/>
            <path d="M 560 100 L 640 100"/>
          </g>
          <g>
            <title>top left</title>
            <!-- TODO add titles -->
            <path d="M 300 160 L 300 240"/>
            <path d="M 100 160 L 100 240"/>
            <path d="M 160 300 L 240 300"/>
            <path d="M 160 100 L 240 100"/>
          </g>
        </g>
        <g inkscape:label="single lines diagonal">
          <g inkscape:label="left">
            <path d="M 0 400 L 58 458"/>
            <path d="M 0 400 L 58 342"/>
          </g>
          <g inkscape:label="right">
            <path d="M 800 400 L 742 458"/>
            <path d="M 800 400 L 742 342"/>
          </g>
          <g inkscape:label="bottom">
            <path d="M 400 800 L 458 742"/>
            <path d="M 400 800 L 342 742"/>
          </g>
          <g inkscape:label="top">
            <path d="M 400 0 L 458 58"/>
            <path d="M 400 0 L 342 58"/>
          </g>
          <path inkscape:label="top right" d="M 800 0 L 742 58"/>
          <path inkscape:label="bottom left" d="M 0 800 L 58 742"/>
          <path inkscape:label="bottom right" d="M 800 800 L 742 742"/>
          <path inkscape:label="top left" d="M 0 0 L 58 58"/>
          <path inkscape:label="center bottom-left to top-right" d="M 458 342 L 342 458"/>
          <path inkscape:label="center top-left to bottom-right" d="M 458 458 L 342 342"/>
        </g>
      </g>
      {% endif %}

      {% if nocircles %}
      {# based on pallas key #}
      <g inkscape:label="pallas key: center cross, top-right square" stroke-width="2" fill="none" stroke="black">
        <g inkscape:label="simple pattern">
          <g inkscape:label="single lines orthogonal: single lines outside squares">
            <g id="nocircles-square-top-right">
              <title>top right square, no circles</title>
              <path d="M 700 100 L 700 300"/>
              <path d="M 500 100 L 500 300"/>
              <path d="M 500 300 L 700 300"/>
              <path d="M 500 100 L 700 100"/>
            </g>
            <use id="nocircles-square-top-left" href="#nocircles-square-top-right" transform="translate(-400 0)" />
            <use id="nocircles-square-bottom-left" href="#nocircles-square-top-right" transform="translate(-400 400)" />
            <use id="nocircles-square-bottom-right" href="#nocircles-square-top-right" transform="translate(0 400)" />
          </g>
          <g id="nocircles-cross-center">
            <path inkscape:label="center bottom-left to top-right" d="M 500 300 L 300 500"/>
            <path inkscape:label="center top-left to bottom-right" d="M 500 500 L 300 300"/>
          </g>
          <use id="nocircles-cross-left" href="#nocircles-cross-center" transform="translate(-400 0)" />
          <use id="nocircles-cross-right" href="#nocircles-cross-center" transform="translate(400 0)" />
          <use id="nocircles-cross-top" href="#nocircles-cross-center" transform="translate(0 -400)" />
          <use id="nocircles-cross-bottom" href="#nocircles-cross-center" transform="translate(0 400)" />
          <use id="nocircles-cross-top-left" href="#nocircles-cross-center" transform="translate(-400 -400)" />
          <use id="nocircles-cross-top-right" href="#nocircles-cross-center" transform="translate(400 -400)" />
          <use id="nocircles-cross-bottom-left" href="#nocircles-cross-center" transform="translate(-400 400)" />
          <use id="nocircles-cross-bottom-right" href="#nocircles-cross-center" transform="translate(400 400)" />
        </g>
      </g>
      {% endif %}

      {% if boxes %}
      <g inkscape:label="boxes Pattern" stroke="black" stroke-width="2" fill="none">

        {% if boxes_320 %}
        <g inkscape:label="boxes 320" stroke="black" stroke-width="2" fill="none">
          <rect x="40" y="40" width="320" height="320"/>
          <rect x="440" y="40" width="320" height="320"/>
          <rect x="440" y="440" width="320" height="320"/>
          <rect x="40" y="440" width="320" height="320"/>
        </g>
        {% else %}
        <g inkscape:label="Squares 360">
          <rect id="boxes-box-top-left" x="20" y="20" width="360" height="360"/>
          <use id="boxes-box-top-right" href="#boxes-box-top-left" transform="translate(400 0)" />
          <use id="boxes-box-bottom-right" href="#boxes-box-top-left" transform="translate(400 400)" />
          <use id="boxes-box-bottom-left" href="#boxes-box-top-left" transform="translate(0 400)" />

          <use id="boxes-box-center" href="#boxes-box-top-left" transform="translate(200 200)" />
          <use id="boxes-box-center-right" href="#boxes-box-center" transform="translate(400 0)" />
          <use id="boxes-box-center-bottom-right" href="#boxes-box-center" transform="translate(400 400)" />
          <use id="boxes-box-center-bottom" href="#boxes-box-center" transform="translate(0 400)" />
          <use id="boxes-box-center-bottom-left" href="#boxes-box-center" transform="translate(-400 400)" />
          <use id="boxes-box-center-left" href="#boxes-box-center" transform="translate(-400 0)" />
          <use id="boxes-box-center-top-left" href="#boxes-box-center" transform="translate(-400 -400)" />
          <use id="boxes-box-center-top" href="#boxes-box-center" transform="translate(0 -400)" />
          <use id="boxes-box-center-top-right" href="#boxes-box-center" transform="translate(400 -400)" />
        </g>
        {% endif %}

        <g inkscape:label="cross top" transform="matrix(1, 0, 0, 1, 0, -400)">
          <g inkscape:label="cross center">
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
          <g inkscape:label="cross right" transform="matrix(1, 0, 0, 1, 400, 0)">
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
          <g inkscape:label="cross left" transform="matrix(1, 0, 0, 1, -400, 0)">
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
        </g>
        <g>
          <title>cross center-y</title>
          <g>
            <title>cross center</title>
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
          <g transform="matrix(1, 0, 0, 1, 400, 0)">
            <title>cross right</title>
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
          <g transform="matrix(1, 0, 0, 1, -400, 0)">
            <title>cross left</title>
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
        </g>
        <g transform="matrix(1, 0, 0, 1, 0, 400)">
          <title>cross bottom</title>
          <g>
            <title>cross center</title>
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
          <g transform="matrix(1, 0, 0, 1, 400, 0)">
            <title>cross right</title>
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
          <g transform="matrix(1, 0, 0, 1, -400, 0)">
            <title>cross left</title>
            <path d="M 420 420 L 380 380"/>
            <path d="M 420 380 L 380 420"/>
          </g>
        </g>
        <g>
          <title>squares small</title>
          <rect x="180" y="180" width="40" height="40"/>
          <rect x="580" y="180" width="40" height="40"/>
          <rect x="180" y="580" width="40" height="40"/>
          <rect x="580" y="580" width="40" height="40"/>
        </g>
      </g>
    {% endif %}
    </g>

    {% if circles %}
    <g inkscape:label="circles and text">
      <g inkscape:label="circles" stroke-width="2" fill="{% if fillcircles %}white{% else %}none{% endif %}" stroke="black">
        <title>Circles</title>
        <circle cx="100" cy="100" r="60"/>
        <circle cx="300" cy="100" r="60"/>
        <circle cx="500" cy="100" r="60"/>
        <circle cx="700" cy="100" r="60"/>
        <circle cx="100" cy="300" r="60"/>
        <circle cx="300" cy="300" r="60"/>
        <circle cx="500" cy="300" r="60"/>
        <circle cx="700" cy="300" r="60"/>
        <circle cx="100" cy="500" r="60"/>
        <circle cx="300" cy="500" r="60"/>
        <circle cx="500" cy="500" r="60"/>
        <circle cx="700" cy="500" r="60"/>
        <circle cx="100" cy="700" r="60"/>
        <circle cx="300" cy="700" r="60"/>
        <circle cx="500" cy="700" r="60"/>
        <circle cx="700" cy="700" r="60"/>
      </g>
      {% if text_4dim %}
      <g inkscape:label="text" dominant-baseline="middle" text-anchor="middle" font-family="sans" font-size="40" fill="black">
        <text x="100" y="100">FPEL</text>
        <text x="300" y="100">MNIL</text>
        <text x="500" y="100">FPIL</text>
        <text x="700" y="100">MNEL</text>
        <text x="100" y="300">FNIS</text>
        <text x="300" y="300">MPES</text>
        <text x="500" y="300">FNES</text>
        <text x="700" y="300">MPIS</text>
        <text x="100" y="500">FNEL</text>
        <text x="300" y="500">MPIL</text>
        <text x="500" y="500">FNIL</text>
        <text x="700" y="500">MPEL</text>
        <text x="100" y="700">FPIS</text>
        <text x="300" y="700">MNES</text>
        <text x="500" y="700">FPES</text>
        <text x="700" y="700">MNIS</text>
      </g>
      {% else %}
      <g inkscape:label="text" dominant-baseline="middle" text-anchor="middle" font-family="sans" font-size="40" fill="black">
        <text x="100" y="100">F1L</text>
        <text x="300" y="100">M2L</text>
        <text x="500" y="100">F4L</text>
        <text x="700" y="100">M3L</text>
        <text x="100" y="300">F2S</text>
        <text x="300" y="300">M1S</text>
        <text x="500" y="300">F3S</text>
        <text x="700" y="300">M4S</text>
        <text x="100" y="500">F3L</text>
        <text x="300" y="500">M4L</text>
        <text x="500" y="500">F2L</text>
        <text x="700" y="500">M1L</text>
        <text x="100" y="700">F4S</text>
        <text x="300" y="700">M3S</text>
        <text x="500" y="700">F1S</text>
        <text x="700" y="700">M2S</text>
      </g>
      {% endif %}
    </g>
    {% endif %}

    {% if development %}
    <g inkscape:label="development helper grids">
      <circle inkscape:label="top left circle" cx="200" cy="200" r="140" fill="none" stroke="red" />
      <g inkscape:label="Grid centers" stroke="red" stroke-width="2">
        <path d="M 0 500 L 800 500"/>
        <path d="M -100 400 L 700 400" transform="matrix(0, 1, -1, 0, 700, 100)"/>
        <path d="M 100 400 L 900 400" transform="matrix(0, 1, -1, 0, 900, -100)"/>
        <path d="M 300 400 L 1100 400" transform="matrix(0, 1, -1, 0, 1100, -300)"/>
        <path d="M -300 400 L 500 400" transform="matrix(0, 1, -1, 0, 500, 300)"/>
        <path d="M 0 100 L 800 100"/>
        <path d="M 0 700 L 800 700"/>
        <path d="M 0 300 L 800 300"/>
      </g>
      <g inkscape:label="Grid between" stroke="red" stroke-width="2">
        <path d="M 0 400 L 800 400"/>
        <path d="M 0 400 L 800 400" transform="matrix(0, 1, -1, 0, 800, 0)"/>
        <path d="M 200 400 L 1000 400" transform="matrix(0, 1, -1, 0, 1000, -200)"/>
        <path d="M -200 400 L 600 400" transform="matrix(0, 1, -1, 0, 600, 200)"/>
        <path d="M 0 600 L 800 600"/>
        <path d="M 0 200 L 800 200"/>
      </g>
    </g>
    {% endif %}
  </g>
</svg>
