2012-09-04 16:10:16 +04:00
|
|
|
(function () {
|
2012-09-05 00:40:54 +04:00
|
|
|
var ns = $.namespace("pskl.controller");
|
2012-09-04 16:10:16 +04:00
|
|
|
ns.DrawingController = function (frame, container, dpi) {
|
|
|
|
this.dpi = dpi;
|
|
|
|
|
2012-09-08 17:34:13 +04:00
|
|
|
var renderingOptions = {
|
|
|
|
"dpi": dpi,
|
|
|
|
"displayGrid": true // Retrieve from localsotrage config
|
|
|
|
}
|
|
|
|
|
2012-09-04 16:10:16 +04:00
|
|
|
// Public
|
|
|
|
this.frame = frame;
|
2012-09-08 17:08:00 +04:00
|
|
|
this.overlayFrame = pskl.model.Frame.createEmptyFromFrame(frame); // Type is frame
|
2012-09-04 16:10:16 +04:00
|
|
|
|
|
|
|
// Private
|
|
|
|
this.container = container;
|
2012-09-08 17:34:13 +04:00
|
|
|
this.renderer = new pskl.rendering.FrameRenderer(this.container, renderingOptions, "drawing-canvas");
|
|
|
|
this.overlayRenderer = new pskl.rendering.FrameRenderer(this.container, renderingOptions, "canvas-overlay");
|
2012-09-08 18:32:28 +04:00
|
|
|
|
2012-09-08 17:08:00 +04:00
|
|
|
this.renderer.init(this.frame);
|
|
|
|
this.overlayRenderer.init(this.frame);
|
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.updateDPI = function (newDPI) {
|
2012-09-08 18:32:28 +04:00
|
|
|
this.renderer.updateDPI(newDPI);
|
|
|
|
this.overlayRenderer.updateDPI(newDPI);
|
|
|
|
|
|
|
|
this.renderer.render(this.frame);
|
2012-09-08 19:57:21 +04:00
|
|
|
this.overlayRenderer.render(this.overlayFrame);
|
2012-09-04 16:10:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.renderFrame = function () {
|
2012-09-08 17:08:00 +04:00
|
|
|
this.renderer.render(this.frame);
|
2012-09-04 16:10:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.renderFramePixel = function (col, row) {
|
2012-09-08 17:08:00 +04:00
|
|
|
this.renderer.drawPixel(col, row, this.frame);
|
2012-09-04 16:10:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.renderOverlay = function () {
|
2012-09-08 17:08:00 +04:00
|
|
|
this.overlayRenderer.render(this.overlayFrame);
|
2012-09-04 16:10:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.clearOverlay = function () {
|
2012-09-08 17:08:00 +04:00
|
|
|
this.overlayFrame = pskl.model.Frame.createEmptyFromFrame(this.frame);
|
|
|
|
this.overlayRenderer.clear();
|
2012-09-04 16:10:16 +04:00
|
|
|
};
|
|
|
|
})();
|