I am new to HTML5 canvas. I have an image of a cup, I am depicted on canvas.
This is a picture of a cup:

Now I'm trying to make another image (my photo, which is in the usual rectangular size), upload your design area for this image. How can I display this image that looks like this image on a cup?
I want to get the final image as follows:

I am using the canvas element to load an image.
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="400" height="400" style="border:5px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script src="js/test.js" type="text/javascript"></script>
</body>
</html>
Js
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var imageObj = new Image();
var x = 0;
var y = 0;
var width = 290;
var height = 297;
imageObj.onload = function() {
context.drawImage(imageObj, x, y);
};
imageObj.src = 'images/cup.jpg';
source
share