JQ动态粒子效果

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    </head>
    <!-- 注意:style和script都包含在body内部,否则会导致代码无样式效果以及js事件无法实现 -->
    <body>
        <div id="jsi-particle-container" class="container">
            <!-- 创建画布 -->
            <canvas width="100%" height="100%" style="align:center;"></canvas><!--canvas标签定义图形,必须使用脚本来绘制图形-->
        </div>
        
        <style>
            html,body {
                width: 100%;
                height: 100%;
                margin: 0;
                padding: 0;
                overflow: hidden; 
                /*overflow属性指定如果内容溢出一个元素的框,会发生什么  其属性值hidden表示内容会被修建,并且其余内容是不可见的*/
                /* overflow属性值:
                    visible  默认值,内容不会被修剪,会呈现在元素框之外
                    hidden 内容会被修剪,并且其余内容是不可见的
                    scroll  内容会被修剪,但是浏览器会显示滚动条以便查看其他内容
                    auto  若内容被修剪,则浏览器会显示滚动条
                    inherit  规定应该从父元素继承overflow属性的值
                    
                    注意:overflow属性只工作于指定高度的块元素上
                 */
            }
            .container{
                width: 100%;
                height: 100%;
                margin: 0;
                padding: 0;
                background-color: #000000;
            }
        </style>
        
        <script>
            //绘制图形
            var RENDERER = {
                PARTICLE_COUNT : 1000,
                PARTICLE_RADIUS : 1,
                MAX_ROTATION_ANGLE : Math.PI / 60,
                TRANSLATION_COUNT : 10000,
                
                //函数体汇总
                init : function(strategy){
                    this.setParameters(strategy);
                    this.createParticles();
                    this.setupFigure();
                    this.reconstructMethod();
                    this.bindEvent();
                    this.drawFigure();
                },
                //窗口响应事件,图形大小控制
                setParameters : function(strategy){
                    this.$window = $(window);
                    
                    //调用html中的样式
                    this.$container = $('#jsi-particle-container');
                    this.width = this.$container.width();
                    this.height = this.$container.height();
                    
                    this.$canvas = $('<canvas />').attr({width : this.width, height : this.height}).appendTo(this.$container);
                    this.context = this.$canvas.get(0).getContext('2d');//2D动画
                    
                    th

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值