0
我正在尋找使用HTML 2D Canvas的煙霧效果示例,其中煙霧受到用戶通過煙霧移動鼠標以便煙霧受到干擾的影響。2d畫布煙霧與鼠標交互的例子。
我正在尋找使用HTML 2D Canvas的煙霧效果示例,其中煙霧受到用戶通過煙霧移動鼠標以便煙霧受到干擾的影響。2d畫布煙霧與鼠標交互的例子。
我不知道,如果你還在這個有趣的,但是,在這裏看一看this 所以,不是檢查,如果顆粒感動你應該提供鼠標X邊,Y座標:
function init() {
var canvas = document.getElementById('myCanvas');
if (canvas.getContext) {
// Set the context variable so it can be re-used
context = canvas.getContext('2d');
// Create the particles and set their initial positions and velocities
for(var i=0; i < particleCount; ++i){
var particle = new Particle(context);
// Set the position to be inside the canvas bounds
particle.setPosition(generateRandom(0, canvasWidth), generateRandom(0, canvasHeight));
// Set the initial velocity to be either random and either negative or positive
particle.setVelocity(generateRandom(-maxVelocity, maxVelocity), generateRandom(-maxVelocity, maxVelocity));
particles.push(particle);
}
}
else {
alert("Please use a modern browser");
}
}