Created
January 21, 2011 21:25
-
-
Save sebmarkbage/790455 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Util | |
function placeholder(){} | |
function derive(Child, Parent){ | |
placeholder.prototype = Parent.prototype | |
var proto = new placeholder() | |
for (var i = 2, l = arguments.length; i < l; i++){ | |
var mixin = arguments[i] | |
for (var key in mixin) proto[key] = mixin[key] | |
} | |
return Child.prototype = proto | |
} | |
// Element | |
function Element(){ | |
} | |
Element.prototype = { | |
render: function(){ | |
} | |
} | |
// Transform | |
function Transform(){ | |
} | |
Transform.prototype = { | |
rotate: function(){ | |
} | |
} | |
// Shape | |
function Shape(){ | |
this._() | |
} | |
Shape.prototype = derive(Element, Transform, { | |
_: Element, | |
_render: Element.prototype.render, | |
render: function(){ | |
this._render() | |
}, | |
draw: function(){ | |
} | |
}) | |
// Triangle | |
function Triangle(){ | |
this.__() | |
} | |
Triangle.prototype = derive(Shape, { | |
__: Shape, | |
__draw: Shape.prototype.draw, | |
__render: Shape.prototype.render, | |
draw: function(){ | |
this.__draw() | |
}, | |
render: function(){ | |
this.__render() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet should be illuminated with this link http://blog.calyptus.eu/seb/2011/01/javascript-call-performance-just-inline-it/