Created
September 6, 2010 20:57
-
-
Save getify/567511 to your computer and use it in GitHub Desktop.
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
| // shorten/alias long canvas method names | |
| // adapted from: http://marijn.haverbeke.nl/js1k.html | |
| var Canv = document.body.children.c, | |
| Gr = Canv.getContext("2d"), | |
| prop | |
| ; | |
| for (prop in Gr) { | |
| Gr[ prop[0] + (prop[3]||"") + (prop[6]||"") ] = Gr[prop]; | |
| } | |
| /* | |
| arc => a | |
| arcTo => aT | |
| beginPath => bia | |
| bezierCurveTo => biC | |
| clearRect => cae | |
| clearShadow => cah | |
| createImageData => caI | |
| createLinearGradient => caL | |
| createPattern => caP | |
| createRadialGradient => caR | |
| clip => cp | |
| closePath => csa | |
| canvas => cv | |
| drawImage => dwa ******** | |
| drawImageFromRect => dwa ******** | |
| fill => fl | |
| fillRect => flc | |
| fillText => flx | |
| fillStyle => fly | |
| font => ft | |
| globalAlpha => gbA | |
| globalCompositeOperation => gbC | |
| getImageData => gIg | |
| isPointInPath => iot | |
| lineTo => le | |
| lineWidth => led | |
| lineJoin => lei | |
| lineCap => lep | |
| moveTo => me | |
| miterLimit => mei | |
| measureText => mse | |
| putImageData => pIg | |
| quadraticCurveTo => qdt | |
| rotate => ra | |
| rect => rt | |
| restore => rte | |
| setAlpha => sAh | |
| setCompositeOperation => sCp | |
| shadowBlur => sdB | |
| shadowColor => sdC | |
| shadowOffsetY => sdO ******** | |
| shadowOffsetX => sdO ******** | |
| save => se | |
| setFillColor => sFl | |
| scale => sl | |
| setLineWidth => sLe ******** | |
| setLineCap => sLe ******** | |
| setLineJoin => sLe ******** | |
| setMiterLimit => sMe | |
| stroke => so | |
| strokeRect => soR | |
| strokeStyle => soS | |
| strokeText => soT | |
| setShadow => sSd | |
| setStrokeColor => sSo | |
| setTransform => sTn | |
| translate => tna | |
| transform => tno | |
| textAlign => tti | |
| textBaseline => tts | |
| */ |
Author
I'd say this is also useless for minifiers. Browser-specific extensions can easily cause conflicts and break this. Gimmicky contests seem to be the only real use ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
clearly this particular hashing algorithm, with collisions, is not acceptable. but maybe one similar to it would be good enough to not create collisions, and therefore be useful in the task.