svg图形

来源:互联网 发布:windows主辅域搭建 编辑:程序博客网 时间:2024/05/16 19:50
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


</head>
<body>
<script type="text/javascript">
function draw() {
var a = 45, b = 22, x0 = 10;
var u = [];
   for (var i =-30; i < 30;i++ ) {
var y = (1 - i*i/(a*a)) *  b*b;
y = Math.sqrt(y);
//移动
var x=i+200;
y=70+y;
u.push(x + ',' + y.toFixed(0))
}
var a = 50, b = 25, x0 = 10;
for (var i =40; i > -40;i-- ) {
var y = (1 - i*i/(a*a)) *  b*b;
y = Math.sqrt(y);
//移动
var x=i+200;
y=100+y;
u.push(x + ',' + y.toFixed(0))
}
point = u.join(" ")
document.getElementById("polygon").setAttribute("points", point)
document.getElementById("polygon2").setAttribute("points", point)


}
window.onload = draw


</script>
<div id="div"></div>
<svg id="ad" width="750" height="300" version="1.1" xmlns="http://www.w3.org/2000/svg">

<filter  id="Gaussian_Blur">
<feGaussianBlur in="SourceGraphic" stdDeviation="2"/>
</filter>
<linearGradient  id="orange_red" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:#000000;stop-opacity:0.1"/>
<stop offset="15%" style="stop-color:#ffffff;stop-opacity:0.2"/>
<stop offset="85%" style="stop-color:#ffffff;stop-opacity:0.2"/>
<stop offset="100%" style="stop-color:#000000;stop-opacity:0.1"/>
</linearGradient>
<linearGradient  id="red_black" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#ff0000;stop-opacity:1"/>
<stop offset="100%" style="stop-color:#ee0000;stop-opacity:1"/>
</linearGradient>

<ellipse cx="200" cy="82" rx="27" ry="6" style="fill:#ff0000;stroke:#ee0000; stroke-width:2;filter:url(#Gaussian_Blur)"/>
<polygon  id="polygon"  points="" style="fill:#ff0000;stroke:#ee0000; stroke-width:2;filter:url(#Gaussian_Blur)"/>
            
            <polygon  id="polygon2"  points="" style="fill:url(#orange_red)"/>
  


</svg>


</body>


</html>