所以我在搞乱 trianglify.js。
我的目标是当鼠标移动时,我的三角形画布的方差会发生变化。
理论上很好,但实际上并没有真正采取我尝试了几种不同的代码格式,但实际上似乎无法通过三角化来尊重新值。
所以希望有人可以阐明我做错了什么。
//Do Traingle Canvas
window.onload = function() {
var pattern = Trianglify({
width: window.innerWidth,
height: window.innerHeight,
cell_size: 120,
stroke_width: 1.3,
variance: 0.75,
seed: '9rqsn',
x_colors: 'Blues'
});
var homecan = document.getElementById('home');
homecan.appendChild(pattern.canvas());
document.onmousemove = (function() {
var onmousestop = function() {
var pattern = Trianglify({
variance: 0.05
});
pattern.canvas()
},
thread;
return function() {
clearTimeout(thread);
thread = setTimeout(onmousestop, 100);
};
})();
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/0.4.0/trianglify.min.js"></script>
<div id="home"></div>