obelisk.js
Version:
JavaScript Library for Building Pixel Isometric Element with HTML5 Canvas
35 lines (25 loc) • 769 B
JavaScript
/*jslint node: true*/
;
var AbstractDimension = require('./AbstractDimension');
var BrickDimension, p;
BrickDimension = function (xAxis, yAxis) {
this.initialize(xAxis, yAxis);
};
p = BrickDimension.prototype = new AbstractDimension();
// constructor
p.initialize = function (xAxis, yAxis) {
this.xAxis = xAxis || 30;
this.yAxis = yAxis || 30;
if (this.xAxis % 2 === 1 || this.yAxis % 2 === 1) {
throw new Error('x,yAxis must be even number');
}
// xAxis || yAxis = 4 floodFill could not be applied
if (this.xAxis <= 4 || this.yAxis <= 4) {
throw new Error('dimension is too small');
}
return this;
};
p.toString = function () {
return '[BrickDimension]';
};
module.exports = BrickDimension;