SVG <g>组样式,属性等

时间:2016-04-30 09:21:41

标签: javascript svg ecmascript-6

我正在设置一些使用Javascript创建的SVG对象,并使用'setAttributeNS'设置对象的X和Y属性。

我还将对象与其他对象放在一起,并使用<g>标签设置笔画,填充等等group =

e.g1 = document.createElementNS(svg, "g" );
e.g1.setAttributeNS(null,"stroke", "#000"); //eye inherits this//
e.g1.setAttributeNS(null,"cy", e.y); //currently not being inherited in group..//
   
e.eye = document.createElementNS(svg, "ellipse");
e.eye.setAttributeNS(null,"cx", e.x);
e.eye.setAttributeNS(null,"cy", e.y); //I want to set this from group so i can remove this line from all objects on the groups y axis//
document.getElementById("mySVG").appendChild(e.eye);


e.g1.appendChild (e.eye);

这对于样式来说很有效,但有没有办法分享X和Y值等属性,所以所有svg对象都设置在它们所在的组中的Y轴,除非它们已被赋予自己的Y轴(只是喜欢风格如何工作)。

由于

0 个答案:

没有答案