UNPKG

obelisk.js-browserify-test

Version:

JavaScript Engine for Building Pixel Isometric Element with HTML5 Canvas

57 lines (44 loc) 1.26 kB
/*global obelisk:true, jQuery:true*/ /* * PixelView */ (function (obelisk) { "use strict"; var PixelView, p; PixelView = function (canvas, point) { this.initialize(canvas, point); }; p = PixelView.prototype; // public properties p.canvas = null; p.context = null; p.point = null; // constructor p.initialize = function (canvas, point) { if (!canvas) { throw new Error("Canvas is not defined"); } try { if (canvas instanceof jQuery) { canvas = canvas.get(0); } } catch (e) { } this.canvas = canvas; this.context = this.canvas.getContext('2d'); this.point = point || new obelisk.Point(0, 0); return this; }; // public methods p.renderObject = function (primitive, point3D) { var po = new obelisk.PixelObject(primitive, point3D); this.context.drawImage(po.canvas, this.point.x + po.x, this.point.y + po.y); }; p.clear = function () { this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); }; p.toString = function () { return "[PixelView]"; }; obelisk.PixelView = PixelView; }(obelisk));