diff --git a/lib/arbor.js b/lib/arbor.js index 87ad4d0..cc632d9 100644 --- a/lib/arbor.js +++ b/lib/arbor.js @@ -4,7 +4,7 @@ // // Copyright (c) 2012 Samizdat Drafting Co. // Physics code derived from springy.js, copyright (c) 2010 Dennis Hotson -// +// // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without @@ -13,10 +13,10 @@ // copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following // conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -43,25 +43,20 @@ })() - arbor = (typeof(arbor)!=='undefined') ? arbor : {} - $.extend(arbor, { - // object constructors (don't use ‘new’, just call them) - ParticleSystem:ParticleSystem, - Point:function(x, y){ return new Point(x, y) }, + if (typeof(arbor)!=='undefined') { + $.extend(arbor, { + // object constructor (don't use ‘new’, just call it) + Graphics:function(ctx){ return Graphics(ctx) }, + + // useful methods for dealing with the r/g/b + colors:{ + CSS:Colors.CSS, // dict:{colorname:"#fef2e2", ...} + validate:Colors.validate, // ƒ(str) -> t/f + decode:Colors.decode, // ƒ(hexString_or_cssColor) -> {r,g,b,a} + encode:Colors.encode, // ƒ({r,g,b,a}) -> hexOrRgbaString + blend:Colors.blend // ƒ(color, opacity) -> rgbaString + } + }) + } - // immutable object with useful methods - etc:{ - trace:trace, // ƒ(msg) -> safe console logging - dirname:dirname, // ƒ(path) -> leading part of path - basename:basename, // ƒ(path) -> trailing part of path - ordinalize:ordinalize, // ƒ(num) -> abbrev integers (and add commas) - objcopy:objcopy, // ƒ(old) -> clone an object - objcmp:objcmp, // ƒ(a, b, strict_ordering) -> t/f comparison - objkeys:objkeys, // ƒ(obj) -> array of all keys in obj - objmerge:objmerge, // ƒ(dst, src) -> like $.extend but non-destructive - uniq:uniq, // ƒ(arr) -> array of unique items in arr - arbor_path:arbor_path, // ƒ() -> guess the directory of the lib code - } - }) - -})(this.jQuery) \ No newline at end of file +})(this.jQuery)