Coder Social home page Coder Social logo

Comments (9)

VincentGarreau avatar VincentGarreau commented on July 29, 2024 2

Hi @kelvinz,

Yep you can:
pJSDom[0].pJS.particles.number.value = 30
pJSDom[0].pJS.fn.particlesRefresh()

from particles.js.

BrunnerLivio avatar BrunnerLivio commented on July 29, 2024 1

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.

nathanmal avatar nathanmal commented on July 29, 2024 1

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.

kelvinz avatar kelvinz commented on July 29, 2024

Thanks @VincentGarreau ! =)

from particles.js.

dukehh avatar dukehh commented on July 29, 2024

how can i do this from the angular particles library?

from particles.js.

Soullighter avatar Soullighter commented on July 29, 2024

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.

sjhendriksz avatar sjhendriksz commented on July 29, 2024

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.

Soullighter avatar Soullighter commented on July 29, 2024

@sjhendriksz
Try to read core js, it helps me to find a solution

from particles.js.

ArginLerit avatar ArginLerit commented on July 29, 2024

$(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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.