From 0aa48d0503c69c9ebc1d2bb209bfbec10e8bed64 Mon Sep 17 00:00:00 2001 From: Bryan Berry Date: Wed, 17 Feb 2010 09:39:34 +0000 Subject: initial commit. Lesson English_Animal_Identification is current template --- (limited to 'docs/symbols/Karma.html') diff --git a/docs/symbols/Karma.html b/docs/symbols/Karma.html new file mode 100755 index 0000000..5db7dd2 --- /dev/null +++ b/docs/symbols/Karma.html @@ -0,0 +1,1505 @@ + + + + + + + JsDoc Reference - Karma + + + + + + + + + + + +
+ +
Class Index +| File Index
+
+

Classes

+ +
+ +
+ +
+ +

+ + Namespace Karma +

+ + +

+ + + + Global namespace for Karma library + + +
Defined in: karma.js. + +

+ + + + + + + + + + + + + + + + + +
Namespace Summary
Constructor AttributesConstructor Name and Description
  +
+ Karma +
+
Karma is the namespace for the Karma library and Karma() is the constructor +function for the Karma library object Karma.
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field Summary
Field AttributesField Name and Description
<static>   +
+ Karma.audio +
+
Collection of audio files with special helper +methods added to each reference
+
<static>   +
+ Karma.canvas +
+
Collection of html 5 canvases with special helper +methods added to each reference
+
<static>   +
+ Karma.image +
+
Collection of images with special helper +methods added to each reference
+
<static>   +
+ Karma.locale +
+
This is the global locale as passed to Karma(), +such as "en", "es_SP"
+
<static>   +
+ Karma.svg +
+
Collection of svgs with special helper +methods added to each reference
+
<static>   +
+ Karma.video +
+
Collection of videos with special helper +methods added to each reference
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method Summary
Method AttributesMethod Name and Description
<static>   +
Karma._n(Number, locale) +
+
+
<static>   +
Karma.clone(target) +
+
Returns a shallow copy of the passed in object
+
<static>   +
Karma.convertNumToLocale(Number, locale) +
+
Converts a number to numerals in the specified locale.
+
<static>   +
Karma.copyObjectPlus(parent1, parent2) +
+
Creates a new object that is a prototype of the first argument +then extends it with the properties of the second argument
+
<static>   +
Karma.create(parent) +
+
This emulates the Object.create method in ecmascript 5 spec +This isn't a full implementation as it doesn't support an all of Object.create's features +This has the same functionality as Crockford's beget method +and this primary building block for prototypal inheritance in +this library
+
<static>   +
Karma.distance(Point, Point) +
+
Gets the Euclidian (ordinary) distance between 2 points.
+
<static>   +
Karma.distance2(Point, Point) +
+
Gets the square of the Euclidian (ordinary) distance between 2 points.
+
<static>   +
Karma.objectPlus(target, source) +
+
Extends properties of the target object with those of +the source object
+
<static>   +
Karma.radians(angle) +
+
Converts a value from degrees to radians.
+
<static>   +
Karma.rand(lower, upper) +
+
Returns a random number within the range provided
+
<static>   +
Karma.ready(cb) +
+
Waits until all assets loaded(ready), then calls callback cb
+
<static>   +
Karma.shuffle(oldList) +
+
Shuffles an array of items randomly
+
+ + + + + + + + + +
+
+ Namespace Detail +
+ +
+ Karma +
+ +
+ Karma is the namespace for the Karma library and Karma() is the constructor +function for the Karma library object Karma. +Karma() checks if the current document type is set to HTML 5, throws +an error if not. Otherwise, initializes the karma object and returns +a reference to that object. + +
+ + + +
+var k = Karma({ 
+                image: [ 
+                   {name: "ninja", file: "ninja.png"}, 
+                   {name: "cowboy", file: "cowboy.png"}
+                        ],
+                audio: [
+                   {name: "woosh", file: "woosh.ogg"},
+                   {name: "yeehaw", file: "yeehaw.ogg"}
+                        ],
+                video: [  //Not Yet Implemented
+                   {name: "attack", file: "attack.ogv"},
+                   {name: "ride", file: "ride.ogv"}
+                        ]
+                canvas: [
+                   {name: "ninja", domId: "ninjaCanvas"},
+                   {name: "cowboy", domId: "cowboyCanvas"}
+                        ],
+                svg: [ 
+                   {name: "ninja", domId: "ninjaSvg"},
+                   {name: "cowboy", domId: "cowboySvg"}
+                        ],
+                });
+Next, call the ready function with a callback to your program code
+
+k.ready(function () { ... your application code . . . }                       
+
+after that you can access each asset like so
+k.image.ninja;
+k.svg.cowboy;
+k.audio.yeehaw.play();
+k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ + + + + +
+
Parameters:
+ +
+ {Object} options + Optional, Default: {} +
+
options for intializing Karma library
+ +
+ {String} options.locale + Optional, Default: '' +
+
sets current locale Not Yet Implemented
+ +
+ {Array} options.image + Optional, Default: [] +
+
array of images to be converted into a collection
+ +
+ {Array} options.audio + Optional, Default: [] +
+
array of audio to be converted into a collection
+ +
+ {Array} options.video + Optional, Default: [] +
+
NYI array of videos to be converted into a collection
+ +
+ {Array} options.svg + Optional, Default: [] +
+
array of SVG elements to be +converted into a collection. Each SVG element must already exist in the html document
+ +
+ {Array} options.canvas + Optional, Default: [] +
+
array of canvas elements +to be converted into a collection. Each canvas element must already exist in the +html document and width and height of each element must be set as attributes
+ +
+ + + + +
+
Throws:
+ +
+ {Error} +
+
if the document type declaration is not set to HTML 5, e.g. +
+ +
+ {Error} +
+
If any of the initialization parameters are invalid values
+ +
+ + +
+
Returns:
+ +
{Object} Karma -- reference to the initialized Karma library
+ +
+ + + + +
+ + + + +
+ Field Detail +
+ + +
<static> + + {object} + Karma.audio + +
+
+ Collection of audio files with special helper +methods added to each reference + + +
+ + + + + + + +
+
Default Value:
+
+ empty object +
+
+ + +
+ + +
<static> + + {object} + Karma.canvas + +
+
+ Collection of html 5 canvases with special helper +methods added to each reference + + +
+ + + + + + + +
+
Default Value:
+
+ empty object +
+
+ + +
+ + +
<static> + + {object} + Karma.image + +
+
+ Collection of images with special helper +methods added to each reference + + +
+ + + + + + + +
+
Default Value:
+
+ empty object +
+
+ + +
+ + +
<static> + + + Karma.locale + +
+
+ This is the global locale as passed to Karma(), +such as "en", "es_SP" + + +
+ + + + + + + +
+
Default Value:
+
+ 'en' +
+
+ + +
+ + +
<static> + + {object} + Karma.svg + +
+
+ Collection of svgs with special helper +methods added to each reference + + +
+ + + + + + + +
+
Default Value:
+
+ empty object +
+
+ + +
+ + +
<static> + + {object} + Karma.video + +
+
+ Collection of videos with special helper +methods added to each reference + + +
+ + + + + + + +
+
Default Value:
+
+ empty object +
+
+ + + + + + + + +
+ Method Detail +
+ + +
<static> + + {String} + Karma._n(Number, locale) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ {Number} Number + +
+
to be converted
+ +
+ {locale} locale + +
+
that number should be converted to
+ +
+ + + + + +
+
Returns:
+ +
{String} Unicode string for localized numeral
+ +
+ + + + +
+ + +
<static> + + {Object} + Karma.clone(target) + +
+
+ Returns a shallow copy of the passed in object + + +
+ + + + +
+
Parameters:
+ +
+ {Object} target + +
+
to be copied
+ +
+ + + + + +
+
Returns:
+ +
{Object} a shallow copy of target
+ +
+ + + + +
+ + +
<static> + + {String} + Karma.convertNumToLocale(Number, locale) + +
+
+ Converts a number to numerals in the specified locale. Currently only +supports Nepali + + +
+ + + + +
+
Parameters:
+ +
+ {Number} Number + +
+
to be converted
+ +
+ {locale} locale + +
+
that number should be converted to
+ +
+ + + + + +
+
Returns:
+ +
{String} Unicode string for localized numeral
+ +
+ + + + +
+ + +
<static> + + {Object} + Karma.copyObjectPlus(parent1, parent2) + +
+
+ Creates a new object that is a prototype of the first argument +then extends it with the properties of the second argument + + +
+ + + + +
+
Parameters:
+ +
+ {Object} parent1 + +
+
will be prototype of returned object
+ +
+ {Object} parent2 + +
+
will extend properties of returned object
+ +
+ + + + + +
+
Returns:
+ +
{Object} object that whose prototype is parent1 and has +been extended with properties of parent2
+ +
+ + + + +
+ + +
<static> + + {Object} + Karma.create(parent) + +
+
+ This emulates the Object.create method in ecmascript 5 spec +This isn't a full implementation as it doesn't support an all of Object.create's features +This has the same functionality as Crockford's beget method +and this primary building block for prototypal inheritance in +this library + + +
+ + + +
+var ninja = { weapon : "sword" };
+var ninja1 = Karma.create(ninja);
+ninja1.weapon === "sword"
+ + + + +
+
Parameters:
+ +
+ {Object} parent + +
+
that the new object's prototype should point to
+ +
+ + + + + +
+
Returns:
+ +
{Object} a new object whose prototype is parent
+ +
+ + + + +
+ + +
<static> + + {Number} + Karma.distance(Point, Point) + +
+
+ Gets the Euclidian (ordinary) distance between 2 points.
+Warning: It's slower than distance2 function + + +
+ + + +
+p0 = {x:0, y:1};
+p1 = {x:50, y:70};
+var d = distance2(p0, p1);
+ + + + +
+
Parameters:
+ +
+ {Object} Point + +
+
No. 0
+ +
+ {Number} Point0.x + +
+
+ +
+ {Number} Point0.y + +
+
+ +
+ {Object} Point + +
+
No. 1
+ +
+ {Number} Point1.x + +
+
+ +
+ {Number} Point1.y + +
+
+ +
+ + + + + +
+
Returns:
+ +
{Number} The Euclidian distance
+ +
+ + + + +
+ + +
<static> + + {Number} + Karma.distance2(Point, Point) + +
+
+ Gets the square of the Euclidian (ordinary) distance between 2 points. + + +
+ + + +
+p0 = {x:0, y:1};
+p1 = {x:50, y:70};
+var d = distance2(p0, p1);
+ + + + +
+
Parameters:
+ +
+ {Object} Point + +
+
No. 0
+ +
+ {Number} Point0.x + +
+
+ +
+ {Number} Point0.y + +
+
+ +
+ {Object} Point + +
+
No. 1
+ +
+ {Number} Point1.x + +
+
+ +
+ {Number} Point1.y + +
+
+ +
+ + + + + +
+
Returns:
+ +
{Number} The square of the Euclidian distance
+ +
+ + + + +
+ + +
<static> + + {Object} + Karma.objectPlus(target, source) + +
+
+ Extends properties of the target object with those of +the source object + + +
+ + + + +
+
Parameters:
+ +
+ {Object} target + +
+
object to be extended
+ +
+ {Object} source + +
+
whose properties will extend target
+ +
+ + + + + +
+
Returns:
+ +
{Object} target extended by source
+ +
+ + + + +
+ + +
<static> + + {Number} + Karma.radians(angle) + +
+
+ Converts a value from degrees to radians. + + +
+ + + + +
+
Parameters:
+ +
+ {Number} angle + +
+
The angle in degrees
+ +
+ + + + + +
+
Returns:
+ +
{Number} The angle in radians
+ +
+ + + + +
+ + +
<static> + + {Number} + Karma.rand(lower, upper) + +
+
+ Returns a random number within the range provided + + +
+ + + +
+var num = rand(0, 10);
+
+//num could be 0, 1, 2, 3 ... or 10
+ + + + +
+
Parameters:
+ +
+ {Number} lower + +
+
limit of the range, lowest number that can be returned
+ +
+ {Number} upper + +
+
limit of the range, highest number that can be returned
+ +
+ + + + + +
+
Returns:
+ +
{Number} number that is >= lower and <= upper
+ +
+ + + + +
+ + +
<static> + + + Karma.ready(cb) + +
+
+ Waits until all assets loaded(ready), then calls callback cb + + +
+ + + +
+var k = Karma({ . . . your assets here . . . });
+k.ready(function(){ .. your code here . . .});
+
+your code will not be called until all assets have been loaded
+into collections
+ + + + +
+
Parameters:
+ +
+ {Function} cb + Optional +
+
callback function
+ +
+ + + + +
+
Throws:
+ +
+ {Error} +
+
if Karma is not initialized with the +Karma({ options }) function
+ +
+ + +
+
Returns:
+ +
this
+ +
+ + + + +
+ + +
<static> + + {Array} + Karma.shuffle(oldList) + +
+
+ Shuffles an array of items randomly + + +
+ + + + +
+
Parameters:
+ +
+ {Array} oldList + +
+
of choices to be shuffled
+ +
+ + + + + +
+
Returns:
+ +
{Array} newlist of choices randomly reordered
+ +
+ + + + + + + + + + + +
+
+ + + +
+ + Documentation generated by JsDoc Toolkit 2.3.2 on Wed Feb 17 2010 14:55:42 GMT+0545 (NPT) +
+ + -- cgit v0.9.1