js实现的心性

 <html>
    <head><title>Love</title></head> 

  <body bgcolor=#FFC0CB> 

      <script type="text/javascript"> 
       var d = document; 
          canvas = d.body.appendChild( d.createElement( 'canvas' ) ); 
            context = canvas.getContext( '2d' ); 

           time = 0; 

          canvas.width = w = innerWidth; 

          canvas.height = h = innerHeight; 

           cos = Math.cos; 

          sin = Math.sin; 

           abs = Math.abs; 

            pow = Math.pow; 

             PI = Math.PI; 

             setInterval( function() { 

                context.clearRect( 0, 0, w, h ); 

                context.fillStyle = 'rgba(138,43,226,0.5)'; 

                context.globalCompositeOperation = 'lighter'; 

                time += 0.5; 

                i = 20000; 

              while( i-- ) { 

                  r = ( ( w + h ) * 0.4 ) * ( cos( ( time + i ) * ( 0.05 + sin( time * 0.00005 ) ) ) / 4.0 ); 

                    t = ( i - 10000.0 ) / 10000.0 * PI; 

                    x = cos( t ) * r; 

                   y = ( pow( cos( t ) , 2.0 / 3.0 ) + sin( t ) ) * r; 

                    if( x < 0 ){ 

                        context.fillRect( x + w / 2 , y + h / 5 * 3 , 1 , 1 ); 

                      context.fillRect( -x + w / 2 , y + h / 5 * 3 , 1 , 1 ); 
                   } 

               } 
          }, 16 ); 

      </script> 
   </body> 

 </html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值