This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a = 33.3, b = 43.7; | |
| var n = new Float32Array(2); | |
| n[0] = a; | |
| n[1] = b; | |
| console.log(a / b, n[0] / n[1]); | |
| // Console: 0.7620137299771166, 0.7620136992148795 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| We remove the operators, just keep the order of digits. | |
| 0123 1230 2013 | |
| 0321 0123 2301 | |
| 1302 0123 0123 | |
| Instant memorize the repeated numbers, so you are left with | |
| 1230 2013 | |
| 0321 2301 | |
| 1302 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function GenMatrix(rows, cols) { | |
| function Matrix() { | |
| // Whatever prefered way of storing you may have. | |
| this.nums = new Array(rows * cols); | |
| } | |
| if(rows == 2 && cols == 2) { | |
| Matrix.prototype.inverse = function() { | |
| // optimize matrix inverse code for 2x2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class actor { | |
| x = 100; | |
| y = 100; | |
| rotate = 45 degrees; | |
| scale = 2; | |
| draw(renderer) { | |
| renderer.drawrectangle(0, 0, 100, 100); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class actor { | |
| x = 100; | |
| y = 100; | |
| draw(renderer) { | |
| renderer.drawpixel(0, 0); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass[11pt, a4paper, twoside, onecolumn]{book} | |
| %\columnsep +30pt | |
| \usepackage[margin=70pt]{geometry} | |
| \usepackage{graphicx} | |
| \usepackage{verbatim} | |
| \usepackage{wrapfig} | |
| \usepackage[font={it}]{caption} | |
| \usepackage{pgf-pie} | |
| \usepackage{tabu} | |
| \usepackage{url} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function DeltaRelativeRadians(a, b) { | |
| var delta = b - a; | |
| return delta + ((delta > Math.PI) ? -Math.TwoPI : (delta < -Math.PI) ? Math.TwoPI : 0) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function.prototype.derp = function() { | |
| console.log("derp!"); | |
| return this; | |
| } | |
| // A functions with methods? Sure. | |
| var m = function () { | |
| console.log("whoop"); | |
| }.derp(); // prints "derp!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function MehBuilder() { | |
| // Ok... using an array b.c. strings are immutable. | |
| var foo = Meh.foo = ["derp"]; | |
| function Meh() { | |
| console.log(foo[0]); | |
| } | |
| return Meh; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| color = "rgba(" + lerpInt(particle.colorA[0], particle.colorB[0], t) + ", " + | |
| lerpInt(particle.colorA[1], particle.colorB[1], t) + ", " + | |
| lerpInt(particle.colorA[2], particle.colorB[2], t) + ", " + | |
| lerpFloat(particle.colorA[3], particle.colorB[3], t) + ")"; |