OLD | NEW |
1 part of sprites; | 1 part of sprites; |
2 | 2 |
3 double degrees2radians(double degrees) => degrees * Math.PI/180.8; | 3 double degrees2radians(double degrees) => degrees * Math.PI/180.8; |
4 | 4 |
5 double radians2degrees(double radians) => radians * 180.0/Math.PI; | 5 double radians2degrees(double radians) => radians * 180.0/Math.PI; |
6 | 6 |
7 class TransformNode { | 7 class TransformNode { |
8 Vector2 _position; | 8 Vector2 _position; |
9 double _rotation; | 9 double _rotation; |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 prePaint(canvas); | 116 prePaint(canvas); |
117 paint(canvas); | 117 paint(canvas); |
118 visitChildren(canvas); | 118 visitChildren(canvas); |
119 postPaint(canvas); | 119 postPaint(canvas); |
120 } | 120 } |
121 | 121 |
122 void prePaint(PictureRecorder canvas) { | 122 void prePaint(PictureRecorder canvas) { |
123 canvas.save(); | 123 canvas.save(); |
124 | 124 |
125 canvas.translate(_position[0], _position[1]); | 125 canvas.translate(_position[0], _position[1]); |
126 canvas.rotateDegrees(_rotation); | 126 canvas.rotate(degrees2radians(_rotation)); |
127 canvas.translate(-_width*_pivot[0], -_height*_pivot[1]); | 127 canvas.translate(-_width*_pivot[0], -_height*_pivot[1]); |
128 | 128 |
129 // TODO: Use transformation matrix instead of individual calls | 129 // TODO: Use transformation matrix instead of individual calls |
130 // List<double> matrix = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; | 130 // List<double> matrix = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; |
131 // this.transformMatrix.copyIntoArray(matrix); | 131 // this.transformMatrix.copyIntoArray(matrix); |
132 // canvas.concat(matrix); | 132 // canvas.concat(matrix); |
133 } | 133 } |
134 | 134 |
135 void paint(PictureRecorder canvas) { | 135 void paint(PictureRecorder canvas) { |
136 | 136 |
137 } | 137 } |
138 | 138 |
139 void visitChildren(PictureRecorder canvas) { | 139 void visitChildren(PictureRecorder canvas) { |
140 children.forEach((child) => child.visit(canvas)); | 140 children.forEach((child) => child.visit(canvas)); |
141 } | 141 } |
142 | 142 |
143 void postPaint(PictureRecorder canvas) { | 143 void postPaint(PictureRecorder canvas) { |
144 canvas.restore(); | 144 canvas.restore(); |
145 } | 145 } |
146 | 146 |
147 void update(double dt) { | 147 void update(double dt) { |
148 | 148 |
149 } | 149 } |
150 } | 150 } |
OLD | NEW |