简体   繁体   English

绝对和相对SVG路径有什么区别?

[英]What is the difference between absolute and relative SVG path?

I know that capital letter for absolute and lower letter for relative but I don't understand the difference between both of them and when I can use each kind. 我知道大写字母代表绝对字母,小写字母代表相对字母,但是我不理解两者之间的区别以及何时可以使用每种字母。

For example : This example give me different shapes when i use capital letter and lower one. 例如:当我使用大写字母和小写字母时,此示例给我不同的形状。

<svg height="210" width="400">
    <path d="M150 0 L75 200 L225 200 Z" />
</svg>

With relative (lower case) commands, the coordinates are calculated relative to the endpoint of the last path segment. 使用相对(小写)命令,相对于最后路径段的端点计算坐标。

So in the case of your path: 因此,就您的路径而言:

M 150 0
L 75 200
L 225 200
Z

the path passes through the coordinates as listed. 路径通过列出的坐标。

However with relative commands you would get the following actual coordinates: 但是,使用相对命令,您将获得以下实际坐标:

              Actual         How this was calculated
             --------------- --------------------------------------
m 150 0       (150, 0)       (0 + 150, 0 + 0)
l 75 200      (225, 200)     (150 + 75, 0 + 200)     (ie. lastX + thisX, lastY + thisY)
l 225 200     (450, 400)     (225 + 225, 200 + 200)
z                            (Z and z have identical behaviour)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM