Permalink
Browse files

bug fixes, TColor alpha made function

  • Loading branch information...
1 parent 700f624 commit 3b6863c35eb55ff6587572a620d31e9349905956 @hapticdata hapticdata committed Jun 1, 2011
Showing with 43 additions and 42 deletions.
  1. +5 −5 build/toxi-color.js
  2. +3 −3 build/toxi-core.js
  3. +3 −2 build/toxi-physics2d.js
  4. +11 −10 build/toxiclibs.js
  5. +7 −7 src/color/TColor.js
  6. +13 −15 src/core/geom/Ellipse.js
  7. +1 −0 src/physics/physics2d/physics2d.js
View
@@ -2,9 +2,9 @@
toxi.color=toxi.color===undefined?{}:toxi.color;toxi.color.TColor=function(a){this.rgb=Array(3);this.hsv=Array(3);this.cmyk=Array(4);this._alpha=1;if(a!==undefined){this.cmyk=a.toCMYKAArray().splice(0,4);this.hsv=a.toHSVAArray().splice(0,3);this.rgb=a.toRGBAArray().splice(0,3);this._alpha=a._alpha}};
toxi.color.TColor.prototype={add:function(a){return this.copy().addSelf(a)},addSelf:function(a){this.rgb[0]=toxi.MathUtils.min(this.rgb[0]+a.rgb[0],1);this.rgb[1]=toxi.MathUtils.min(this.rgb[1]+a.rgb[1],1);this.rgb[2]=toxi.MathUtils.min(this.rgb[2]+a.rgb[2],1);return this.setRGB(rgb)},adjustConstrast:function(a){return this.hsv[2]<0.5?this.darken(a):this.lighten(a)},adjustHSV:function(a,b,d){return this.setHSV([this.hsv[0]+a,this.hsv[1]+b,this.hsv[2]+d])},adjustRGB:function(a,b,d){return this.setRGB([this.rgb[0]+
a,this.rgb[1]+b,this.rgb[2]+d])},alpha:function(){return this._alpha},analog:function(a,b){this.rotateRYB(toxi.MathUtils.degrees(a)*toxi.MathUtils.normalizedRandom());this.hsv[1]+=b*toxi.MathUtils.normalizedRandom();this.hsv[2]+=b*toxi.MathUtils.normalizedRandom();return this.setHSV(this.hsv)},black:function(){return this.cmyk[3]},blend:function(a,b){if(b===undefined)b=0.5;var d=a.toRGBAArray();this.rgb[0]+=(d[0]-this.rgb[0])*b;this.rgb[1]+=(d[1]-this.rgb[1])*b;this.rgb[2]+=(d[2]-this.rgb[2])*b;this._alpha+=
-(a.alpha-this._alpha)*b;return this.setRGB(this.rgb)},blue:function(){return this.rgb[2]},brightness:function(){return this.hsv[2]},complement:function(){return this.rotateRYB(180)},copy:function(){return new toxi.color.TColor(this)},cyan:function(){return this.cmyk[0]},darken:function(a){this.hsv[2]=toxi.MathUtils.clip(this.hsv[2]-a,0,1);return this.setHSV(this.hsv)},desaturate:function(a){this.hsv[1]=toxi.MathUtils.clip(this.hsv[1]-a,0,1);return this.setHSV(this.hsv)},differenceTo:function(a){return toxi.color.TColor.newRGB(Math.abs(this.rgb[0]-
+(a.alpha()-this._alpha)*b;return this.setRGB(this.rgb)},blue:function(){return this.rgb[2]},brightness:function(){return this.hsv[2]},complement:function(){return this.rotateRYB(180)},copy:function(){return new toxi.color.TColor(this)},cyan:function(){return this.cmyk[0]},darken:function(a){this.hsv[2]=toxi.MathUtils.clip(this.hsv[2]-a,0,1);return this.setHSV(this.hsv)},desaturate:function(a){this.hsv[1]=toxi.MathUtils.clip(this.hsv[1]-a,0,1);return this.setHSV(this.hsv)},differenceTo:function(a){return toxi.color.TColor.newRGB(Math.abs(this.rgb[0]-
a.rgb[0]),Math.abs(this.rgb[1]-a.rgb[1]),Math.abs(this.rgb[2]-a.rgb[2]))},distanceToCMYK:function(a){var b=a.toCMYKAArray();a=this.cmyk[0]-b[0];var d=this.cmyk[1]-b[1],c=this.cmyk[2]-b[2];b=this.cmyk[3]-b[3];return Math.sqrt(a*a+d*d+c*c+b*b)},distanceToHSV:function(a){var b=this.hsv[0]*toxi.MathUtils.TWO_PI,d=a.hue()*toxi.MathUtils.TWO_PI;b=new toxi.Vec3D(Math.cos(b)*this.hsv[1],Math.sin(b)*this.hsv[1],this.hsv[2]);a=new toxi.Vec3D(Math.cos(d)*a.saturation(),Math.sin(d)*a.saturation(),a.brightness());
-return b.distanceTo(a)},distanceToRGB:function(a){var b=a.toRGBAArray();a=this.rgb[0]-b[0];var d=this.rgb[1]-b[1];b=this.rgb[2]-b[2];return Math.sqrt(a*a+d*d+b*b)},equals:function(a){if(a!==undefined&&a instanceof toxi.color.TColor){var b=a.rgb[0]-rgb[0],d=a.rgb[1]-rgb[1],c=a.rgb[2]-rgb[2];a=a.alpha-alpha;return Math.sqrt(b*b+d*d+c*c+a*a)<toxi.color.TColor.EPS}return false},getAnalog:function(a,b){return(new toxi.color.TColor(this)).analog(a,b)},getBlended:function(a,b){return(new toxi.color.TColor(this)).blend(a,
+return b.distanceTo(a)},distanceToRGB:function(a){var b=a.toRGBAArray();a=this.rgb[0]-b[0];var d=this.rgb[1]-b[1];b=this.rgb[2]-b[2];return Math.sqrt(a*a+d*d+b*b)},equals:function(a){if(a!==undefined&&a instanceof toxi.color.TColor){var b=a.rgb[0]-rgb[0],d=a.rgb[1]-rgb[1],c=a.rgb[2]-rgb[2];a=a.alpha()-this._alpha;return Math.sqrt(b*b+d*d+c*c+a*a)<toxi.color.TColor.EPS}return false},getAnalog:function(a,b){return(new toxi.color.TColor(this)).analog(a,b)},getBlended:function(a,b){return(new toxi.color.TColor(this)).blend(a,
b)},getComplement:function(){return(new toxi.color.TColor(this)).complement()},getComponentValue:function(a){return a.getComponentValueFor(this)},getDarkened:function(a){return(new toxi.color.TColor(this)).darken(a)},getDesaturated:function(a){return(new toxi.color.TColor(this)).desaturate(a)},getDifferenceTo:function(a){return this.copy().differenceTo(a)},getInverted:function(){return(new toxi.color.TColor(this)).invert()},getLightened:function(a){return(new toxi.color.TColor(this)).lighten(a)},
getRotatedRYB:function(a){return(new toxi.color.TColor(this)).rotateRYB(a)},getSaturated:function(a){return(new toxi.color.TColor(this)).saturate(a)},green:function(){return this.rgb[1]},hue:function(){return this.hsv[0]},invert:function(){this.rgb[0]=1-this.rgb[0];this.rgb[1]=1-this.rgb[1];this.rgb[2]=1-this.rgb[2];return this.setRGB(this.rgb)},isBlack:function(){return this.rgb[0]<=toxi.color.TColor.BLACK_POINT&&this.rgb[0]==this.rgb[1]&&this.rgb[0]==this.rgb[2]},isGrey:function(){return this.hsv[1]<
toxi.color.TColor.GREY_THRESHOLD},isWhite:function(){return this.rgb[0]>=toxi.color.TColor.WHITE_POINT&&this.rgb[0]==this.rgb[1]&&this.rgb[0]==this.rgb[2]},lighten:function(a){this.hsv[2]=toxi.MathUtils.clip(this.hsv[2]+a,0,1);return this.setHSV(this.hsv)},luminance:function(){return this.rgb[0]*0.299+this.rgb[1]*0.587+this.rgb[2]*0.114},magenta:function(){return this.cmyk[1]},red:function(){return this.rgb[0]},rotateRYB:function(a){parseInt(toxi.MathUtils.degrees(a));var b=this.hsv[0]*360;a%=360;
@@ -19,9 +19,9 @@ this.rgb[0]+", "+this.rgb[1]+", "+this.rgb[2]+" hsv: "+this.hsv[0]+","+this.hsv[
toxi.color.TColor.cmykToRGB=function(a,b,d,c,e){if(e===undefined)e=[0,0,0];e[0]=1-Math.min(1,a+c);e[1]=1-Math.min(1,b+c);e[2]=1-Math.min(1,d+c);return e};toxi.color.TColor.hexToRGB=function(a,b){if(b===undefined)b=[];a=a.charAt(0)=="#"?a.substring(1,7):a;b[0]=parseInt(a.substring(0,2),16)*toxi.color.TColor.INV8BIT;b[1]=parseInt(a.substring(2,4),16)*toxi.color.TColor.INV8BIT;b[2]=parseInt(a.substring(4,6),16)*toxi.color.TColor.INV8BIT;return b};
toxi.color.TColor.hsvToRGB=function(a,b,d,c){if(c===undefined)c=[];if(b==0)c[0]=c[1]=c[2]=d;else{a/=toxi.color.TColor.INV60DEGREES;var e=parseInt(a),f=a-e;a=d*(1-b);var g=d*(1-b*f);b=d*(1-b*(1-f));if(e==0){c[0]=d;c[1]=b;c[2]=a}else if(e==1){c[0]=g;c[1]=d;c[2]=a}else if(e==2){c[0]=a;c[1]=d;c[2]=b}else if(e==3){c[0]=a;c[1]=g;c[2]=d}else if(e==4){c[0]=b;c[1]=a;c[2]=d}else{c[0]=d;c[1]=a;c[2]=g}}return c};
toxi.color.TColor.labToRGB=function(a,b,d,c){if(c===undefined)c=[];a=(a+16)/116;b=b/500+a;d=a-d/200;c[0]=b;c[1]=a;c[2]=d;for(d=0;d<3;d++){a=Math.pow(c[d],3);c[d]=a>0.008856?a:(c[d]-16/116)/7.787}b=c[0]*0.95047;a=c[1];d=c[2]*1.08883;c[0]=b*3.2406+a*-1.5372+d*-0.4986;c[1]=b*-0.9689+a*1.8758+d*0.0415;c[2]=b*0.0557+a*-0.204+d*1.057;a=1/2.4;for(d=0;d<3;d++)c[d]=c[d]>0.0031308?1.055*Math.pow(c[d],a)-0.055:12.92*c[d];return c};
-toxi.color.TColor.newARGB=function(a){return toxi.color.TColor.newRGBA((a>>16&255)*toxi.color.TColor.INV8BIT,(a>>8&255)*toxi.color.TColor.INV8BIT,(a&255)*toxi.color.TColor.INV8BIT,(a>>>24)*toxi.color.TColor.INV8BIT)};toxi.color.TColor.newCMYK=function(a,b,d,c){return toxi.color.TColor.newCMYKA(a,b,d,c,1)};toxi.color.TColor.newCMYKA=function(a,b,d,c,e){var f=new TColor;f.setCMYK([a,b,d,c]);f.alpha=toxi.MathUtils.clip(e,0,1);return f};
-toxi.color.TColor.newGray=function(a){return toxi.color.TColor.newGrayAlpha(a,1)};toxi.color.TColor.newGrayAlpha=function(a,b){var d=new toxi.color.TColor;d.setRGB([a,a,a]);d.alpha=b;return d};toxi.color.TColor.newHex=function(a){var b=new toxi.color.TColor;b.setRGB(toxi.color.TColor.hexToRGB(a));b.alpha=1;return b};toxi.color.TColor.newHSV=function(a,b,d){return toxi.color.TColor.newHSVA(a,b,d,1)};
-toxi.color.TColor.newHSVA=function(a,b,d,c){var e=new toxi.color.TColor;e.setHSV(a,b,d);e.alpha=toxi.MathUtils.clip(c,0,1);return e};toxi.color.TColor.newRandom=function(){return toxi.color.TColor.newRGBA(Math.random(),Math.random(),Math.random(),1)};toxi.color.TColor.newRGB=function(a,b,d){return toxi.color.TColor.newRGBA(a,b,d,1)};toxi.color.TColor.newRGBA=function(a,b,d,c){var e=new toxi.color.TColor;e.setRGB([a,b,d]);e.alpha=toxi.MathUtils.clip(c,0,1);return e};
+toxi.color.TColor.newARGB=function(a){return toxi.color.TColor.newRGBA((a>>16&255)*toxi.color.TColor.INV8BIT,(a>>8&255)*toxi.color.TColor.INV8BIT,(a&255)*toxi.color.TColor.INV8BIT,(a>>>24)*toxi.color.TColor.INV8BIT)};toxi.color.TColor.newCMYK=function(a,b,d,c){return toxi.color.TColor.newCMYKA(a,b,d,c,1)};toxi.color.TColor.newCMYKA=function(a,b,d,c,e){var f=new TColor;f.setCMYK([a,b,d,c]);f.setAlpha(toxi.MathUtils.clip(e,0,1));return f};
+toxi.color.TColor.newGray=function(a){return toxi.color.TColor.newGrayAlpha(a,1)};toxi.color.TColor.newGrayAlpha=function(a,b){var d=new toxi.color.TColor;d.setRGB([a,a,a]);d.setAlpha(b);return d};toxi.color.TColor.newHex=function(a){var b=new toxi.color.TColor;b.setRGB(toxi.color.TColor.hexToRGB(a));b.setAlpha(1);return b};toxi.color.TColor.newHSV=function(a,b,d){return toxi.color.TColor.newHSVA(a,b,d,1)};
+toxi.color.TColor.newHSVA=function(a,b,d,c){var e=new toxi.color.TColor;e.setHSV(a,b,d);e.setAlpha(toxi.MathUtils.clip(c,0,1));return e};toxi.color.TColor.newRandom=function(){return toxi.color.TColor.newRGBA(Math.random(),Math.random(),Math.random(),1)};toxi.color.TColor.newRGB=function(a,b,d){return toxi.color.TColor.newRGBA(a,b,d,1)};toxi.color.TColor.newRGBA=function(a,b,d,c){var e=new toxi.color.TColor;e.setRGB([a,b,d]);e.setAlpha(toxi.MathUtils.clip(c,0,1));return e};
toxi.color.TColor.rgbToCMYK=function(a,b,d,c){if(c===undefined)c=[];c[0]=1-a;c[1]=1-b;c[2]=1-d;c[3]=toxi.MathUtils.min(c[0],c[1],c[2]);c[0]=toxi.MathUtils.clip(c[0]-c[3],0,1);c[1]=toxi.MathUtils.clip(c[1]-c[3],0,1);c[2]=toxi.MathUtils.clip(c[2]-c[3],0,1);c[3]=toxi.MathUtils.clip(c[3],0,1);return c};toxi.color.TColor.rgbToHex=function(a,b,d){return(toxi.MathUtils.clip(a,0,1)*255).toString(16)+(toxi.MathUtils.clip(b,0,1)*255).toString(16)+(toxi.MathUtils.clip(d,0,1)*255).toString(16)};
toxi.color.TColor.rgbToHSV=function(a,b,d,c){if(c===undefined)c=[];var e=0,f=0,g=toxi.MathUtils.max(a,b,d),h=g-toxi.MathUtils.min(a,b,d);if(g!=0)f=h/g;if(f!=0)e=a==g?(b-d)/h:b==g?2+(d-a)/h:4+(a-b)/h;e*=toxi.color.TColor.INV60DEGREES;if(e<0)e+=1;c[0]=e;c[1]=f;c[2]=g;return c};toxi.color.TColor.RED=toxi.color.TColor.newRGB(1,0,0);
toxi.color.TColor.RYB_WHEEL=[new toxi.Vec2D(0,0),new toxi.Vec2D(15,8),new toxi.Vec2D(30,17),new toxi.Vec2D(45,26),new toxi.Vec2D(60,34),new toxi.Vec2D(75,41),new toxi.Vec2D(90,48),new toxi.Vec2D(105,54),new toxi.Vec2D(120,60),new toxi.Vec2D(135,81),new toxi.Vec2D(150,103),new toxi.Vec2D(165,123),new toxi.Vec2D(180,138),new toxi.Vec2D(195,155),new toxi.Vec2D(210,171),new toxi.Vec2D(225,187),new toxi.Vec2D(240,204),new toxi.Vec2D(255,219),new toxi.Vec2D(270,234),new toxi.Vec2D(285,251),new toxi.Vec2D(300,
View
@@ -81,10 +81,10 @@ e.b0[n]+g.x*e.b1[n]+h.x*e.b2[n]+k.x*e.b3[n],j.y*e.b0[n]+g.y*e.b1[n]+h.y*e.b2[n]+
(m-this.arcLenIndex[k-1])/(this.arcLenIndex[k]-this.arcLenIndex[k-1])))}g&&i.push(this.vertices[this.vertices.length-1]);return i},getEstimatedArcLength:function(){if(this.arcLenIndex===undefined||this.arcLenIndex!==undefined&&this.arcLenIndex.length!=this.vertices.length)this.arcLenIndex=[];for(var e=0,g=1;g<this.arcLenIndex.length;g++){e+=this.vertices[g-1].distanceTo(this.vertices[g]);this.arcLenIndex[g]=e}return e},getNumPoints:function(){return this.numP},getPointList:function(){return this.pointList},
getTightness:function(){return this.tightness},setPointList:function(e){this.pointList=e.slice(0);return this},setTightness:function(e){this.tightness=e;this.invTightness=1/this.tightness;return this},updateCoefficients:function(){this.numP=this.pointList.length;if(this.points===undefined||this.points!=undefined&&this.points.length!=this.numP){this.coeffA=[];this.delta=[];this.bi=[];for(var e=0;e<this.numP;e++){this.coeffA[e]=new toxi.Vec2D;this.delta[e]=new toxi.Vec2D}this.setTightness(this.tightness)}this.points=
this.pointList.slice(0)}};toxi.Spline2D.DEFAULT_TIGHTNESS=0.25;toxi.Spline2D.DEFAULT_RES=16;
-toxi.Ellipse=function(e,g,h,i){this.radius=new toxi.Vec2D;if(arguments.length==0){this.parent.init.call(this,0,0);this.setRadii(1,1)}else if(e instanceof toxi.Vec2D){this.parent.init.call(this,e.x,e.y);g instanceof toxi.Vec2D?this.setRadii(g.x,g.y):this.setRadii(g,g)}else if(i===undefined)if(h===undefined){this.parent.init.call(this,0,0);this.setRadii(e,g)}else{this.parent.init.call(this,e,g);this.setRadii(h,h)}else{this.parent.init.call(this,e,g);this.setRadii(h,i)}};toxi.Ellipse.prototype=new toxi.Vec2D;
-toxi.Ellipse.prototype.constructor=toxi.Ellipse;toxi.Ellipse.prototype.parent=toxi.Vec2D.prototype;toxi.Ellipse.prototype.containsPoint=function(e){var g=this.getFoci();return e.distanceTo(g[0])+e.distanceTo(g[1])<2*MathUtils.max(this.radius.x,this.radius.y)};toxi.Ellipse.prototype.getArea=function(){return MathUtils.PI*radius.x*radius.y};toxi.Ellipse.prototype.getCircumference=function(){return Math.sqrt(0.5*this.radius.magSquared())*MathUtils.TWO_PI};
+toxi.Ellipse=function(e,g,h,i){this.radius=new toxi.Vec2D;if(arguments.length==0){toxi.Vec2D.apply(this,[0,0]);this.setRadii(1,1)}else if(e instanceof toxi.Vec2D){toxi.Vec2D.apply(this,[e.x,e.y]);g instanceof toxi.Vec2D?this.setRadii(g.x,g.y):this.setRadii(g,g)}else if(i===undefined)if(h===undefined){toxi.Vec2D.apply(this,[0,0]);this.setRadii(e,g)}else{toxi.Vec2D.apply(this,[e,g]);this.setRadii(h,h)}else{toxi.Vec2D.apply(this,[e,g]);this.setRadii(h,i)}};toxi.extend(toxi.Ellipse,toxi.Vec2D);
+toxi.Ellipse.prototype.containsPoint=function(e){var g=this.getFoci();return e.distanceTo(g[0])+e.distanceTo(g[1])<2*toxi.MathUtils.max(this.radius.x,this.radius.y)};toxi.Ellipse.prototype.getArea=function(){return toxi.MathUtils.PI*radius.x*radius.y};toxi.Ellipse.prototype.getCircumference=function(){return Math.sqrt(0.5*this.radius.magSquared())*toxi.MathUtils.TWO_PI};
toxi.Ellipse.prototype.getFoci=function(){var e=[];if(this.radius.x>this.radius.y){e[0]=this.sub(this.focus,0);e[1]=this.add(this.focus,0)}else{e[0]=this.sub(0,this.focus);e[1]=this.add(0,this.focus)}return e};toxi.Ellipse.prototype.getRadii=function(){return this.radius.copy()};toxi.Ellipse.prototype.setRadii=function(e,g){if(e instanceof toxi.Vec2D){g=e.y;e=e.x}this.radius.set(e,g);this.focus=this.radius.magnitude();return this};
-toxi.Ellipse.prototype.toPolygon2D=function(e){for(var g=new toxi.Polygon2D,h=MathUtils.TWO_PI/e,i=0;i<e;i++)g.add(toxi.Vec2D.fromTheta(i*h).scaleSelf(this.radius).addSelf(this));return g};
+toxi.Ellipse.prototype.toPolygon2D=function(e){for(var g=new toxi.Polygon2D,h=toxi.MathUtils.TWO_PI/e,i=0;i<e;i++){var j=toxi.Vec2D.fromTheta(i*h).scaleSelf(this.radius).addSelf(this);g.add(j)}return g};
toxi.Rect=function(e,g,h,i){if(arguments.length===2)if(e instanceof toxi.Vec2D){this.x=e.x;this.y=e.y;this.width=g.x-this.x;this.height=g.y-this.y}else throw Error("toxi.Rect received incorrect parameters");else if(arguments.length===4){this.x=e;this.y=g;this.width=h;this.height=i}else if(arguments.length>0)throw Error("toxi.Rect received incorrect parameters");};toxi.Rect.fromCenterExtent=function(e,g){return new toxi.Rect(e.sub(g),e.add(g))};
toxi.Rect.prototype={containsPoint:function(e){var g=e.x;e=e.y;if(g<this.x||g>=this.x+this.width)return false;if(e<this.y||e>=this.y+this.height)return false;return true},copy:function(){return new toxi.Rect(this.x,this.y,this.width,this.height)},getArea:function(){return this.width*this.height},getAspect:function(){return this.width/this.height},getBottom:function(){return this.y+this.height},getBottomRight:function(){return new toxi.Vec2D(this.x+this.width,this.y+this.height)},getCentroid:function(){return new toxi.Vec2D(this.x+
this.width*0.5,this.y+this.height*0.5)},getDimensions:function(){return new toxi.Vec2D(this.width,this.height)},getEdge:function(e){var g=undefined;switch(e){case 0:g=new toxi.Line2D(new toxi.Vec2D(this.x,this.y),new toxi.Vec2D(this.x+this.width,this.y));break;case 1:g=new toxi.Line2D(new toxi.Vec2D(this.x+this.width,this.y),new toxi.Vec2D(this.x+this.width,this.y+this.height));break;case 2:g=new toxi.Line2D(new toxi.Vec2D(this.x,this.y+this.height),new toxi.Vec2D(this.x+this.width,this.y+this.height));
@@ -1,6 +1,7 @@
// toxi-physics2d.js r34 - http://github.com/hapticdata/toxiclibsjs
-toxi.physics2d=toxi.physics2d||{};toxi.physics2d.removeItemFrom=function(a,b){var c=b.indexOf(a);if(c>-1)return b.splice(c,1)};toxi.physics2d.VerletParticle2D=function(a,b,c){this.force=new toxi.Vec2D;if(a instanceof toxi.Vec2D)if(a instanceof toxi.physics2d.VerletParticle2D){b=a.y;c=a.weight;a=a.x;this.isLocked=a.isLocked}else{if(b===undefined){b=a.y;c=1}else{c=b;b=a.y}a=a.x}this.isLocked=false;this.init(a,b);this.prev=new toxi.Vec2D(this);this.temp=new toxi.Vec2D;c=c===undefined?1:c;this.setWeight(c)};
-toxi.extend(toxi.physics2d.VerletParticle2D,toxi.Vec2D);toxi.physics2d.VerletParticle2D.prototype.addBehavior=function(a,b){if(this.behaviors===undefined)this.behaviors=[];if(a===undefined)throw{name:"TypeError",message:"behavior was undefined"};b=b===undefined?1:b;a.configure(b);this.behaviors.push(a);return this};toxi.physics2d.VerletParticle2D.prototype.addConstraint=function(a){if(this.constraints===undefined)this.constraints=[];this.constraints.push(a);return this};
+toxi.physics2d=toxi.physics2d||{};toxi.physics2d.removeItemFrom=function(a,b){var c=b.indexOf(a);if(c>-1)return b.splice(c,1);console.log("undefined")};
+toxi.physics2d.VerletParticle2D=function(a,b,c){this.force=new toxi.Vec2D;if(a instanceof toxi.Vec2D)if(a instanceof toxi.physics2d.VerletParticle2D){b=a.y;c=a.weight;a=a.x;this.isLocked=a.isLocked}else{if(b===undefined){b=a.y;c=1}else{c=b;b=a.y}a=a.x}this.isLocked=false;this.init(a,b);this.prev=new toxi.Vec2D(this);this.temp=new toxi.Vec2D;c=c===undefined?1:c;this.setWeight(c)};toxi.extend(toxi.physics2d.VerletParticle2D,toxi.Vec2D);
+toxi.physics2d.VerletParticle2D.prototype.addBehavior=function(a,b){if(this.behaviors===undefined)this.behaviors=[];if(a===undefined)throw{name:"TypeError",message:"behavior was undefined"};b=b===undefined?1:b;a.configure(b);this.behaviors.push(a);return this};toxi.physics2d.VerletParticle2D.prototype.addConstraint=function(a){if(this.constraints===undefined)this.constraints=[];this.constraints.push(a);return this};
toxi.physics2d.VerletParticle2D.prototype.addForce=function(a){this.force.addSelf(a);return this};toxi.physics2d.VerletParticle2D.prototype.addVelocity=function(a){this.prev.subSelf(a);return this};toxi.physics2d.VerletParticle2D.prototype.applyBehaviors=function(){if(this.behaviors!==undefined){var a=0;for(a=0;a<this.behaviors.length;a++)this.behaviors[a].applyBehavior(this)}};
toxi.physics2d.VerletParticle2D.prototype.applyConstraints=function(){if(this.constraints!==undefined){var a=0;for(a=0;a<this.constraints.length;a++)this.constraints[a].applyConstraint(this)}};toxi.physics2d.VerletParticle2D.prototype.clearForce=function(){this.force.clear();return this};toxi.physics2d.VerletParticle2D.prototype.clearVelocity=function(){this.prev.set(this);return this};toxi.physics2d.VerletParticle2D.prototype.getInvWeight=function(){return this.invWeight};
toxi.physics2d.VerletParticle2D.prototype.getPreviousPosition=function(){return this.prev};toxi.physics2d.VerletParticle2D.prototype.getVelocity=function(){return this.sub(this.prev)};toxi.physics2d.VerletParticle2D.prototype.getWeight=function(){return this.weight};toxi.physics2d.VerletParticle2D.prototype.lock=function(){this.isLocked=true;return this};toxi.physics2d.VerletParticle2D.prototype.removeAllBehaviors=function(){this.behaviors=[];return this};
Oops, something went wrong. Retry.

0 comments on commit 3b6863c

Please sign in to comment.