Javascript JQuery光点闪烁,如何实现它,是否有类似的东西准备好了?

Javascript JQuery光点闪烁,如何实现它,是否有类似的东西准备好了?,javascript,jquery,css,Javascript,Jquery,Css,我在这个网站上没有他的影响 这里有一个闪光点,在悬停时你得到背景,我想要一些类似的东西而不用闪光灯 这就是我现在使用的脚本 /* Particle Emitter JavaScript Library Version 0.3 by Erik Friend Creates a circular particle emitter of specified radius centered and offset at specified screen location. Particles appe

我在这个网站上没有他的影响 这里有一个闪光点,在悬停时你得到背景,我想要一些类似的东西而不用闪光灯 这就是我现在使用的脚本

/*
Particle Emitter JavaScript Library
Version 0.3
by Erik Friend

Creates a circular particle emitter of specified radius centered and offset at specified screen location.  Particles appear outside of emitter and travel outward at specified velocity while fading until disappearing in specified decay time.  Particle size is specified in pixels.  Particles reduce in size toward 1px as they decay.  A custom image(s) may be used to represent particles.  Multiple images will be cycled randomly to create a mix of particle types.

example:
var emitter = new particle_emitter({
    image: ['resources/particle.white.gif', 'resources/particle.black.gif'],
    center: ['50%', '50%'], offset: [0, 0], radius: 0,
    size: 6, velocity: 40, decay: 1000, rate: 10
}).start();
*/

particle_emitter = function (opts) {
    // DEFAULT VALUES
    var defaults = {
        center: ['50%', '50%'], // center of emitter (x / y coordinates)
        offset: [0, 0],         // offset emitter relative to center
        radius: 0,              // radius of emitter circle
        image: 'particle.gif',  // image or array of images to use as particles
        size: 1,                // particle diameter in pixels
        velocity: 10,           // particle speed in pixels per second
        decay: 500,             // evaporation rate in milliseconds
        rate: 10                // emission rate in particles per second
    };
    // PASSED PARAMETER VALUES
    var _options = $.extend({}, defaults, opts);

    // CONSTRUCTOR
    var _timer, _margin, _distance, _interval, _is_chrome = false;
    (function () {
        // Detect Google Chrome to avoid alpha transparency clipping bug when adjusting opacity
        if (navigator.userAgent.indexOf('Chrome') >= 0) _is_chrome = true;

        // Convert particle size into emitter surface margin (particles appear outside of emitter)
        _margin = _options.size / 2;

        // Convert emission velocity into distance traveled
        _distance = _options.velocity * (_options.decay / 1000);

        // Convert emission rate into callback interval
        _interval = 1000 / _options.rate;
    })();

    // PRIVATE METHODS
    var _sparkle = function () {
        // Pick a random angle and convert to radians
        var rads = (Math.random() * 360) * (Math.PI / 180);

        // Starting coordinates
        var sx = parseInt((Math.cos(rads) * (_options.radius + _margin)) + _options.offset[0] - _margin);
        var sy = parseInt((Math.sin(rads) * (_options.radius + _margin)) + _options.offset[1] - _margin);

        // Ending Coordinates
        var ex = parseInt((Math.cos(rads) * (_options.radius + _distance + _margin + 0.5)) + _options.offset[0] - 0.5);
        var ey = parseInt((Math.sin(rads) * (_options.radius + _distance + _margin + 0.5)) + _options.offset[1] - 0.5);

        // Pick from available particle images
        var image;
        if (typeof(_options.image) == 'object') image = _options.image[Math.floor(Math.random() * _options.image.length)];
        else image = _options.image;

        // Attach sparkle to page, then animate movement and evaporation
        var s = $('<img>')
        .attr('src', image)
        .css({
            zIndex:     10,
            position:   'absolute',
            width:      _options.size + 'px',
            height:     _options.size + 'px',
            left:       _options.center[0],
            top:        _options.center[1],
            marginLeft: sx + 'px',
            marginTop:  sy + 'px'
        })
        .appendTo('body')
        .animate({
            width: '1px',
            height: '1px',
            marginLeft: ex + 'px',
            marginTop: ey + 'px',
            opacity: _is_chrome ? 1 : 0
        }, _options.decay, 'linear', function () { $(this).remove(); });

        // Spawn another sparkle
        _timer = setTimeout(function () { _sparkle(); }, _interval);
    };

    // PUBLIC INTERFACE
    // This is what gets returned by "new particle_emitter();"
    // Everything above this point behaves as private thanks to closure
    return {
        start:function () {
            clearTimeout(_timer);
            _timer = setTimeout(function () { _sparkle(); }, 0);
            return(this);
        },
        stop:function () {
            clearTimeout(_timer);
            return(this);            
        },
        centerTo:function (x, y) {
            _options.center[0] = x;
            _options.center[1] = y;
        },
        offsetTo:function (x, y) {
            if ((typeof(x) == 'number') && (typeof(y) == 'number')) {
                _options.center[0] = x;
                _options.center[1] = y;
            }
        }
    }
};
/*
粒子发射器JavaScript库
版本0.3
埃里克·弗里德
在指定的屏幕位置创建具有指定半径中心和偏移的圆形粒子发射器。粒子出现在发射器外部,并以指定的速度向外移动,同时衰减,直到在指定的衰减时间内消失。粒子大小以像素为单位指定。当粒子衰变时,其尺寸减小到1px。自定义图像可用于表示粒子。将随机循环多个图像以创建粒子类型的混合。
例子:
var发射器=新粒子\发射器({
图像:['resources/particle.white.gif','resources/particle.black.gif'],
中心:['50%','50%],偏移量:[0,0],半径:0,
尺寸:6,速度:40,衰减:1000,速率:10
}).start();
*/
粒子发射器=函数(opts){
//默认值
var默认值={
中心:['50%,'50%,//发射器的中心(x/y坐标)
偏移:[0,0],//相对于中心偏移发射器
半径:0,//发射器圆的半径
image:'particle.gif',//要用作粒子的图像或图像数组
大小:1,//粒子直径(像素)
速度:10,//粒子速度(像素/秒)
衰减:500,//蒸发率(毫秒)
速率:10//发射速率(以粒子/秒为单位)
};
//传递的参数值
var_options=$.extend({},默认值,opts);
//建造师
变量计时器、边距、距离、间隔为假;
(功能(){
//检测Google Chrome以避免在调整不透明度时出现alpha透明剪裁错误
如果(navigator.userAgent.indexOf('Chrome')>=0)\u为\u Chrome=true;
//将粒子大小转换为发射器曲面边距(粒子出现在发射器外部)
_保证金=_options.size/2;
//将发射速度转换为行驶距离
_距离=_options.velocity*(_options.decation/1000);
//将排放率转换为回调间隔
_间隔=1000/_.rate;
})();
//私有方法
var_sparkle=函数(){
//拾取随机角度并转换为弧度
var rads=(Math.random()*360)*(Math.PI/180);
//起始坐标
var sx=parseInt((Math.cos(rads)*(_options.radius+_margin))+_options.offset[0]-_margin);
var sy=parseInt((Math.sin(rads)*(_options.radius+_margin))+_options.offset[1]-_margin);
//终点坐标
var ex=parseInt((数学cos(rads)*(_options.radius+_distance+_margin+0.5))+_options.offset[0]-0.5);
var ey=parseInt((数学sin(rads)*(_options.radius+_distance+_margin+0.5))+_options.offset[1]-0.5);
//从可用的粒子图像中拾取
var图像;
if(typeof(_options.image)='object')image=_options.image[Math.floor(Math.random()*_options.image.length)];
else image=_options.image;
//将火花附加到页面,然后设置移动和蒸发的动画

var s=$('您可能需要这样的东西:

您已经尝试了什么?