0

Почему изображение не рисуется?

В чём ошибка? Почему не рисуется?? https://code.sololearn.com/WGznNNkW9JdG/?ref=app

21st Mar 2019, 7:00 PM
undefined
undefined - avatar
1 Réponse
0
function tick(){ var hero = new Image(); hero.onload = function() { ctx.drawImage(hero,0,0); }; hero.src = "https://ya-webdesign.com/images/3d-sprite-png-3.png"; } Make use of the onload() function I read here https://stackoverflow.com/questions/10684290/html5-image-is-not-loaded-into-canvas that you can set the canvas’ width and size in the onload() function depending on what the image’s dimensions are and then pass that into drawImage() Используйте функцию onload () Я читаю здесь https://stackoverflow.com/questions/10684290/html5-image-is-not-loaded-into-canvas что вы можете установить ширину и размер холста в функции onload () в зависимости от размеров изображения, а затем передать это в drawImage ()
23rd Mar 2019, 8:39 AM
Jenine