繁体   English   中英

Particles.js - 如何将角色制作为粒子

[英]Particles.js - How to make a character as particles

嗨,实际上我想将特定文本制作成粒子。 我的意思是我希望它像图像中一样(dropbox.com/s/y43jf4vzdr5cd9p/p.png?dl=0),例如,如果我给 P,这个 P 应该像图像中那样变换。 是否可以?。 为了实现这一点,我使用了particle.js JavaScript 文件。 我尝试了很多来完成自己,但我无法实现。 此外,我不知道要实现这一点。 请帮我。 提前致谢。

 /* ---- particles.js config ---- */ particlesJS("particles-js", { "particles": { "number": { "value": 380, "density": { "enable": true, "value_area": 800 } }, "color": { "value": "#ffffff" }, "shape": { "type": "circle", "stroke": { "width": 0, "color": "#000000" }, "polygon": { "nb_sides": 5 }, "image": { "src": "img/github.svg", "width": 100, "height": 100 } }, "opacity": { "value": 0.5, "random": false, "anim": { "enable": false, "speed": 1, "opacity_min": 0.1, "sync": false } }, "size": { "value": 3, "random": true, "anim": { "enable": false, "speed": 40, "size_min": 0.1, "sync": false } }, "line_linked": { "enable": true, "distance": 150, "color": "#ffffff", "opacity": 0.4, "width": 1 }, "move": { "enable": true, "speed": 6, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false, "attract": { "enable": false, "rotateX": 600, "rotateY": 1200 } } }, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": true, "mode": "grab" }, "onclick": { "enable": true, "mode": "push" }, "resize": true }, "modes": { "grab": { "distance": 140, "line_linked": { "opacity": 1 } }, "bubble": { "distance": 400, "size": 40, "duration": 2, "opacity": 8, "speed": 3 }, "repulse": { "distance": 200, "duration": 0.4 }, "push": { "particles_nb": 4 }, "remove": { "particles_nb": 2 } } }, "retina_detect": true }); /* ---- stats.js config ---- */ var count_particles, stats, update; stats = new Stats; stats.setMode(0); stats.domElement.style.position = 'absolute'; stats.domElement.style.left = '0px'; stats.domElement.style.top = '0px'; document.body.appendChild(stats.domElement); count_particles = document.querySelector('.js-count-particles'); update = function() { stats.begin(); stats.end(); if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) { count_particles.innerText = window.pJSDom[0].pJS.particles.array.length; } requestAnimationFrame(update); }; requestAnimationFrame(update);
 #particles-js { position: absolute; width: 100%; height: 100%; background-color: #b61924; background-image: url(""); background-repeat: no-repeat; background-size: cover; background-position: 50% 50%; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script> <!-- particles.js container --> <div id="particles-js"></div>

强调文本

你必须改变这个文件particles.min.js。 您将在普通文件 (particles.js) 中搜索“circle”这个词。 对我来说,我有两个结果(幸运),当您进入“圆圈”案例下的开关时,您只需添加以下几行:

case "circle":
    var context = pJS.canvas.ctx.canvas.getContext("2d");
    context.beginPath();
    context.fillStyle = "black";
    context.fillText("Hello World!", p.x, p.y);
    context.fill();
    break;

享受! 然后你可以做任何事情。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM