Skip to content

Instantly share code, notes, and snippets.

@sebmarkbage
Created January 21, 2011 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebmarkbage/790455 to your computer and use it in GitHub Desktop.
Save sebmarkbage/790455 to your computer and use it in GitHub Desktop.
// 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()
}
})
@steida
Copy link

steida commented Jan 25, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment