/* * lib physical v0.1 beta build 090301 copyright (c) 2009 ilwave ce. http://ilwave.spaces.live.com * * this class is part of lib - a javascript library which is still on designing, and is an extend copy of class "object" in lib. * before using this class, you might include lib.common.js and lib.physical.js first. * * 注意:本类需要 lib.common.js 的支持。 * */ var physical = object.extend({ /* * 平滑滚动,生成坐标数组 * * nfrom 滚动起点 * nto 滚动终点 * nsteps 平滑度,越大越平滑 * ntype 滚动类型 0 = 先快后慢, 1 = 先慢后快再慢 * */ smooth: function(nfrom, nto, nsteps, ntype) { var arrlist = []; switch (ntype) { case 1: { var npt = 0, ndata = 0; for (var i=1; i<=nsteps; i++) { npt = i/nsteps; npt != 0.5 && arrlist.push(nfrom + (nto - nfrom) * ((math.sqrt(math.abs(2 * npt - 1)) * (2 * npt - 1) / math.abs(2 * npt - 1) + 1) / 2)); } break; } default: { for (var i=1; i<=nsteps; i++) { arrlist.push(nfrom + (nto - nfrom) * math.sqrt(i / nsteps)); } } } return arrlist; } });