This is a fork of the awesome chainify library (https://gist.github.com/gists/1466219).
I made it because I don't like with().
bonus: It's much faster! http://jsperf.com/chaining-mehods
demo here: http://jsfiddle.net/ce25R/3/
This is a fork of the awesome chainify library (https://gist.github.com/gists/1466219).
I made it because I don't like with().
bonus: It's much faster! http://jsperf.com/chaining-mehods
demo here: http://jsfiddle.net/ce25R/3/
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This is a fork of a function by MathRobin. It's a bit longer, but it's made to work in older browsers that don't support indexOf.
Adds vendor prefix when needed.
Thanks to Evghenusi for minification tips
I always thought there was a better way to access the dom. This is a tool that allows you to use extremely simple syntax to access dom elements. It makes an object with the name of your choice (I chose "$") that contains a reference to all elements that have an id.
example:
<script> $.foo.innerHTML = "Hello world" </script>
You can even choose to use an object that already exists (I chose "document" because it makes sense)
A function to get rid of the stupid "Math" object once and for all!
It allows this sort of syntax:
myVariable = floor(myVariable)
myOtherVariable = random()
This is a function to calculate the appropriate unit to describe a file size. If you want a fancier function, try this function: https://gist.github.com/2202887 by @vitronprince
Thanks to maettig for minification tips.
<!DOCTYPE html> | |
<title>terrain test</title> | |
<body onkeydown=keys(1,event) onkeyup=keys(0,event)> | |
<script> | |
var CANVAS_WIDTH=480, CANVAS_HEIGHT=320, FPS = 30; | |
var keydownleft=0, keydownright=0 ,keydownspace=0 ,keydownup=0 ,keydowndown=0; | |
//mathglobalizr: https://gist.github.com/2221488 |
This function checks if a canvas pixel is black.
This is very useful for making pixel-perfect collisions in a javascript game.
argument x and y are for the coordinates of said pixel.
argument c is for the canvas context.
Function to check if 2 objects collide. Very useful for games.
arguments:
a: object 1 x
b: object 1 y