jQuery|JAVASCRIPT tsparticles로 연결되는 입자(파티클) 배경 만들기
페이지 정보
조회 204회
작성일 20-05-18 09:45
tsparticles 라이브러리를 이용해 입자들이 서로 선으로 연결되며 움직이는 애니메이션 배경을 만드는 방법이다. CDN 스크립트 로드와 배경 컨테이너 HTML, 입자 개수·색상·크기·투명도·연결선, 마우스 호버 repulse와 클릭 push 반응, 배경 색상 등을 설정하는 CSS와 JavaScript 코드를 제공한다.
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/tsparticles.min.js"></script>
<div id="tsparticles"></div>
/* ---- reset ---- */
body {
margin: 0;
font: normal 75% Arial, Helvetica, sans-serif;
}
canvas {
display: block;
vertical-align: bottom;
}
/* ---- tsparticles container ---- */
#tsparticles {
position: absolute;
width: 100%;
height: 100%;
background-color: #0d47a1;
background-image: url("");
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
}
tsParticles.load("tsparticles", {
fpsLimit: 60,
particles: {
number: {
value: 80,
density: {
enable: true,
value_area: 800
}
},
color: {
value: "#ff0000",
animation: {
enable: true,
speed: 20,
sync: true
}
},
shape: {
type: "circle",
stroke: {
width: 0,
color: "#000000"
},
polygon: {
nb_sides: 5
}
},
opacity: {
value: 0.5,
random: false,
anim: {
enable: false,
speed: 3,
opacity_min: 0.1,
sync: false
}
},
size: {
value: 3,
random: true,
anim: {
enable: false,
speed: 20,
size_min: 0.1,
sync: false
}
},
line_linked: {
enable: true,
distance: 100,
color: "random",
opacity: 0.4,
width: 1,
triangles: {
enable: true,
color: "#ffffff",
opacity: 0.1
}
},
move: {
enable: true,
speed: 6,
direction: "none",
random: false,
straight: false,
out_mode: "out",
attract: {
enable: false,
rotateX: 600,
rotateY: 1200
}
}
},
interactivity: {
detect_on: "canvas",
events: {
onhover: {
enable: true,
mode: "repulse"
},
onclick: {
enable: true,
mode: "push"
},
resize: true
},
modes: {
grab: {
distance: 400,
line_linked: {
opacity: 1
}
},
bubble: {
distance: 400,
size: 40,
duration: 2,
opacity: 0.8,
speed: 3
},
repulse: {
distance: 200
},
push: {
particles_nb: 4
},
remove: {
particles_nb: 2
}
}
},
retina_detect: true,
background: {
color: "#000000",
image: "",
position: "50% 50%",
repeat: "no-repeat",
size: "cover"
}
}); 첨부파일
-
tsparticles.min.js (105.3K)
22회 다운로드 | DATE : 2020-05-18 10:33:49
관련링크
-
http://www.jq22.com/code3225
3329회 연결
- 이전글CSS animation으로 텍스트 색상이 번지는 효과 만들기 23.08.16