P
P
Pavel Antonov2016-07-12 16:47:17
JavaScript
Pavel Antonov, 2016-07-12 16:47:17

How to insert an image into canvas?

Please tell me if it is possible to insert an arbitrary image instead of points, indicating the path to it. And if possible, tell me where to dig.
Example:
codepen.io/acauamontiel/pen/mJdnw

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Antonov, 2016-07-12
@freislot

I decided

var img = new Image();   // Создаём новый объект Image
img.src = 'imgcss/wide.png'; // Устанавливаем путь к источнику
context.drawImage(img, this.x, this.y, 50, 26); //рисуем картинку в канвас

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question