2012-09-04 12:10:16 +00:00
|
|
|
(function () {
|
2012-09-04 20:40:54 +00:00
|
|
|
var ns = $.namespace("pskl.controller");
|
2012-09-04 12:10:16 +00:00
|
|
|
ns.DrawingController = function (frame, container, dpi) {
|
|
|
|
this.dpi = dpi;
|
|
|
|
|
2012-09-08 13:34:13 +00:00
|
|
|
var renderingOptions = {
|
|
|
|
"dpi": dpi,
|
|
|
|
"displayGrid": true // Retrieve from localsotrage config
|
|
|
|
}
|
|
|
|
|
2012-09-04 12:10:16 +00:00
|
|
|
// Public
|
|
|
|
this.frame = frame;
|
2012-09-08 13:08:00 +00:00
|
|
|
this.overlayFrame = pskl.model.Frame.createEmptyFromFrame(frame); // Type is frame
|
2012-09-04 12:10:16 +00:00
|
|
|
|
|
|
|
// Private
|
|
|
|
this.container = container;
|
2012-09-08 13:34:13 +00: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 14:32:28 +00:00
|
|
|
|
2012-09-08 13:08:00 +00:00
|
|
|
this.renderer.init(this.frame);
|
|
|
|
this.overlayRenderer.init(this.frame);
|
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.updateDPI = function (newDPI) {
|
2012-09-08 14:32:28 +00:00
|
|
|
this.renderer.updateDPI(newDPI);
|
|
|
|
this.overlayRenderer.updateDPI(newDPI);
|
|
|
|
|
|
|
|
this.renderer.render(this.frame);
|
|
|
|
this.overlayRenderer.render(this.frame);
|
2012-09-04 12:10:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.renderFrame = function () {
|
2012-09-08 13:08:00 +00:00
|
|
|
this.renderer.render(this.frame);
|
2012-09-04 12:10:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.renderFramePixel = function (col, row) {
|
2012-09-08 13:08:00 +00:00
|
|
|
this.renderer.drawPixel(col, row, this.frame);
|
2012-09-04 12:10:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.renderOverlay = function () {
|
2012-09-08 13:08:00 +00:00
|
|
|
this.overlayRenderer.render(this.overlayFrame);
|
2012-09-04 12:10:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.DrawingController.prototype.clearOverlay = function () {
|
2012-09-08 13:08:00 +00:00
|
|
|
this.overlayFrame = pskl.model.Frame.createEmptyFromFrame(this.frame);
|
|
|
|
this.overlayRenderer.clear();
|
2012-09-04 12:10:16 +00:00
|
|
|
};
|
|
|
|
})();
|