SVG-координаты в VML-координаты - PullRequest
2 голосов
/ 11 мая 2010

У меня есть файл SVG

<svg 
    xmlns="http://www.w3.org/2000/svg" 
    xml:space="preserve" width="200px" 
    height=""
    style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
    viewBox="0 0 69.1341 93.4405"
    xmlns:xlink="http://www.w3.org/1999/xlink">
...
<path class="fil3 str0" d="M49.1257 35.5851c3.029,0.890254 7.2612,0.610968 12.3164,-0.468419 -5.13373,3.85796 -12.1161,4.96333 -19.7673,5.07307"/>
... 
</svg>

Я пытаюсь преобразовать его в VML вручную, и я получаю

<body>
...
<v:group style="position: absolute;
                left: 0pt;
                top: 0pt; 
                width: 200px;
                height: 200px;
                z-index: -56;"
                coordsize="100000 100000"
                coordorigin="0 0" id="Слой_x0020_1">

<v:shape path="m 491257,355851 nf v 30290,8903 72612,6110 123164,-4684 -51337,38580 -121161,49633 -197673,50731 e" 
   strokeweight="0.126615" 
   fill="false" 
   style="width: 200px; 
   height: 200px;" 
   coordorigin="-100000 -100000" 
   class="fil3 str0"></v:shape>
...
</body>

Проблема: я получаю изображение в неправильном масштабе

Вопрос: как правильно преобразовать svg-размеры / координаты в vml-размеры / координаты

Ответы [ 2 ]

3 голосов
/ 12 мая 2010

хорошо, это просто

у нас есть

<svg 
    xmlns="http://www.w3.org/2000/svg" 
    xml:space="preserve" width="200px" 
    height=""
    style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
    viewBox="0 0 69.1341 93.4405"
    xmlns:xlink="http://www.w3.org/1999/xlink">
...
<path class="fil3 str0" d="M49.1257 35.5851c3.029,0.890254 7.2612,0.610968 12.3164,-0.468419 -5.13373,3.85796 -12.1161,4.96333 -19.7673,5.07307"/>
... 
</svg>

69,1341 / 200 = 0,3456705

круглый (0,3456705 * 10000) = 3456

это 3456 "некоторых единиц" на пиксель

в vml равно "width: 1px; height: 1px" иordinsize = "3456 3456"

результат

<body>
...
<v:group style="position: absolute;
                left: 0pt;
                top: 0pt; 
                width: 1px;
                height: 1px;
                z-index: -56;"
                coordsize="1 1"
                coordorigin="0 0" id="Слой_x0020_1">

<v:shape path="m 491257,355851 nf v 30290,8903 72612,6110 123164,-4684 -51337,38580 -121161,49633 -197673,50731 e" 
   strokeweight="0.126615" 
   fill="false" 
   style="width: 1px; height: 1px;" 
   coordorigin="-100000 -100000" 
   coordsize="3456 3456"
   class="fil3 str0"></v:shape>
...
</body>
1 голос
/ 27 июня 2011

Вот облегченная библиотека, которая преобразует пути SVG в пути VML Преобразование SVG в VML с помощью Core Framework

...