html
html
1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
</head>
<body>
<div id="background"></div>
<div id="weeeee"></div>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
body {
margin: 0;
padding: 0;
}
div {
position: fixed;
left: 50px;
top: 50px;
width: 10px;
height: 10px;
border-radius: 5px;
background-color: green;
}
#background {
top: 30px;
left: 30px;
width: 50px;
height: 50px;
border-radius: 25px;
background-color: yellow;
border: 1px solid black;
box-sizing: border-box;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
window.onload = function() {
$(function() {
let leftStart = parseInt($("#weeeee").css("left").replace("px",""));
let topStart = parseInt($("#weeeee").css("top").replace("px",""))
let left;
let top;
let deg = 0;
let radius = 20;
rotate = function() {
deg += Math.PI / 180;
if(deg >= 2 * Math.PI) {
deg = 0;
}
/*if(i >= 16) {
clearInterval(t);
}*/
//console.log(deg + ":\n Sinus: " +Math.sin(deg).toFixed(0) + ", Cosinus: " + Math.cos(deg).toFixed(0));
left = leftStart + parseFloat(Math.sin(deg).toFixed(10)) * radius;
top = topStart + parseFloat(Math.cos(deg).toFixed(10)) * radius;
$("#weeeee").css("left", left + "px");
$("#weeeee").css("top", top + "px");
//console.log(deg + ":\n Left: " + left + ", Top: " + top);
}
//console.log(Math.sin(Math.PI).toFixed(0));
t = setInterval(rotate, 1);
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run