图像作为基于javascript的粒子网络效果的节点?

时间:2016-12-03 12:26:00

标签: javascript css3 web particle-system

我正在尝试创建一个基于javascript的粒子网络,将我自己的20个圆形图像作为其20个不同的节点。

我尝试过使用各种可用的库并在此过程中修改它们但尚未成功 - http://vincentgarreau.com/particles.js/这个库是我能找到的最接近的库,并且可以自定义我的解决方案。

任何指针肯定会有所帮助。

谢谢!

1 个答案:

答案 0 :(得分:0)

请参阅下面编辑的particle.js文件以供我实施。

    particlesJS('particles-js',
    {
     "particles": {
     "number": {
      "value": 80,
      "density": {
        "enable": true,
        "value_area": 800
      }
    },
    "color": {
      "value": "#90a3ad"
    },
    "shape": {
      "type": ["image", "image2", "image3", "image4", "image5", "image6", "image7", "image8", "image9", "image10", "image11", "image12"],
      "stroke": {
        "width": 7,
        "color": "#094d8d"
      },
      "polygon": {
        "nb_sides": 5
      },
      "image": {
        "src": "./img/4.png",
        "width": 270,
        "height": 270
      }
    },
    "size": {
      "value": 30,
      "random": true,
      "anim": {
        "enable": false,
        "speed": 40,
        "size_min": 25,
        "sync": true
      }
    },
    "line_linked": {
      "enable": true,
      "distance": 170,
      "color": "#90a3ad",
      "width": 3
    },
    "move": {
      "enable": true,
      "speed": 4.810236182596568,
      "direction": "none",
      "random": true,
      "straight": false,
      "out_mode": "bounce",
      "bounce": false,
      "attract": {
        "enable": true,
        "rotateX": 3768.0183430339785,
        "rotateY": 3768.0183430339785
      }
    }
  },
  "interactivity": {
    "detect_on": "canvas",
    "events": {
      "onhover": {
        "enable": false,
        "mode": "repulse"
      },
      "onclick": {
        "enable": false,
        "mode": "push"
      },
      "resize": true
    },
    "modes": {
      "grab": {
        "distance": 400,
        "line_linked": {
          "opacity": 1
        }
      },
      "bubble": {
        "distance": 400,
        "size": 40,
        "duration": 2,
        "opacity": 8,
        "speed": 3
      },
      "repulse": {
        "distance": 200,
        "duration": 0.4
      },
      "push": {
        "particles_nb": 4
      },
      "remove": {
        "particles_nb": 2
      }
    }
  }
  }
);