在js中java math.ceill*0xefffff+0x0fffff.tostring是什么意思

网页设计教程与开发
提供各种常见网页效果
提供各种各样的设计教程
装扮QQ,让QQ变得更酷
设计参考,提高自升水平
学习服务器和操作系统
提供各种素材和工具
收藏学习资料
您现在的位置:&&>>&&>>&&>>&&>>&正文
原生Js实现简易烟花爆炸效果的方法教程
本文实例讲述了原生Js实现简易烟花爆炸效果的方法。分享给大家供大家参考。具体分析如下:
实现原理: 在一定范围内,随机生成一些div,形成烟花效果
代码如下:&!doctype html&
&meta charset="utf-8"&
&title&js烟花效果&/title&
&script type="text/javascript"&
document.onclick=function (ev)
&&& var oEvent=ev||
&&& var aDiv=[];
&&& var oDiv=
&&& var _oDiv=document.createElement('div');
&&& var i=0;
&&& var x=oEvent.clientX;
&&& var y=oEvent.clientY;
&&& _oDiv.style.position='absolute';
&&& _oDiv.style.background='red';
&&& _oDiv.style.width='3px';
&&& _oDiv.style.height='30px';
&&& _oDiv.style.left=oEvent.clientX+'px';
&&& _oDiv.style.top=document.documentElement.clientHeight+'px';
&&& document.body.appendChild(_oDiv);
&&& var t=setInterval(function (){
&&&&&&& if(_oDiv.offsetTop&=y)
&&&&&&&&&&& clearInterval(t);
&&&&&&&&&&& show();
&&&&&&&&&&& document.body.removeChild(_oDiv);
&&&&&&& _oDiv.style.top=_oDiv.offsetTop-30+'px';
&&& }, 30);
&&& function show()
&&&&&&& var oDiv=
&&&&&&& for(i=0;i&100;i++)
&&&&&&&&&&& oDiv=document.createElement('div');
&&&&&&&&&&& oDiv.style.width='3px';
&&&&&&&&&&& oDiv.style.height='3px';
&&&&&&&&&&& oDiv.style.background='#'+Math.ceil(Math.random()*0xEFFFFF+0x0FFFFF).toString(16);
&&&&&&&&&&& oDiv.style.position='absolute';
&&&&&&&&&&& oDiv.style.left=x+'px';
&&&&&&&&&&& oDiv.style.top=y+'px';
&&&&&&&&&&& var a=Math.random()*360;
&&&&&&&&&&& //oDiv.speedX=Math.random()*40-20;
&&&&&&&&&&& //oDiv.speedY=Math.random()*40-20;
&&&&&&&&&&& oDiv.speedX=Math.sin(a*180/Math.PI)*20*Math.random();
&&&&&&&&&&& oDiv.speedY=Math.cos(a*180/Math.PI)*20*Math.random();
&&&&&&&&&&& document.body.appendChild(oDiv);
&&&&&&&&&&& aDiv.push(oDiv);
&&& setInterval(doMove, 30);
&&& function doMove()
&&&&&&& for(i=0;i&aDiv.i++)
&&&&&&&&&&& aDiv[i].style.left=aDiv[i].offsetLeft+aDiv[i].speedX+'px';
&&&&&&&&&&& aDiv[i].style.top=aDiv[i].offsetTop+aDiv[i].speedY+'px';
&&&&&&&&&&& aDiv[i].speedY+=1;
&&&&&&&&&&& if(aDiv[i].offsetLeft&0 || aDiv[i].offsetLeft&document.documentElement.clientWidth || aDiv[i].offsetTop&0 || aDiv[i].offsetTop&document.documentElement.clientHeight)
&&&&&&&&&&& {
&&&&&&&&&&&&&&& document.body.removeChild(aDiv[i]);
&&&&&&&&&&&&&&& aDiv.splice(i, 1);
&&&&&&&&&&& }
&body style="overflow: background:"&
希望本文所述对大家的javascript程序设计有所帮助。
转载请注明:破洛洛(谢谢合作)
上一篇文章: 下一篇文章:
网友评论:
[][][][][][][][][][]一个js的问题,。麻烦各位棒棒忙。谢谢_百度知道
一个js的问题,。麻烦各位棒棒忙。谢谢
0'javascript&quot.offsetTop-20+'html&style'UTF-8&css&style&
oDiv.createElement(&px' 20.toString(16).style.clientHeight+'
body{4px'div1&
oDiv.createElement(&#39.
div{position.div id=&quot.width='&#47.height='&body&gt.width=&#39: absolute.background=',30);/+;
for (var i = 0;
oDstyle type=&&
var t=oE&#'
aD/2px&#39.top=oD;script&显示oDiv.offsetTop-20+'
} } &&#47.left=oEvent。代码错误提示是Cannot read property 'div&quot.clientX;px';
timer=setInterval(function(){
oDiv:div' &.length&;& &;&&gt.offsetTop&30px'.
};&#47.random()*);&gt.top=oDiv.clientX+'/ &lt.background='script type=&/).appendChild(oDiv).clientY. &lt.
oD+getRnd();
oDiv!DOCTYPE html&gt.style.left=l+'px&#39.height='px&#39.title&text/body&gt.&#47.这条代码有错误;
function getRnd(){
var str=M);title&gt. &6){
srt=&#39.push(oDiv); i &lt.
document.removeChild(oDiv);&lt.ceil(M;&
oDiv.documentEpx'&red'&
} &/;;html lang=&2px'
var timer=
oDiv: hidden&div&gt.meta charset=&
var aDiv=[]. i++) {
var oDiv=px'alert(str)./
while(text/head&gt.onclick=function(ev){
var oEvent=ev||event.appendChild(oDiv).top=t+&#39.top==t){
clearInterval(timer);&en&&lt
为什么会报错?
0'javascript&quot.offsetTop-20+'html&style'UTF-8&css&style&
oDiv.createElement(&px' 20.toString(16).style.clientHeight+'
body{4px'div1&
oDiv.createElement(&#39.
div{position.div id=&quot.width='&#47.height='&body&gt.width=&#39: absolute.background=',30);/+;
for (var i = 0;
oDstyle type=&&
var t=oE&#'
aD/2px&#39.top=oD;script&显示oDiv.offsetTop-20+'
} } &&#47.left=oEvent。代码错误提示是Cannot read property 'div&quot.clientX;px';
timer=setInterval(function(){
oDiv:div' &.length&;& &;&&gt.offsetTop&30px'.
};&#47.random()*);&gt.top=oDiv.clientX+'/ &lt.background='script type=&/).appendChild(oDiv).clientY. &lt.
oD+getRnd();
oDiv!DOCTYPE html&gt.style.left=l+'px&#39.height='px&#39.title&text/body&gt.&#47.这条代码有错误;
function getRnd(){
var str=M);title&gt. &6){
srt=&#39.push(oDiv); i &lt.
document.removeChild(oDiv);&lt.ceil(M;&
oDiv.documentEpx'&red'&
} &/;;html lang=&2px'
var timer=
oDiv: hidden&div&gt.meta charset=&
var aDiv=[]. i++) {
var oDiv=px'alert(str)./
while(text/head&gt.onclick=function(ev){
var oEvent=ev||event.appendChild(oDiv).top=t+&#39.top==t){
clearInterval(timer);&en&&lt
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁小伙伴出错了原生Js实现简易烟花爆炸效果的方法
本文实例讲述了原生Js实现简易烟花爆炸效果的方法。分享给大家供大家参考。具体分析如下:
实现原理: 在一定范围内,随机生成一些div,形成烟花效果
&!doctype html&
&meta charset=”utf-8″&
&title&js烟花效果&/title&
&script type=”text/javascript”&
document.onclick=function (ev)
&&& var oEvent=ev||
&&& var aDiv=[];
&&& var oDiv=
&&& var _oDiv=document.createElement(‘div’);
&&& var i=0;
&&& var x=oEvent.clientX;
&&& var y=oEvent.clientY;
&&& _oDiv.style.position=’absolute’;
&&& _oDiv.style.background=’red’;
&&& _oDiv.style.width=’3px’;
&&& _oDiv.style.height=’30px’;
&&& _oDiv.style.left=oEvent.clientX+’px’;
&&& _oDiv.style.top=document.documentElement.clientHeight+’px’;
&&& document.body.appendChild(_oDiv);
&&& var t=setInterval(function (){
&&&&&&& if(_oDiv.offsetTop&=y)
&&&&&&&&&&& clearInterval(t);
&&&&&&&&&&& show();
&&&&&&&&&&& document.body.removeChild(_oDiv);
&&&&&&& _oDiv.style.top=_oDiv.offsetTop-30+’px’;
&&& }, 30);
&&& function show()
&&&&&&& var oDiv=
&&&&&&& for(i=0;i&100;i++)
&&&&&&&&&&& oDiv=document.createElement(‘div’);
&&&&&&&&&&& oDiv.style.width=’3px’;
&&&&&&&&&&& oDiv.style.height=’3px’;
&&&&&&&&&&& oDiv.style.background=’#’+Math.ceil(Math.random()*0xEFFFFF+0x0FFFFF).toString(16);
&&&&&&&&&&& oDiv.style.position=’absolute’;
&&&&&&&&&&& oDiv.style.left=x+’px’;
&&&&&&&&&&& oDiv.style.top=y+’px’;
&&&&&&&&&&& var a=Math.random()*360;
&&&&&&&&&&& //oDiv.speedX=Math.random()*40-20;
&&&&&&&&&&& //oDiv.speedY=Math.random()*40-20;
&&&&&&&&&&& oDiv.speedX=Math.sin(a*180/Math.PI)*20*Math.random();
&&&&&&&&&&& oDiv.speedY=Math.cos(a*180/Math.PI)*20*Math.random();
&&&&&&&&&&& document.body.appendChild(oDiv);
&&&&&&&&&&& aDiv.push(oDiv);
&&& setInterval(doMove, 30);
&&& function doMove()
&&&&&&& for(i=0;i&aDiv.i++)
&&&&&&&&&&& aDiv[i].style.left=aDiv[i].offsetLeft+aDiv[i].speedX+’px’;
&&&&&&&&&&& aDiv[i].style.top=aDiv[i].offsetTop+aDiv[i].speedY+’px’;
&&&&&&&&&&& aDiv[i].speedY+=1;
&&&&&&&&&&& if(aDiv[i].offsetLeft&0 || aDiv[i].offsetLeft&document.documentElement.clientWidth || aDiv[i].offsetTop&0 || aDiv[i].offsetTop&document.documentElement.clientHeight)
&&&&&&&&&&& {
&&&&&&&&&&&&&&& document.body.removeChild(aDiv[i]);
&&&&&&&&&&&&&&& aDiv.splice(i, 1);
&&&&&&&&&&& }
&body style=”overflow: background:”&
希望本文所述对大家的javascript程序设计有所帮助。
相关文章:
暂时还没有评论.}

我要回帖

更多关于 javascript math.ceil 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信