Skip to content

Instantly share code, notes, and snippets.

View rhyolight's full-sized avatar

Matthew Taylor rhyolight

View GitHub Profile
var rect = Rectangle(2,3);
function stringy(a) {
this.init(a)
}
stringy.prototype = {
context: null,
prevMouseX: null,
prevMouseY: null,
points: null,
count: null,
init: function (a) {
function curvy(a) {
this.init(a)
}
curvy.prototype = {
context: null,
prevMouseX: null,
prevMouseY: null,
points: null,
count: null,
init: function (a) {
PositionedRectangle = function(w,h,xIn,yIn) {
var x = xIn,
y = yIn,
rect = new ORectangle(w,h),
me = {
getX: function() { return x; },
setX: function(xIn) { this.x = xIn; },
getY: function() { return y; },
setY: function(yIn) { this.y = yIn; },
distanceFrom: function(otherRect) {
function mixin(from, to) {
var property;
for (property in from) {
if (!to.hasOwnProperty(property)) {
to[property] = from[property];
}
}
return to;
}
PositionedRectangle = function(w,h,xIn,yIn) {
var x = xIn,
y = yIn,
rect = new ORectangle(w,h),
me = {
getX: function() { return x; },
setX: function(xIn) { this.x = xIn; },
getY: function() { return y; },
setY: function(yIn) { this.y = yIn; },
distanceFrom: function(otherRect) {
function println(s) {
document.write(s + '<br/>');
}
var rect = new Rectangle(2,3);
println(rect);
println(rect.area());
var posRect = new PositionedRectangle(6,3,0,0);
println(posRect);
println(posRect.area());
println(posRect.distanceFrom(new PositionedRectangle(4,4,100,100)));
function Rectangle(w,h) {
this.width = w;
this.height = h;
}
Rectangle.prototype.area = function() {
return this.width * this.height;
};
PositionedRectangle = function(w,h,x,y) {
Rectangle.call(this, w, h);
ORectangle = function(w,h) {
var width = w, height = h;
return {
getWidth: function() { return width; },
getHeight: function() { return height; },
setWidth: function(w) { width = w; },
setHeight: function(h) { height = h; },
area: function() { return width * height },
toString: function() {
return '(' + this.getWidth() + 'X' + this.getHeight() + ')'
var pix = document.getPixel(100,100);
if (pix.getHexColor() === '0000FF') {
console.log('pixel at 100x100 is red');
}