-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
59 lines (50 loc) · 1.11 KB
/
sketch.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
var cx;
var cy;
var x;
var y;
var r = 170;
var o = 0;
var sunsize = 200;
var stars = [];
function setup() {
canvas = createCanvas(600, 600);
frameRate(30)
cx = width/2;
cy = height/2;
for (var i = 0; i < 800; i++) {
stars[i] = new Star();
}
}
function draw() {
background(0);
fill("yellow");
ellipse(cx, cy, sunsize);
fill(255)
x = r*cos(o);
y = r*sin(o);
o = o + 0.01;
ellipse(cx - x, cy - y, 10, 10);
print(y)
stroke(126);
//left
line(cx - (sunsize/2), 0, cx - (sunsize/2), cy*2)
//right
line(cx+(sunsize/2), 0, cx + (sunsize/2), cy*2)
if ((sunsize/2) > x && x > (-sunsize/2)) {
fill(255, 0, 0);
textSize(16);
text("I Am UNDER SUN!!, Its hot!", cx-100, 50)
}
for ( var i = 0; i < stars.length; i++) {
stars[i].show();
}
}
function Star() {
this.x = random(-width, width);
this.y = random(-height, height);
this.show = function() {
fill(random(100,255));
noStroke();
ellipse(this.x, this.y, 2, 2);
}
}