精彩:JS畫的圖形[金剛石篇] (轉)

amyz發表於2007-11-16
精彩:JS畫的圖形[金剛石篇] (轉)[@more@]

<!--
如果您想線上看看效果:/test/1.htm">
--&gt
ns:v="urn:schemas--com:vml">







function line(x, y, x1, y1, n)
{
  document.write("");
  //  StrokeColor=Rgb("" + Math.round(Math.ran() * 255 ) + "," + Math.round(Math.random() * 255) + "," + Math.round(Math.random() * 255 ) +")
}

var n = 30, r = 346, t = 6.28318 / n, x0 = 300, y0 = 300;

var x = new Array();
var y = new Array();

for (var i = 0; i < n; i++)
{
  x[i] = r * Math.cos(i * t) + x0;
  y[i] = r * Math.sin(i * t) + y0;
}
for (var i = 0; i < n - 2; i++)
  for (var j = i + 1; j <= n - 1; j++)
  line(x[i], y[i], x[j], y[j], 500);




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-982686/,如需轉載,請註明出處,否則將追究法律責任。

相關文章