JS庫(kù)particles.js創(chuàng)建超炫背景粒子插件(附源碼下載)
插件描述:particles.js用于創(chuàng)建粒子的輕量級(jí) JavaScript 庫(kù)。
使用
加載 particles.js和配置粒子
<div id="particles-js"></div> <script src="particles.js"></script>
app.js
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */ particlesJS.load('particles-js', 'assets/particles.json', function() { console.log('callback - particles.js config loaded'); });
particles.json
{ "particles": { "number": { "value": 80, "density": { "enable": true, "value_area": 800 } }, "color": { "value": "#ffffff" }, "shape": { "type": "circle", "stroke": { "width": 0, "color": "#000000" }, "polygon": { "nb_sides": 5 }, "image": { "src": "img/github.svg", "width": 100, "height": 100 } }, "opacity": { "value": 0.5, "random": false, "anim": { "enable": false, "speed": 1, "opacity_min": 0.1, "sync": false } }, "size": { "value": 10, "random": true, "anim": { "enable": false, "speed": 80, "size_min": 0.1, "sync": false } }, "line_linked": { "enable": true, "distance": 300, "color": "#ffffff", "opacity": 0.4, "width": 2 }, "move": { "enable": true, "speed": 12, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false, "attract": { "enable": false, "rotateX": 600, "rotateY": 1200 } } }, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": false, "mode": "repulse" }, "onclick": { "enable": true, "mode": "push" }, "resize": true }, "modes": { "grab": { "distance": 800, "line_linked": { "opacity": 1 } }, "bubble": { "distance": 800, "size": 80, "duration": 2, "opacity": 0.8, "speed": 3 }, "repulse": { "distance": 400, "duration": 0.4 }, "push": { "particles_nb": 4 }, "remove": { "particles_nb": 2 } } }, "retina_detect": true }
選項(xiàng)
key | option type / notes | example |
---|---|---|
particles.number.value | number | 40 |
particles.number.density.enable | boolean | true / false |
particles.number.density.value_area | number | 800 |
particles.color.value | HEX (string) RGB (object) HSL (object) array selection (HEX) random (string) |
"#b61924" {r:182, g:25, b:36} {h:356, s:76, l:41} ["#b61924", "#333333", "999999"] "random" |
particles.shape.type | string array selection |
"circle" "edge" "triangle" "polygon" "star" "image" ["circle", "triangle", "image"] |
particles.shape.stroke.width | number | 2 |
particles.shape.stroke.color | HEX (string) | "#222222" |
particles.shape.polygon.nb_slides | number | 5 |
particles.shape.image.src | path link svg / png / gif / jpg |
"assets/img/yop.svg" "http://mywebsite.com/assets/img/yop.png" |
particles.shape.image.width | number (for aspect ratio) |
100 |
particles.shape.image.height | number (for aspect ratio) |
100 |
particles.opacity.value | number (0 to 1) | 0.75 |
particles.opacity.random | boolean | true / false |
particles.opacity.anim.enable | boolean | true / false |
particles.opacity.anim.speed | number | 3 |
particles.opacity.anim.opacity_min | number (0 to 1) | 0.25 |
particles.opacity.anim.sync | boolean | true / false |
particles.size.value | number | 20 |
particles.size.random | boolean | true / false |
particles.size.anim.enable | boolean | true / false |
particles.size.anim.speed | number | 3 |
particles.size.anim.size_min | number | 0.25 |
particles.size.anim.sync | boolean | true / false |
particles.line_linked.enable | boolean | true / false |
particles.line_linked.distance | number | 150 |
particles.line_linked.color | HEX (string) | #ffffff |
particles.line_linked.opacity | number (0 to 1) | 0.5 |
particles.line_linked.width | number | 1.5 |
particles.move.enable | boolean | true / false |
particles.move.speed | number | 4 |
particles.move.direction | string | "none" "top" "top-right" "right" "bottom-right" "bottom" "bottom-left" "left" "top-left" |
particles.move.random | boolean | true / false |
particles.move.straight | boolean | true / false |
particles.move.out_mode | string (out of canvas) |
"out" "bounce" |
particles.move.bounce | boolean (between particles) |
true / false |
particles.move.attract.enable | boolean | true / false |
particles.move.attract.rotateX | number | 3000 |
particles.move.attract.rotateY | number | 1500 |
interactivity.detect_on | string | "canvas", "window" |
interactivity.events.onhover.enable | boolean | true / false |
interactivity.events.onhover.mode | string array selection |
"grab" "bubble" "repulse" ["grab", "bubble"] |
interactivity.events.onclick.enable | boolean | true / false |
interactivity.events.onclick.mode | string array selection |
"push" "remove" "bubble" "repulse" ["push", "repulse"] |
interactivity.events.resize | boolean | true / false |
interactivity.events.modes.grab.distance | number | 100 |
interactivity.events.modes.grab.line_linked.opacity | number (0 to 1) | 0.75 |
interactivity.events.modes.bubble.distance | number | 100 |
interactivity.events.modes.bubble.size | number | 40 |
interactivity.events.modes.bubble.duration | number (second) |
0.4 |
interactivity.events.modes.repulse.distance | number | 200 |
interactivity.events.modes.repulse.duration | number (second) |
1.2 |
interactivity.events.modes.push.particles_nb | number | 4 |
interactivity.events.modes.push.particles_nb | number | 4 |
retina_detect | boolean | true / false |
總結(jié)
以上所述是小編給大家介紹的JS庫(kù)particles.js創(chuàng)建超炫背景粒子插件附源碼下載,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- 使用3D引擎threeJS實(shí)現(xiàn)星空粒子移動(dòng)效果
- THREE.JS入門(mén)教程(4)創(chuàng)建粒子系統(tǒng)
- 原生JS+HTML5實(shí)現(xiàn)跟隨鼠標(biāo)一起流動(dòng)的粒子動(dòng)畫(huà)效果
- 基于Particles.js制作超炫粒子動(dòng)態(tài)背景效果(仿知乎)
- 用JavaScript玩轉(zhuǎn)游戲物理(一)運(yùn)動(dòng)學(xué)模擬與粒子系統(tǒng)
- Canvas + JavaScript 制作圖片粒子效果
- javascript轉(zhuǎn)換靜態(tài)圖片,增加粒子動(dòng)畫(huà)效果
- 基于three.js實(shí)現(xiàn)的3D粒子動(dòng)效實(shí)例代碼
- JavaScript實(shí)現(xiàn)鼠標(biāo)移動(dòng)粒子跟隨效果
- js canvas實(shí)現(xiàn)隨機(jī)粒子特效
相關(guān)文章
javascript下arguments,caller,callee,call,apply示例及理解
在看到大家如此關(guān)注JS里頭的這幾個(gè)對(duì)象,我試著把原文再修改一下,力求能再詳細(xì)的闡明個(gè)中意義2009-12-12PHP配置文件php.ini中打開(kāi)錯(cuò)誤報(bào)告的設(shè)置方法
這篇文章主要介紹了PHP配置文件php.ini中打開(kāi)錯(cuò)誤報(bào)告的設(shè)置方法,需要的朋友可以參考下2015-01-01jsonp格式前端發(fā)送和后臺(tái)接受寫(xiě)法的代碼詳解
jsonp是ajax提交的一種格式不會(huì)受跨域限制,這篇文章主要介紹了jsonp格式前端發(fā)送和后臺(tái)接受寫(xiě)法的代碼詳解,需要的朋友可以參考下2019-11-11uniapp微信小程序授權(quán)登錄并獲取手機(jī)號(hào)的方法
這篇文章主要給大家介紹了關(guān)于uniapp微信小程序授權(quán)登錄并獲取手機(jī)號(hào)的相關(guān)資料,我們?cè)趗niapp開(kāi)發(fā)微信小程序的過(guò)程中,經(jīng)常需要在微信端登錄,需要的朋友可以參考下2023-06-06JavaScript中判斷整數(shù)的多種方法總結(jié)
這篇文章主要介紹了JavaScript中判斷整數(shù)的多種方法總結(jié),本文總結(jié)了5種判斷整數(shù)的方法,如取余運(yùn)算符判斷、Math.round、Math.ceil、Math.floor判斷等,需要的朋友可以參考下2014-11-11深入淺析JavaScript中的arguments對(duì)象(強(qiáng)力推薦)
這篇文章主要介紹了JavaScript中的arguments對(duì)象(強(qiáng)力推薦)的相關(guān)資料,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06