• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

精彩:JS画的图形[Good篇]

发布: 2007-7-01 20:40 | 作者: admin | 来源: | 查看: 28次 | 进入软件测试论坛讨论

领测软件测试网

<!--
如果您想在线看看效果:
-->
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>test</title>
</head>
<STYLE>
 v\:* { BEHAVIOR: url(#default#VML) }
</STYLE>

<body>

<v:group ID="group1"

style="position:relative;WIDTH:800px;HEIGHT:600px;top:0;left:0;"

CoordOrig="-500,-500" coordsize="1000,1000">
<v:RoundRect style="position:relative;z-index:1;left:-600px;top:-

580;width:1100px;height:1100px"  fillcolor="#cccccc">
<v:shadow on="T" type="single" color="#b3b3b3" offset="5px,5px"/>
</v:RoundRect>
<script>

function line(x, y, x1, y1, n)
{
   document.write("<v:line from=\"" + (x - n) + "," + y + "\" to=\"" +

(x1 - n) + "," + y1 + "\" style=\"position:relative;top:-80;left:-50;z

-index:9999;\" strokeweight=\"1pt\"></v:line>");
   //  StrokeColor=Rgb(\"" + Math.round(Math.random() * 255 ) + "," +

Math.round(Math.random() * 255) + "," + Math.round(Math.random() * 255

) +")
}

var i, j, a;
var length = 1000;      // 方块边长
var n = 60, theta = 3;  // 每个方块里画子方块的个数,偏移角度值
var x = 300, y = 300;   // 原始坐标位置
var py = 800;           // x 偏移值

function polygonc(x0, y0, r, n, af)
{
  var x, y, xs, ys, i, dtheta, theta;

  if(n < 3)return;
  dtheta = 6.28318 / n;
  theta = af * 0.0174533;
  xs = x0 + r * Math.cos(theta);
  ys = y0 + r * Math.sin(theta);
  var xo = xs, yo = ys;
  for ( i = 1; i < n; i++)
  {
    theta += dtheta;
    x = x0 + r * Math.cos(theta);
    y = y0 + r * Math.sin(theta);
    line(xs, ys, x, y, py);
 xs = x;
 ys = y;
  }
  line(xs, ys, xo, yo, py);
}

function block(x, y, a, n, theta)
{
  var x0, y0, i, r, t, f, af = 45;
  t = Math.abs(theta * 0.0174533);
  f = 1 / (Math.cos(t) + Math.sin(t));
  r = a / 1.414;
  x0 = x + 0.5 * a;
  y0 = y + 0.5 * a;
  for (i = 1; i <= n; i++)
  {
     polygonc(x0, y0, r, 4, af);
     r = r * f;
     af -= theta;
  }
}

a = length /4;
for (i = 1; i <= 4; i++)
{
  for (j = 1; j <= 4; j++)
  {
    block(x, y, a, n, theta);
    theta = 0 - theta;
    x += a;
  }
  x = 300;
  y -= a;
  theta = 0 - theta
}

</script>
</v:group>
</body>
</html>


延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网