-
Notifications
You must be signed in to change notification settings - Fork 0
/
thoughts.js
33 lines (30 loc) · 893 Bytes
/
thoughts.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
$(document).ready(function(){
// Map the enter key to the go button
$("#input").keyup(function(event) {
if (event.keyCode === 13) {
$("#inputBtn").click();
}
});
// White star background
var max = 100;
var w = window.innerWidth;
var h = window.innerHeight;
var canvas = document.getElementById("sky");
canvas.width = w;
canvas.height = h;
var ctx = canvas.getContext("2d");
var radius = 1.5;
for (var i = 0; i < max; i++){
ctx.beginPath();
ctx.arc(Math.floor((Math.random() * w)) , Math.floor((Math.random() * h)), radius, 0, 2*Math.PI, false);
ctx.fillStyle = "rgba(255,255,255,0.8)";
ctx.fill();
}
// On click, make a star
$("#skyWords").click(function(event) {
ctx.beginPath();
ctx.arc(event.clientX , event.clientY, radius, 0, 2*Math.PI, false);
ctx.fillStyle = "rgba(255,255,255,0.8)";
ctx.fill();
});
});