-
Notifications
You must be signed in to change notification settings - Fork 0
/
polarg2.html
50 lines (47 loc) · 1.98 KB
/
polarg2.html
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
---
layout: default
title: Polar Graphs
categories: [ generators, precalc ]
---
<style>
/*body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}*/
#prob1 {
font-family: 'Cambria Math', Cambria, 'Times New Roman', Times, serif;
font-size: 1.5em;
}
iframe {
width: 100%;
}
button {
font-family: unset;
}
</style>
<!--<h1>Polar Graphs</h1>-->
<p>Graph the problem:<br /><b id="prob1"></b><br />
<button id="copyprob" class="no-print">Copy in Desmos Format</button>
<button id="speak" class="no-print">Speak Problem</button>
<button id="newrose" class="no-print">New Rose Problem</button>
<button id="newlima" class="no-print">New Limacon Problem</button>
</p>
<p><i>Check your graph with Desmos below.</i>{% include desmos.html %}</p>
<script defer>
const randbool = () => Math.random() > .5 ? true : false
window.onload = () => {
document.getElementById("prob1").innerText = `r = ${(Math.random() * 5 + 1).toFixed(0)} ${randbool() ? "sin" : "cos"}${(Math.random() * 4 + 1).toFixed(0)}θ`
}
document.getElementById("newrose").onclick = window.onload
document.getElementById("newlima").onclick = () => {
document.getElementById("prob1").innerText = `r = ${(Math.random() * 5 + 1).toFixed(0)} ${randbool() ? "+" : "-"} ${(Math.random() * 4 + 1).toFixed(0)} ${randbool() ? "sin" : "cos"}θ`
}
document.getElementById("copyprob").onclick = () =>
navigator.clipboard.writeText(document.getElementById("prob1").innerText.replace(/θ/g, "\\theta"))
.catch(err => alert("Error with the copy button: ", err))
document.getElementById("speak").onclick = () =>
speechSynthesis.speak(new SpeechSynthesisUtterance(
document.getElementById("prob1").innerText
.replace(/sin/g, "sine of")
.replace(/cos/g, "cosine of")
))
</script>