我有一个项目,它使用Particle.JS创建一个带有移动图像粒子的画布。我目前遇到的问题是,每一张图像在一定时间后都会被重新加载,而它已经被加载了。
config.json
"particles": {
"number": {
"value": 10,
"density": {
"enable": false,
"value_area": 100
}
},
"color": {
"value": "#ffffff"
},
"shape": {
"type": ["image0", "image1", "image2", "image3", "image4", "image5"],
"stroke": {
"width": 0,
"color": "#000000"
},
"polygon": {
"nb_sides": 5
},
"image": {
"src": "images/0.png",
"width": 100,
"height": 100
}
},我用这个例子过滤掉了开关中的所有图像类型。(pJS.fn.particle.prototype.draw)
particles.js
case (p.shape.match(/image/) || {}).input:
if(pJS.tmp.img_type == 'svg'){
var img_obj = p.img.obj;
}else{
var img_obj = pJS.tmp.img_obj;
}
var element = document.createElement('img');
var number = p.shape.replace("image", "")
element.src = './styles/eles/theme/images/particlelogo/'+number+'.png';
img_obj = element;
if(img_obj){
draw();
}
break;发布于 2022-05-30 16:50:27
"shape": {
"type": "images",
"stroke": {
"width": 0,
"color": "#000"
},
"polygon": {
"nb_sides": 6
},
"images": [
{
"src": "img/shapes/0.svg",
"width": 100,
"height": 100
},
{
"src": "img/shapes/1.svg",
"width": 100,
"height": 100
}
]
},https://stackoverflow.com/questions/48332791
复制相似问题