you need to rotate the image by the button, I kind of wrote everything correctly, but it is erased for some reason
var img; var tttAlt = 0; var tttLong = 0; var tttScale = 0; function draw() { //upload var ctx = document.getElementById('canvas').getContext('2d'); img = new Image(); var f = document.getElementById("uploadimage").files[0], url = window.zURL || window.URL, src = url.createObjectURL(f); img.src = src; img.onload = function() { ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, (img.height * canvas.width) / img.width); //вписывание в ширину }; }; document.getElementById("uploadimage").addEventListener("change", draw, false) function turn() { var ctx = document.getElementById('canvas').getContext('2d'); ctx.rotate(Math.PI / 2); var rectX = canvas.width / 2, rectY = canvas.height / 2; ctx.translate(-0, -500); ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, (img.height * canvas.width) / img.width); //вписывание в ширину } <button onclick="turn()">turn</button> <input type="file" name="img" id="uploadimage" size="1" class="input_input_style"> <body style="background-color:3F6E6F;"> <canvas id="canvas" width="500" height="500"></canvas> <script src="config.js"></script>
canvasvariable in js? Pasteconsole.log(canvas);into img.onloadconsole.log(canvas);that the console will output? - cronfy Nov.