This file contains hidden or 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
var rect = Rectangle(2,3); |
This file contains hidden or 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
function stringy(a) { | |
this.init(a) | |
} | |
stringy.prototype = { | |
context: null, | |
prevMouseX: null, | |
prevMouseY: null, | |
points: null, | |
count: null, | |
init: function (a) { |
This file contains hidden or 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
function curvy(a) { | |
this.init(a) | |
} | |
curvy.prototype = { | |
context: null, | |
prevMouseX: null, | |
prevMouseY: null, | |
points: null, | |
count: null, | |
init: function (a) { |
This file contains hidden or 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
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) { |
This file contains hidden or 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
function mixin(from, to) { | |
var property; | |
for (property in from) { | |
if (!to.hasOwnProperty(property)) { | |
to[property] = from[property]; | |
} | |
} | |
return to; | |
} |
This file contains hidden or 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
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) { |
This file contains hidden or 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
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))); |
This file contains hidden or 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
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); |
This file contains hidden or 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
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() + ')' |
This file contains hidden or 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
var pix = document.getPixel(100,100); | |
if (pix.getHexColor() === '0000FF') { | |
console.log('pixel at 100x100 is red'); | |
} |