Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Rectangle(x, y, width, height) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- this.boxColor = "red";
- }
- Rectangle.prototype.middle = function() { return { x: this.x + this.width * 0.5, y: this.y + this.height * 0.5 }; }
- Rectangle.prototype.contains = function(point) {
- if (point.x > this.x && point.x < this.x + this.width &&
- point.y > this.y && point.y < this.y + this.height) {
- return true;
- }
- return false;
- }
- Rectangle.prototype.draw = function() {
- context.fillStyle = this.boxColor;
- context.fillRect(this.x,this.y,this.width,this.height);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement