Skip to content

Instantly share code, notes, and snippets.

View hongymagic's full-sized avatar
🤪

David Hong hongymagic

🤪
View GitHub Profile
@hongymagic
hongymagic / THE_NORTH_FACE.logo.js
Created July 25, 2011 13:10
Draws half dome "THE NORTH FACE" logo on HTML5 Canvas
/**
* Draw "THE NORTH FACE" thrice half-dome logo
*
* usage:
* THE_NORTH_FACE.draw(
* context // canvas.getContext('2d')
* x, // x center of the dome
* y, // y center of the dome
* width, // width of the dome
@hongymagic
hongymagic / CanvasRenderingContext2D.renderText.js
Created July 27, 2011 04:25
CanvasRenderingContext2D fillText with letter-spacing support
/**
* CanvasRenderingContext2D.renderText extension
*/
if (CanvasRenderingContext2D && !CanvasRenderingContext2D.renderText) {
// @param letterSpacing {float} CSS letter-spacing property
CanvasRenderingContext2D.prototype.renderText = function (text, x, y, letterSpacing) {
if (!text || typeof text !== 'string' || text.length === 0) {
return;
}
@hongymagic
hongymagic / css.parser.js
Created August 2, 2011 04:02
A Simple CSS Properties parser
///
/// CSS Parser method
///
/// @param css-properties {String} Semi-colon delimitered CSS properties
/// @returns {Object} JSON-style name/value pair
///
/// @usage:
/// parse('font-weight: 700; font-size: 1em', 'font-family: Verdana, sans-serif');
///
/// This is a pretty inefficient way of parsing CSS properties. The purpose here
@hongymagic
hongymagic / SF-Logo.raphael.js
Created December 19, 2011 03:50
SF Logo (svg and Raphael)
var
container = 'rsr',
scale = 1.00, /* TODO: doesn't work atm */
width = 170.48 * scale,
height = 203.22 * scale,
rsr = Raphael(container, width, height),
background,
lower,
@hongymagic
hongymagic / dabblet.css
Created December 19, 2011 06:21
BonBon+
/**
* BonBon+
*
* This is an improvement over BonBon CSS3 buttons
*
* @see: http://lab.simurai.com/css/buttons/
*/
/* Fonts being used */
@import url(http://fonts.googleapis.com/css?family=Droid+Sans:bold+Lobster);
@hongymagic
hongymagic / dabblet.css
Created December 20, 2011 03:27
BonBon+
/**
* BonBon+
*
* This is an improvement over BonBon CSS3 buttons
*
* @see: http://lab.simurai.com/css/buttons/
*/
/* Fonts being used */
@import url(http://fonts.googleapis.com/css?family=Droid+Sans:bold+Lobster);
/**
* BonBon+
*
* This is an improvement over BonBon CSS3 buttons
*
* @see: http://lab.simurai.com/css/buttons/
*/
/* Fonts being used */
@import url(http://fonts.googleapis.com/css?family=Droid+Sans:bold+Lobster);
@hongymagic
hongymagic / dabblet.css
Created January 10, 2012 00:01
css quiz 8
/**
* css quiz 8
* http://cssquiz.com/q8-theres-a-fire-starting-in-my-heart
*/
div {
width: 100px; height: 100px;
line-height: 100px;
text-align: center;
@hongymagic
hongymagic / log.js
Created January 10, 2012 03:37
Simple log wrapper which prints line numbers...
window.log = (function (console) {
'use strict';
var COUNT = 0;
return function () {
var args = Array.prototype.slice.call(arguments),
line = [++COUNT + ':'];
if (typeof console === 'object') {
@hongymagic
hongymagic / UserAgentAPI.js
Created January 15, 2012 12:57
Agent Smith's new storage interface for user-settings
/**
* UserAgent storage object
*
* Use this object to set, get, and delete user agent information
* TODO: sub-type global/tabs/url get/set/delete
*/
var UserAgent = (function (localStorage) {
'use strict';
var