Laura: extend Canvas-Framwork-prototype mit CRC2D-props/meths

Beitrag lesen

Nachtrag:

Du suchst hier

Canvas.prototype[m] = function () {

this.ctx[m].[link:https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply@title=apply](this, [link:https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments@title=arguments]);
};

  
Folgender Code (außerhalb des Konstruktors) funktioniert.  
Wenn ich aber statt this.ctx[m](a,b,c,d,...) this.ctx[m].apply(this,arguments)  
schreibe, bekomme ich oben genannte Fehlermeldung in der firebug-Konsole:  
Illegal operation on WrappedNative prototype object  
~~~javascript
  
for ( var m in CanvasRenderingContext2D.prototype ) {  
  (function( m ) {	  
	Canvas.prototype[m] = function ( a,b,c,d,e,f,g,h,i,j ) {  
		if ( typeof ctx[m] === 'function' ) {  
			this.ctx[m]( a,b,c,d,e,f,g,h,i,j );  
		} else {  
			this.ctx[m] = a;  
		}  
	};  
  })( m );  
}  

Hab das mal nachgegooglet, scheint eine neuere Restriktion durch den Browser zu sein(?), hmm..