From 55670a4a146346c488c1c31d50ad316e67411343 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 9 Jan 2019 15:09:20 +1200 Subject: [PATCH] Renderer is now the manager --- desktop/sources/scripts/dotgrid.js | 21 ++++++++++--------- desktop/sources/scripts/guide.js | 5 ++--- .../scripts/{renderer.js => manager.js} | 4 +++- index.html | 3 ++- 4 files changed, 18 insertions(+), 15 deletions(-) rename desktop/sources/scripts/{renderer.js => manager.js} (97%) diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js index 23bf31d..3a296d3 100644 --- a/desktop/sources/scripts/dotgrid.js +++ b/desktop/sources/scripts/dotgrid.js @@ -16,15 +16,16 @@ function Dotgrid (width, height, grid_x, grid_y, block_x, block_y) { // ISU this.install = function (host) { + this.manager = new Manager(this) this.guide = new this.Guide() this.tool = new this.Tool() this.interface = new this.Interface() - this.renderer = new this.Renderer() + this.picker = new this.Picker() this.cursor = new this.Cursor() host.appendChild(this.guide.el) - this.renderer.install() + this.manager.install() this.interface.install(host) this.theme.install(host, this.update) } @@ -51,7 +52,7 @@ function Dotgrid (width, height, grid_x, grid_y, block_x, block_y) { this.update = function () { DOTGRID.resize() - DOTGRID.renderer.update() + DOTGRID.manager.update() DOTGRID.interface.update() DOTGRID.guide.update() } @@ -89,20 +90,20 @@ function Dotgrid (width, height, grid_x, grid_y, block_x, block_y) { this.save = function () { if (DOTGRID.tool.length() < 1) { console.warn('Nothing to save'); return } - this.renderer.toGRID(grab) + this.manager.toGRID(grab) } this.export = function () { if (DOTGRID.tool.length() < 1) { console.warn('Nothing to export'); return } - this.renderer.toSVG(grab) + this.manager.toSVG(grab) } this.render = function () { if (DOTGRID.tool.length() < 1) { console.warn('Nothing to render'); return } const size = { width: DOTGRID.tool.settings.size.width * 2, height: DOTGRID.tool.settings.size.height * 2 } - this.renderer.toPNG(size, grab) + this.manager.toPNG(size, grab) } // Basics @@ -206,8 +207,8 @@ function Dotgrid (width, height, grid_x, grid_y, block_x, block_y) { if (e.target !== this.picker.input) { e.clipboardData.setData('text/source', DOTGRID.tool.export(DOTGRID.tool.layer())) e.clipboardData.setData('text/plain', DOTGRID.tool.path()) - e.clipboardData.setData('text/html', DOTGRID.renderer.svg_el.outerHTML) - e.clipboardData.setData('text/svg+xml', DOTGRID.renderer.svg_el.outerHTML) + e.clipboardData.setData('text/html', DOTGRID.manager.svg_el.outerHTML) + e.clipboardData.setData('text/svg+xml', DOTGRID.manager.svg_el.outerHTML) e.preventDefault() } @@ -220,8 +221,8 @@ function Dotgrid (width, height, grid_x, grid_y, block_x, block_y) { if (e.target !== this.picker.input) { e.clipboardData.setData('text/source', DOTGRID.tool.export(DOTGRID.tool.layer())) e.clipboardData.setData('text/plain', DOTGRID.tool.export(DOTGRID.tool.layer())) - e.clipboardData.setData('text/html', DOTGRID.renderer.svg_el.outerHTML) - e.clipboardData.setData('text/svg+xml', DOTGRID.renderer.svg_el.outerHTML) + e.clipboardData.setData('text/html', DOTGRID.manager.svg_el.outerHTML) + e.clipboardData.setData('text/svg+xml', DOTGRID.manager.svg_el.outerHTML) DOTGRID.tool.layers[DOTGRID.tool.index] = [] e.preventDefault() } diff --git a/desktop/sources/scripts/guide.js b/desktop/sources/scripts/guide.js index 2e60710..8106492 100644 --- a/desktop/sources/scripts/guide.js +++ b/desktop/sources/scripts/guide.js @@ -18,9 +18,8 @@ DOTGRID.Guide = function () { } this.update = function (force = false) { + DOTGRID.manager.update() - DOTGRID.renderer.update() - this.clear() this.context.restore() @@ -274,7 +273,7 @@ DOTGRID.Guide = function () { this.drawRender = function(ctx = this.context){ let img = new Image() - img.src = DOTGRID.renderer.svg64() + img.src = DOTGRID.manager.svg64() this.context.drawImage(img, 0, 0, this.el.width, this.el.height) } diff --git a/desktop/sources/scripts/renderer.js b/desktop/sources/scripts/manager.js similarity index 97% rename from desktop/sources/scripts/renderer.js rename to desktop/sources/scripts/manager.js index 951346d..ff1a665 100644 --- a/desktop/sources/scripts/renderer.js +++ b/desktop/sources/scripts/manager.js @@ -1,6 +1,8 @@ 'use strict' -DOTGRID.Renderer = function () { +// Manages the SVG file + +function Manager (dotgrid) { // Create SVG parts this.el = document.createElementNS('http://www.w3.org/2000/svg', 'svg') this.el.setAttribute('xmlns', 'http://www.w3.org/2000/svg') diff --git a/index.html b/index.html index 737d621..bead1be 100644 --- a/index.html +++ b/index.html @@ -22,9 +22,10 @@ + - +