在将svg图形格式转化为其它格式图形的工作中,坐标变换是首当其冲的一件工作,下面我们结合svg规范看看svg
是如何处理坐标变换的,理解了这些,再将其转化成你想要的图形格式的变换方式也就不困难了。
1.svg采用的初始坐标系统是视图坐标系,即屏幕左上角为左边原点,y轴正方向朝下,x轴正方向朝右
2.The value of the transform attribute is a <transform-list>, which is defined as a list of transform definitions, which are applied in the order provided.
transform属性的值是一个变换列表,它们将根据在svg文件中的顺序依次起作用。
解析transform值时,一定要根据各个变换出现的顺序进行处理,而不能根据变换的类型进行处理。
3.The transform attribute is applied to an element before processing any other coordinate or length values supplied for that element. In the element
<rect x="10" y="10" width="20" height="20" transform="scale(2)"/>
the x, y, width and height values are processed after the current coordinate system has been scaled uniformly by a factor of 2 by the transform attribute.