问题描述
我完全缺乏javascript直觉的道歉,但我想知道是否可以更改对象:
Apologies for my complete lack of javascript intuition, but I was wondering if it is possible to change properties of a particles.js
object dynamically:
我正在使用 jQuery
检测用户何时移动屏幕上的滑块(成功)。但是,我想知道如何将这些滑块值更改应用到我在后台的 particles.js
画布。
I'm using jQuery
to detect when a user moves a slider on the screen (successfully). However, I was wondering how to apply these slider-value changes to the particles.js
canvas I have in the background.
即移动滑块,粒子变大。
I.e. Move the slider across, and the particles get larger.
但是,我不知道如何更新 particles.js
- 是否有人熟悉回调或动画循环功能,我可以将我的属性更改删除?
However, I'm not sure how to update the particles.js
— is anyone familiar with a callback or animation loop function that I can drop my property changes into?
推荐答案
有关于此主题的。
但您可以通过访问每个粒子的radius属性手动更改它:
There is an open issue on this subject.But you can change it manually by accessing the radius property of each particle:
pJS.particles.array.forEach(function(p) {
p.radius = p.radius * sliderValue; // change by a factor
p.radius = sliderValue; // change to a single size
});
这篇关于Particles.js - 修改帧更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!