| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 (function() { | 4 (function() { |
| 5 'use strict'; | 5 'use strict'; |
| 6 /** | 6 /** |
| 7 * T-Rex runner. | 7 * T-Rex runner. |
| 8 * @param {string} outerContainerId Outer containing element id. | 8 * @param {string} outerContainerId Outer containing element id. |
| 9 * @param {object} opt_config | 9 * @param {object} opt_config |
| 10 * @constructor | 10 * @constructor |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 canvas.width = oldWidth * ratio; | 786 canvas.width = oldWidth * ratio; |
| 787 canvas.height = oldHeight * ratio; | 787 canvas.height = oldHeight * ratio; |
| 788 | 788 |
| 789 canvas.style.width = oldWidth + 'px'; | 789 canvas.style.width = oldWidth + 'px'; |
| 790 canvas.style.height = oldHeight + 'px'; | 790 canvas.style.height = oldHeight + 'px'; |
| 791 | 791 |
| 792 // Scale the context to counter the fact that we've manually scaled | 792 // Scale the context to counter the fact that we've manually scaled |
| 793 // our canvas element. | 793 // our canvas element. |
| 794 context.scale(ratio, ratio); | 794 context.scale(ratio, ratio); |
| 795 return true; | 795 return true; |
| 796 } else if (devicePixelRatio == 1) { |
| 797 // Reset the canvas width / height. Fixes scaling bug when the page is |
| 798 // zoomed and the devicePixelRatio changes accordingly. |
| 799 canvas.style.width = canvas.width + 'px'; |
| 800 canvas.style.height = canvas.height + 'px'; |
| 796 } | 801 } |
| 797 return false; | 802 return false; |
| 798 }; | 803 }; |
| 799 | 804 |
| 800 | 805 |
| 801 /** | 806 /** |
| 802 * Get random number. | 807 * Get random number. |
| 803 * @param {number} min | 808 * @param {number} min |
| 804 * @param {number} max | 809 * @param {number} max |
| 805 * @param {number} | 810 * @param {number} |
| (...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 | 2249 |
| 2245 /** | 2250 /** |
| 2246 * Add a new cloud to the horizon. | 2251 * Add a new cloud to the horizon. |
| 2247 */ | 2252 */ |
| 2248 addCloud: function() { | 2253 addCloud: function() { |
| 2249 this.clouds.push(new Cloud(this.canvas, this.cloudImg, | 2254 this.clouds.push(new Cloud(this.canvas, this.cloudImg, |
| 2250 this.dimensions.WIDTH)); | 2255 this.dimensions.WIDTH)); |
| 2251 } | 2256 } |
| 2252 }; | 2257 }; |
| 2253 })(); | 2258 })(); |
| OLD | NEW |