Initialize properly and otherwise clean up gewgaw implementation.
Chris Pressey
3 years ago
6 | 6 | this.ctx.strokeStyle = "black"; |
7 | 7 | this.ctx.globalCompositeOperation = 'source-over'; |
8 | 8 | this.dist = 5; |
9 | this.deltaTheta = 90; | |
10 | this.setStyle('opaque'); | |
9 | 11 | |
10 | 12 | this.startIndex = 0; |
11 | 13 | this.endIndex = 10000; |
31 | 33 | } |
32 | 34 | var $this = this; |
33 | 35 | var stepFunction = function() { |
34 | $this.step(); | |
36 | $this.draw(); | |
35 | 37 | setTimeout(stepFunction, 0); |
36 | 38 | } |
37 | 39 | this.intervalID = setTimeout(stepFunction, 0); |
43 | 45 | var num = this.sequence[this.index]; |
44 | 46 | |
45 | 47 | if (num === 1) { |
46 | // FD 10 | |
48 | // Go forward | |
47 | 49 | var rad = (this.theta / 360) * (Math.PI * 2); |
48 | 50 | |
49 | 51 | var dx = this.dist * Math.cos(rad); |
60 | 62 | this.x = newX; |
61 | 63 | this.y = newY; |
62 | 64 | } else if (num === 2) { |
63 | // RT 90 | |
64 | this.theta += 90; | |
65 | // Turn right | |
66 | this.theta += this.deltaTheta; | |
65 | 67 | while (this.theta >= 360) this.theta -= 360; |
66 | 68 | } else { |
67 | 69 | alert('wtf'); |
81 | 83 | for (var j = 0; j < this.stepSize; j++) { |
82 | 84 | this.step(); |
83 | 85 | } |
84 | }; | |
85 | ||
86 | this.update = function() { | |
87 | 86 | }; |
88 | 87 | |
89 | 88 | /* |