<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>svgdom实现g元素的变形操作</title>
<style>
#myg{
border: 1px solid red;
width: 200px;
height: 200px;
}
</style>
<script src="js/raphael.js"></script>
<script>
function createEleG(){
var root=document.getElementByIdx_x("myg");
var paper=Raphael(root,200,200);
var st=paper.set();
for(var i=0;i<3;i++){
st.push(paper.rect(10+50*i,10+50*i,40,40,10));
}
//变形部分
st.translate(50,10);
st.rotate(45,50,50);
st.scale(0.5);
st.attr("fill","YellowGreen");
st.attr("stroke","none");
}
</script>
</head>
<body οnlοad="createEleG()">
<h3>Raphael实现g元素的变形操作</h3>
<div id="myg"></div>
</body>
</html>