start of circle logic

This commit is contained in:
2026-06-06 19:09:27 -05:00
parent e02696b245
commit 55845a80fb
+22 -7
View File
@@ -20,7 +20,7 @@
height: 20px; height: 20px;
width: 20px; width: 20px;
background-color: red; background-color: red;
position: relative; position: absolute;
} }
#frame { #frame {
width: 75%; width: 75%;
@@ -59,7 +59,19 @@
console.log('frame: ' + this.frameWidth + ' x ' + this.frameHeight); console.log('frame: ' + this.frameWidth + ' x ' + this.frameHeight);
}); });
generateTarget(); let k, r, x, y;
let radians;
for (let i = 0; i < 360; i++) {
r = frameWidth / 2;
radians = degreesToRadians(i);
x = r * Math.cos(i);
y = r * Math.sin(i);
console.log(x + ', ' + y);
generateTarget(x, y);
}
// init logs: // init logs:
console.log('page: ' + pageWidth + ' x ' + pageHeight); console.log('page: ' + pageWidth + ' x ' + pageHeight);
@@ -68,14 +80,17 @@
function degreesToRadians(degrees) {
return degrees * (Math.PI / 180)
}
function generateTarget() { function generateTarget(x, y) {
const target = document.createElement("div"); const target = document.createElement("div");
target.id = "target"; target.id = "target";
target.style.top = getRandomInt(0, frameHeight) + 'px'; target.style.top = y +'px';
target.style.left = getRandomInt(0, frameWidth) + 'px'; target.style.left = x + 'px';
console.log(target); // console.log(target);
document.getElementById("frame").insertAdjacentElement("afterbegin", target); document.getElementById("frame").insertAdjacentElement("afterbegin", target);
} }
@@ -87,4 +102,4 @@
} }
</script> </script>
</body> </body>
</html> </html>