This file contains 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
/** | |
* @author Kevin Moot | |
*/ | |
Marker.prototype.hitTest = function(point) { | |
return Util.pointInCircle(point, this.positionCenter, this.radiusSquared); | |
}; | |
Util.pointInCircle = function(point, circleCenter, circleRadiusSquared) { | |
// determine vector between center of circle and mouse position |
This file contains 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
/** | |
* A simple object for creating pre-rendered Canvas elements on the fly without | |
* creating a mess in your files. | |
* @author Ash Blue [email protected] | |
* @link http://blueashes.com | |
* | |
* @example | |
* // Create a new pre-renderd Canvas and draw on it (width, height, drawLogic) | |
* var myPreRender = new PreRender(50, 50, function (ctx) { | |
* ctx.fillStyle = '#000'; |
This file contains 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
/** | |
* Calculates the distqance between two vertices and returns the value | |
* @param {array} startVert Start x and y point | |
* @param {array} endVert End x and y point | |
* @returns {number} | |
*/ | |
function distanceBetweenPoints (startVert, endVert) { | |
return Math.sqrt(Math.pow(endVert[0] - startVert[0], 2) + Math.pow(endVert[1] - startVert[1], 2)); | |
} |
This file contains 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
/** | |
* Calculates the angle between two separate points. 0 degrees points up and 180 degrees points down | |
* @link https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2 | |
* @link http://stackoverflow.com/questions/3309617/calculating-degrees-between-2-points-with-inverse-y-axis | |
* @param {object} start Beginning vertex formatted as {x, y} | |
* @param {object} end End vertex formatted as {x, y} | |
* @returns {number} Returns a counterclockwise angle, measured in radians | |
*/ | |
function angleBetweenPoints (start, end) { | |
// find angle |
This file contains 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
/** | |
* Moves a vertex at an angle for a specific distance, 0 degrees points up and 180 degrees points down | |
* @param {array} point Location on a cartesian graph formatted as [x, y] | |
* @param {number} angle Angle at which a point should move in radians | |
* @param {number} distance How far should the point move at the given angle in pixels? | |
* @returns {array} Newly moved point formatted as [x, y] | |
*/ | |
function movePointAtAngle (point, angle, distance) { | |
return [ | |
point[0] + (Math.sin(angle) * distance), |
This file contains 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
/** | |
* Goes through the given directory to return all files and folders recursively | |
* @author Ash Blue [email protected] | |
* @example getFilesRecursive('./folder/sub-folder'); | |
* @requires Must include the file system module native to NodeJS, ex. var fs = require('fs'); | |
* @param {string} folder Folder location to search through | |
* @returns {object} Nested tree of the found files | |
*/ | |
// var fs = require('fs'); | |
function getFilesRecursive (folder) { |
This file contains 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
/** | |
* Detects if the vertex point's x and y are inside of a circle. Only works with | |
* plain symetrical circles, not ovals | |
* @link Adapted from http://stackoverflow.com/questions/2212604/javascript-check-mouse-clicked-inside-the-circle-or-polygon#answer-2212678 | |
* @param {array|number} point Point to test, formatted as [x, y] | |
* @param {array|number} circleCenter Center of the circle formatted as [x, y] | |
* @param {number} radius Radius of the circle, which calculates as half its with or height | |
* @returns {boolean} True if the point is contained in the circle | |
*/ | |
function pointInCircle (point, circleCenter, radius) { |
This file contains 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
/** | |
* Turns a number into a more readable format with commas | |
* @param {number} num Number for conversion | |
* @returns {string} Readable number such as 700,345,384 | |
*/ | |
function setCommas (num) { | |
var letters = (num).toString().split(''), | |
count = 0, | |
readableNum = ''; |
This file contains 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
# Rails 3 | |
# Place in lib/tasks/helloworld.rake | |
# Call via "rake hello:world" | |
# Primary name of the rake job you'll call | |
namespace :hello do | |
# Task of the rake job, can support multiple tasks | |
task :world do | |
print 'hello world' | |
end |
This file contains 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 wk = wk || {}; | |
$(document).ready(function () { | |
var _monthNames = [ | |
'January', | |
'February', | |
'March', | |
'April', | |
'May', | |
'June', |