Having trouble with my studies and looking to create a custom shirt website. Posted below is the beginner code I have:
If anyone knows how to upload an image onto a shirt canvas using a button, as well as change the shirt color with another button, please share your knowledge. Thank you in advance, and apologies for any language errors^^
<html>
<head>
<title>HTML5 Canvas example</title>
<script type="text/javascript">
window.addEventListener('load', function () {
var element = document.getElementById('myCanvas');
if (!element || !element.getContext) {
return;
}
var context = element.getContext('2d');
if (!context || !context.drawImage) {
return;
}
context.fillStyle = '#CC5422'; // set canvas background color
context.fillRect (0, 0, 350, 350); // now fill the canvas
// create amd draw the branding image for the qr-code
var Shirt = new Image();
Shirt.addEventListener('load', function () {
context.drawImage(this, 35, 25, 275, 275);
},false);
Shirt.src = "men_shirt_front.png";
},false);
</script>
</head>
<body>
<div style="padding:35px;">
<canvas id="myCanvas" width="350" height="350">
Your browser does not support HTML5 Canvas element.
</canvas>
</div>
</body>
</html>