-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
109 lines (103 loc) · 3.61 KB
/
main.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
let startx = (window.innerHeight + 250) / 2, starty = window.innerWidth / 2, ang = 0, epiVal = 5, hypoVal = 5, x, y;
function epicycloid(k, r) {
x = r * (k - 1) * Math.cos(ang) - r * Math.cos((k - 1) * ang);
y = r * (k - 1) * Math.sin(ang) - r * Math.sin((k - 1) * ang);
$('body').append(`<div style='position: absolute; top:${startx + x}px; left:${starty - y}px; height: 5px; width: 5px; background-color: aqua; border-radius: 50%; z-index: -1'></div>`);
ang = ang + 3
}
function hypocycloid(k, r) {
x = r * (k - 1) * Math.cos(ang) + r * Math.cos((k - 1) * ang);
y = r * (k - 1) * Math.sin(ang) - r * Math.sin((k - 1) * ang);
$('body').append(`<div style='position: absolute; top:${startx + x}px; left:${starty - y}px; height: 5px; width: 5px; background-color: lawngreen; border-radius: 50%;'></div>`);
ang = ang + 3
}
//=================================================
//Epicycloid buttons
//=================================================
$('#epi1').on('click', function () {
setInterval(epicycloid, .01, 1.3, window.innerHeight / 3)
setTimeout(align, 1000)
})
$('#epi2').on('click', function () {
setInterval(epicycloid, .01, 1.7, window.innerHeight / 5)
setTimeout(align, 1000)
})
$('#epi3').on('click', function () {
setInterval(epicycloid, .01, 3.1, window.innerHeight / 7)
setTimeout(align, 1000)
})
$('#epi4').on('click', function () {
setInterval(epicycloid, .01, 4.2, window.innerHeight / 12)
setTimeout(align, 1000)
})
$('#epi5').on('click', function () {
setInterval(epicycloid, .01, 5.1, window.innerHeight / 14)
setTimeout(align, 1000)
})
$('#epi6').on('click', function () {
setInterval(epicycloid, .01, 9.5, window.innerHeight / 21)
setTimeout(align, 1000)
})
$('#epiRange').on('change', function () {
epiVal = this.value
$('#value').text(this.value)
})
$('#tryEpi').on('click', function () {
setInterval(epicycloid, .01, epiVal, window.innerHeight / ((epiVal * 2) + 2));
setTimeout(align, 1000)
})
//=================================================
//Hypocycloid buttons
//=================================================
$('#hypo1').on('click', function () {
setInterval(hypocycloid, .001, 1.3, window.innerHeight / 3)
setTimeout(align, 1000)
})
$('#hypo2').on('click', function () {
setInterval(hypocycloid, .001, 2.1, window.innerHeight / 5)
setTimeout(align, 1000)
})
$('#hypo3').on('click', function () {
setInterval(hypocycloid, .001, 2.8, window.innerHeight / 6)
setTimeout(align, 1000)
})
$('#hypo4').on('click', function () {
setInterval(hypocycloid, .001, 4.1, window.innerHeight / 9)
setTimeout(align, 1000)
})
$('#hypo5').on('click', function () {
setInterval(hypocycloid, .001, 5.9, window.innerHeight / 13)
setTimeout(align, 1000)
})
$('#hypo6').on('click', function () {
setInterval(hypocycloid, .001, 9.5, window.innerHeight / 25)
setTimeout(align, 1000)
})
$('#hypoRange').on('change', function () {
hypoVal = this.value
$('#value2').text(this.value)
})
$('#tryHypo').on('click', function () {
setInterval(hypocycloid, .01, hypoVal, window.innerHeight / ((hypoVal * 2) + 2));
setTimeout(align, 1000)
})
//=================================================
//Extra Button Functions & Align Screen Function
//=================================================
$('.reload').on('click', function () {
window.scrollTo(0, 0)
location.reload()
})
$('.btn').on('mousedown', function () {
$(this).css({
border: 'none'
})
})
$('.btn').on('mouseup', function () {
$(this).css({
border: '4px groove violet'
})
})
function align() {
window.scrollTo(0, 1000)
}