admin管理员组文章数量:1024678
How to change color and background in react-tsparticles ? This is my particle-config.js
const particlesConfig = {
background: {
color: {
value: "#232741",
},
position: "50% 50%",
repeat: "no-repeat",
size: "20%",
},
fullScreen: {
zIndex: 1,
},
interactivity: {
events: {
onClick: {
enable: true,
mode: "repulse",
},
onHover: {
enable: true,
mode: "bubble",
},
},
modes: {
bubble: {
distance: 250,
duration: 2,
opacity: 0,
size: 0,
},
grab: {
distance: 400,
},
repulse: {
distance: 400,
},
},
},
particles: {
color: {
value: "#ffffff",
},
links: {
color: {
value: "#ffffff",
},
distance: 150,
opacity: 0.4,
},
move: {
attract: {
rotate: {
x: 600,
y: 600,
},
},
enable: true,
outModes: {
bottom: "out",
left: "out",
right: "out",
top: "out",
},
random: true,
speed: 1,
},
number: {
density: {
enable: true,
},
value: 160,
},
opacity: {
random: {
enable: true,
},
value: {
min: 0,
max: 1,
},
animation: {
enable: true,
speed: 1,
minimumValue: 0,
},
},
size: {
random: {
enable: true,
},
value: {
min: 1,
max: 3,
},
animation: {
speed: 4,
minimumValue: 0.3,
},
},
},
};
export default particlesConfig;
dummy data"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea modi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
How to change color and background in react-tsparticles ? This is my particle-config.js
const particlesConfig = {
background: {
color: {
value: "#232741",
},
position: "50% 50%",
repeat: "no-repeat",
size: "20%",
},
fullScreen: {
zIndex: 1,
},
interactivity: {
events: {
onClick: {
enable: true,
mode: "repulse",
},
onHover: {
enable: true,
mode: "bubble",
},
},
modes: {
bubble: {
distance: 250,
duration: 2,
opacity: 0,
size: 0,
},
grab: {
distance: 400,
},
repulse: {
distance: 400,
},
},
},
particles: {
color: {
value: "#ffffff",
},
links: {
color: {
value: "#ffffff",
},
distance: 150,
opacity: 0.4,
},
move: {
attract: {
rotate: {
x: 600,
y: 600,
},
},
enable: true,
outModes: {
bottom: "out",
left: "out",
right: "out",
top: "out",
},
random: true,
speed: 1,
},
number: {
density: {
enable: true,
},
value: 160,
},
opacity: {
random: {
enable: true,
},
value: {
min: 0,
max: 1,
},
animation: {
enable: true,
speed: 1,
minimumValue: 0,
},
},
size: {
random: {
enable: true,
},
value: {
min: 1,
max: 3,
},
animation: {
speed: 4,
minimumValue: 0.3,
},
},
},
};
export default particlesConfig;
dummy data"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea modi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
Share Improve this question edited Jan 14, 2022 at 11:29 Kaizen asked Jan 7, 2022 at 17:41 KaizenKaizen 632 silver badges7 bronze badges1 Answer
Reset to default 5To change particle & background colour you need to adjust the below values respectively (with hex code colours) in your config. I also included links
(the ones between the dots) as you can also adjust their colour
particles: {
color: {
value: "#a13f23",
},
links: {
color: "#098712",
}
}
background: {
color: {
value: "#121",
}
}
In order to change the height of the canvas ponent, you have to add another field to the options object:
fullScreen: false
Once this is done, you have to target tsparticles
id and add height
attribute with a value that fits your needs, example below:
#tsparticles {
height: 100px
}
Here's Sandbox to test.
How to change color and background in react-tsparticles ? This is my particle-config.js
const particlesConfig = {
background: {
color: {
value: "#232741",
},
position: "50% 50%",
repeat: "no-repeat",
size: "20%",
},
fullScreen: {
zIndex: 1,
},
interactivity: {
events: {
onClick: {
enable: true,
mode: "repulse",
},
onHover: {
enable: true,
mode: "bubble",
},
},
modes: {
bubble: {
distance: 250,
duration: 2,
opacity: 0,
size: 0,
},
grab: {
distance: 400,
},
repulse: {
distance: 400,
},
},
},
particles: {
color: {
value: "#ffffff",
},
links: {
color: {
value: "#ffffff",
},
distance: 150,
opacity: 0.4,
},
move: {
attract: {
rotate: {
x: 600,
y: 600,
},
},
enable: true,
outModes: {
bottom: "out",
left: "out",
right: "out",
top: "out",
},
random: true,
speed: 1,
},
number: {
density: {
enable: true,
},
value: 160,
},
opacity: {
random: {
enable: true,
},
value: {
min: 0,
max: 1,
},
animation: {
enable: true,
speed: 1,
minimumValue: 0,
},
},
size: {
random: {
enable: true,
},
value: {
min: 1,
max: 3,
},
animation: {
speed: 4,
minimumValue: 0.3,
},
},
},
};
export default particlesConfig;
dummy data"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea modi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
How to change color and background in react-tsparticles ? This is my particle-config.js
const particlesConfig = {
background: {
color: {
value: "#232741",
},
position: "50% 50%",
repeat: "no-repeat",
size: "20%",
},
fullScreen: {
zIndex: 1,
},
interactivity: {
events: {
onClick: {
enable: true,
mode: "repulse",
},
onHover: {
enable: true,
mode: "bubble",
},
},
modes: {
bubble: {
distance: 250,
duration: 2,
opacity: 0,
size: 0,
},
grab: {
distance: 400,
},
repulse: {
distance: 400,
},
},
},
particles: {
color: {
value: "#ffffff",
},
links: {
color: {
value: "#ffffff",
},
distance: 150,
opacity: 0.4,
},
move: {
attract: {
rotate: {
x: 600,
y: 600,
},
},
enable: true,
outModes: {
bottom: "out",
left: "out",
right: "out",
top: "out",
},
random: true,
speed: 1,
},
number: {
density: {
enable: true,
},
value: 160,
},
opacity: {
random: {
enable: true,
},
value: {
min: 0,
max: 1,
},
animation: {
enable: true,
speed: 1,
minimumValue: 0,
},
},
size: {
random: {
enable: true,
},
value: {
min: 1,
max: 3,
},
animation: {
speed: 4,
minimumValue: 0.3,
},
},
},
};
export default particlesConfig;
dummy data"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea modi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
Share Improve this question edited Jan 14, 2022 at 11:29 Kaizen asked Jan 7, 2022 at 17:41 KaizenKaizen 632 silver badges7 bronze badges1 Answer
Reset to default 5To change particle & background colour you need to adjust the below values respectively (with hex code colours) in your config. I also included links
(the ones between the dots) as you can also adjust their colour
particles: {
color: {
value: "#a13f23",
},
links: {
color: "#098712",
}
}
background: {
color: {
value: "#121",
}
}
In order to change the height of the canvas ponent, you have to add another field to the options object:
fullScreen: false
Once this is done, you have to target tsparticles
id and add height
attribute with a value that fits your needs, example below:
#tsparticles {
height: 100px
}
Here's Sandbox to test.
本文标签:
版权声明:本文标题:javascript - How to change color , background and height of the particle background in react-tsparticles? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745616031a2159297.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论