Skip to content

Commit a137616

Browse files
committed
added vignette
1 parent 2d32db4 commit a137616

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: snow.js

+19
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,27 @@ class Snow{
5858
}
5959
}
6060

61+
createVignette(){
62+
const xMid = this.width/2;
63+
const yMid = this.height/2;
64+
const radius = Math.sqrt(xMid*xMid + yMid*yMid);
65+
this.vignette = this.context.createRadialGradient(xMid, yMid, 0, xMid, yMid, radius);
66+
67+
68+
this.vignette.addColorStop(0.49, `rgba(0, 0, 0, 0)`);
69+
for(let i=0; i<=1; i+=0.1){
70+
const alpha = Math.pow(i,3);
71+
this.vignette.addColorStop(0.5+i*0.5, `rgba(0, 0, 0, ${alpha})`);
72+
}
73+
}
74+
6175
onResize(){
6276
this.width = window.innerWidth;
6377
this.height = window.innerHeight;
6478
this.canvas.width = this.width;
6579
this.canvas.height = this.height;
80+
81+
this.createVignette();
6682
}
6783

6884
update(){
@@ -81,6 +97,9 @@ class Snow{
8197
this.context.restore();
8298
}
8399

100+
this.context.fillStyle=this.vignette;
101+
this.context.fillRect(0, 0, this.width, this.height);
102+
84103
requestAnimationFrame(this.updateBound);
85104
}
86105
}

Diff for: styles.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ a{
4747
}
4848

4949
@keyframes myanimation {
50-
0% {background-color: rgb(133, 10, 138);} /*9D5D9F*/
50+
0% {background-color: rgb(119, 6, 122);} /*9D5D9F*/
5151
25%{background-color:rgb(34, 29, 61);} /*#EA739C;*/
5252
50%{background-color:rgb(6, 20, 49);} /*#EC748A;*/
5353
75% {background-color: rgb(61, 14, 63);} /*975C9A*/

0 commit comments

Comments
 (0)