function loop(){
Array.from(list.children).forEach(c=>{
c.style.top = (c.offsetTop - speed ) +"px";
})
while(list.children[0].offsetTop <= -list.children[0].offsetHeight){
var el = list.children[0];
el.style.top = list.children[list.children.length-1].offsetTop + el.offsetHeight + 10 + 'px';
list.removeChild(el);
list.appendChild(el);
}
setTimeout(loop,10);
}
loop();
data[category]
includes(searchInput.toLowerCase())
console.log(searchInput);
var angle = getAngle(this.x,this.y,player.x,player.y);
this.x += (this.speed * deltaTime)* Math.cos(angle);
this.y += (this.speed * deltaTime)* Math.sin(angle);
//Получить угол между двумя точками
function getAngle(dx, dy, dx1, dy1) {
return Math.atan2(dy - dy1, dx - dx1) + Math.PI;
}
<label >Выберите 2 изображения
<input id="files" type="file" multiple accept="image/x-png,image/gif,image/jpeg">
</label>
<canvas id="myCanvas" width="1000" height="1000"
style="background-color:#eee; border:1px solid #ccc;">
</canvas>
var images = [];
function ff(imgs){
var canvas = document.getElementById("myCanvas"),
context = canvas.getContext("2d");
var loaded = 0;
var img = new Image();
var imgT = new Image();
img.src = imgs[0];
imgT.src = imgs[1];
imgT.onload = img.onload = function() {
if(++loaded == 2)
draw();
};
function draw(){
context.drawImage(imgT, 200, 200,200,200);
context.drawImage(img, 0, 0,200,200);
document.write("<img src='"+canvas.toDataURL()+"' />")
}
}
document.querySelector("#files").onchange = function(e){
Array.from(this.files).forEach(f=>{
var reader = new FileReader();
reader.onload = function (e) {
images.push(e.target.result)
if(images.length == 2)
ff(images);
};
reader.readAsDataURL(f);
});
};