Draws a mandelbrot fractal on a canvas.
usage:
mandelbrot(imageData,width)
Thanks to @atk for doing most of the minification work!
Draws a mandelbrot fractal on a canvas.
usage:
mandelbrot(imageData,width)
Thanks to @atk for doing most of the minification work!
Add parallax scrolling to a page's background.
Returns a string that formats time in a smart manner. If minutes is lower than 10, prepend a "0" to the minutes. If hours is in the afternoon, convert it to PM mode.
Thanks to xpansive for minification tips.
Function to check if 2 objects collide. Very useful for games.
arguments:
a: object 1 x
b: object 1 y
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.
<!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 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.
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()
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)
Adds vendor prefix when needed.
Thanks to Evghenusi for minification tips