Comments (9)
Hi @kelvinz,
Yep you can:
pJSDom[0].pJS.particles.number.value = 30
pJSDom[0].pJS.fn.particlesRefresh()
from particles.js.
When I change it, the background rerenders. So the existing nodes jump around. Is there a way to add nodes without the jumping?
from particles.js.
Just started using this library, but yes it looks like the particlesRefresh() function resets everything.
If you want to do this at runtime you have to access the particle array directly, example:
$(document).on('click', function(e){
const newColor = '#FF2222';
$.each(pJSDom[0].pJS.particles.array, function(i,p){
pJSDom[0].pJS.particles.array[i].color.value = newColor;
pJSDom[0].pJS.particles.array[i].color.rgb = hexToRgb(newColor);
});
});
notice that to change color, you actually have to set the color.rgb value (ie not just the color.value), also the hexToRgb function is in the main particles.js file, this example refers to that function
i haven't tested everything yet but i'm pretty sure you could set any of the values of any particle at runtime using this method. hope that helps!
from particles.js.
Thanks @VincentGarreau ! =)
from particles.js.
how can i do this from the angular particles library?
from particles.js.
Just started using this library, but yes it looks like the particlesRefresh() function resets everything.
If you want to do this at runtime you have to access the particle array directly, example:
$(document).on('click', function(e){ const newColor = '#FF2222'; $.each(pJSDom[0].pJS.particles.array, function(i,p){ pJSDom[0].pJS.particles.array[i].color.value = newColor; pJSDom[0].pJS.particles.array[i].color.rgb = hexToRgb(newColor); }); });
notice that to change color, you actually have to set the color.rgb value (ie not just the color.value), also the hexToRgb function is in the main particles.js file, this example refers to that function
i haven't tested everything yet but i'm pretty sure you could set any of the values of any particle at runtime using this method. hope that helps!
Its working! But how we can change line color as well? i try with
pJSDom[0].pJS.particles.line_linked.color = newColor;
and nothing happend
UPDATE:
I found it, here is a link
from particles.js.
Hi.
I'm trying to change some of the properties with either Jquery of JS.
I did it a while back and with the browser debugger, were able to see the library properties somewhere that showed the objects in a dropdown menu which made it very easy to find the object needed. No idea how to find it anymore. Any help would be appreciated.
I would like to do:
pJSDom[0].pJS.particles.array[i].shape.stroke.color
from particles.js.
@sjhendriksz
Try to read core js, it helps me to find a solution
from particles.js.
$(document).on('click', function(e){
const newColor = '#FF2222';
$.each(pJSDom[0].pJS.particles.array, function(i,p){
pJSDom[0].pJS.particles.array[i].color.value = newColor;
pJSDom[0].pJS.particles.array[i].color.rgb = hexToRgb(newColor);
});
});
I tried exactly this but it's changing the color of all the particles. Has anybody else tried changing the properties of a specific particle?
from particles.js.
Related Issues (20)
- Test1 - Updated
- Test2 - Updated
- How do i justify its position to bottom right inside div
- decrease the movement speed
- Can't interact with the page content - Elementor HOT 1
- Particle.js overlaps everything HOT 1
- Push particles based on variable change in a seperate function HOT 3
- Render single frame for prefers-reduced-motion HOT 1
- How to disable interactivity HOT 1
- s
- Problem with particles.js 2023 HOT 1
- Particles dont interact while hovering or clicking HOT 1
- Uncaught ReferenceError: Stats is not defined in Wordpress HOT 1
- idk
- how to use config file HOT 1
- particals js error
- Documentation HOT 2
- Make code compatible with ES5 strict mode HOT 2
- How can I reset the particles to initial position?
- Particles as a background
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from particles.js.