|
12 | 12 | Snowflake.prototype.tick = function() { |
13 | 13 | var sidePhase = this.sidePhase += this.sideVel; |
14 | 14 | this.y += this.vel; |
15 | | - this.x = this.midX + Math.sin(sidePhase) * this.sideAmp; |
| 15 | + this.x += this.sideVel; |
16 | 16 | }; |
17 | 17 | Snowflake.prototype.reset = function(maxX) { |
18 | 18 | var rand = Math.random(); |
19 | | - var sizeRand; |
20 | 19 | var chanceOfLargeSnowflake = 0.15; |
21 | 20 |
|
22 | | - if (Math.random() < chanceOfLargeSnowflake) { |
23 | | - sizeRand = Math.random() * 0.9 + 0.1; |
24 | | - } |
25 | | - else { |
26 | | - sizeRand = Math.random() * 0.1; |
27 | | - } |
28 | | - |
29 | | - this.size = sizeRand * 20 + 2.5; |
30 | | - this.vel = sizeRand * 4 + 1; |
31 | | - this.alpha = (1 - sizeRand * 0.9); |
| 21 | + this.size = 2 + Math.random() * 5; |
| 22 | + this.vel = 3 + Math.random() * 3; |
| 23 | + this.alpha = 0.5 + Math.random() * 0.8; |
32 | 24 |
|
33 | 25 | // random x position |
34 | | - this.midX = Math.random() * maxX; |
| 26 | + this.x = Math.random() * maxX; |
35 | 27 | this.y = -this.size; |
36 | 28 |
|
37 | 29 | // side-to-side movement |
38 | | - this.sidePhase = 0; |
39 | | - this.sideAmp = sizeRand * 40; |
40 | | - this.sideVel = Math.random() * 0.05; |
| 30 | + this.sideVel = (0.5 - Math.random()) * this.vel; |
41 | 31 |
|
42 | | - this.x = 0; |
43 | 32 |
|
44 | 33 | return this; |
45 | 34 | }; |
|
53 | 42 | var settleCanvasStyle = settleCanvas.style; |
54 | 43 | var windowResized; |
55 | 44 | var activeFlakes = []; |
56 | | - var snowflakesPerPixelPerSecond = 0.02; |
| 45 | + var snowflakesPerPixelPerSecond = 0.05; |
57 | 46 | var PIx2 = Math.PI*2; |
58 | 47 | var assumedFps = 60; |
59 | 48 | var settlePoint; |
|
75 | 64 | range += xStart; |
76 | 65 | xStart = 0; |
77 | 66 | } |
78 | | - else if (xStart + range > settlePoint.length) { |
| 67 | + if (xStart + range > settlePoint.length) { |
79 | 68 | range -= xStart + range - settlePoint.length; |
80 | 69 | } |
81 | 70 |
|
|
109 | 98 | activeFlakes.push( new Snowflake(canvas.width) ); |
110 | 99 | } |
111 | 100 | } |
112 | | - |
| 101 | + |
113 | 102 | var i = activeFlakes.length; |
114 | 103 | var flake; |
115 | 104 |
|
|
0 commit comments