Can now rotate fully.

This commit is contained in:
Kaylee 2023-05-09 05:06:42 +01:00
parent 0e50c49aad
commit 2c0be8c3bc
No known key found for this signature in database
GPG Key ID: 84EB2D9600AD856C
5 changed files with 21 additions and 6 deletions

BIN
.index.html.swp Normal file

Binary file not shown.

BIN
js/.app.js.swp Normal file

Binary file not shown.

View File

@ -1,20 +1,35 @@
var angle_arr = []; var angle_arr = [];
function closest(val){ function closest(val){
var lessThan0 = val < 0;
var geNinety = Math.abs(val)>=90;
if(geNinety)
if(lessThan0) {
val += 90}
else
val -= 90
x= angle_arr.reduce(function(prev, cur) { x= angle_arr.reduce(function(prev, cur) {
return Math.abs(cur.angle - val) < Math.abs(prev.angle - val) ? cur : prev; return Math.abs(cur.angle - Math.abs(val)) < Math.abs(prev.angle - Math.abs(val)) ? cur : prev;
}); });
return x; var output = x.angle;
if(geNinety)
output = x.angle + 90
if(lessThan0)
output = 0 - output
return [output,x];
} }
window.onload = function() { window.onload = function() {
fetch('js/angles.json').then((response)=>response.json()).then((json)=>angle_arr=json.angles); fetch('js/angles.json').then((response)=>response.json()).then((json)=>angle_arr=json.angles);
var input = document.getElementById('fileUpload'); var input = document.getElementById('fileUpload');
input.addEventListener('change', handleFiles); input.addEventListener('change', handleFiles);
rotation.addEventListener("input", (event) => { rotation.addEventListener("input", (event) => {
var closestAngle = closest(event.target.value); var closestAngle = closest(parseInt(event.target.value));
console.log(closestAngle); event.target.value = closestAngle[0];
event.target.value = closestAngle.angle;
angle.textContent = event.target.value; angle.textContent = event.target.value;
tileImg(closestAngle.angle); tileImg(closestAngle[0]);
}) })
canvas.width = 700; canvas.width = 700;
canvas.height = 700; canvas.height = 700;

BIN
lazygit Executable file

Binary file not shown.

BIN
lazygit.tar.gz Normal file

Binary file not shown.