Skip to content

Instantly share code, notes, and snippets.

@vstarck
Created May 28, 2012 20:39
Show Gist options
  • Save vstarck/2821116 to your computer and use it in GitHub Desktop.
Save vstarck/2821116 to your computer and use it in GitHub Desktop.
hug.color.js
var Color = hug()
Color('#set')('init', function($self, r, g, b) {
$self
('#set')('r', r)
('#set')('g', g)
('#set')('b', b)
})
Color('#set')('+', function($self, another) {
return Color('#new')(
$self('r') + another('r'),
$self('g') + another('g'),
$self('b') + another('b')
)
})
var red = Color('#new')(255, 0, 0)
var blue = Color('#new')(0, 0, 255)
var violet = red('+', blue)
violet('r') // 255
violet('g') // 0
violet('b') // 255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment