Skip to content

Instantly share code, notes, and snippets.

@koozdra
Created October 20, 2015 04:24
Show Gist options
  • Save koozdra/c8b4e8b3bb333e4206f5 to your computer and use it in GitHub Desktop.
Save koozdra/c8b4e8b3bb333e4206f5 to your computer and use it in GitHub Desktop.
Object design
function point(x, y) {
return {
x: x, y: y,
shift: function(x, y) {
return _.extend({}, this, {
x: this.x + x,
y: this.y + y
})
}
}
}
var a = point(10, 10);
var b = a.shift(1,1);
console.log(a,b);
function color(r, g, b) {
return {
r: r, g: g, b: b,
toArray: function() {
return [r, g, b, 255];
}
}
}
function pixel(point, color) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment