From 6ae606d8766a0b8bd1928565500c745add1dbea2 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 9 Jan 2019 16:44:24 +1200 Subject: [PATCH] Aligned renderer --- desktop/sources/scripts/dotgrid.js | 18 +++++++----------- desktop/sources/scripts/renderer.js | 8 ++++---- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js index 7881b9f..9d3eb39 100644 --- a/desktop/sources/scripts/dotgrid.js +++ b/desktop/sources/scripts/dotgrid.js @@ -1,18 +1,15 @@ 'use strict' function Dotgrid (width, height) { - this.controller = null - const defaultTheme = { background: '#eee', f_high: '#000', f_med: '#999', f_low: '#ccc', f_inv: '#000', b_high: '#000', b_med: '#888', b_low: '#aaa', b_inv: '#ffb545' } - this.theme = new Theme(defaultTheme) - this.history = new History() - this.grid = { x: 20, y: 20, width: 0, height: 0 } // ISU this.install = function (host) { + this.theme = new Theme(defaultTheme) + this.history = new History() this.manager = new Manager(this) this.renderer = new Renderer(this) this.tool = new Tool(this) @@ -121,8 +118,8 @@ function Dotgrid (width, height) { this.grid = { x: size.width / 15, y: size.height / 15, - width: this.tool.settings.size.width / size.width / 15, - height: this.tool.settings.size.height / size.height / 15 + width: 15, + height: 15 } this.renderer.resize(size) @@ -169,12 +166,11 @@ function Dotgrid (width, height) { this.grid = { x: size.width / 15, - y: size.height / 15 + y: size.height / 15, + width: 15, + height: 15 } - this.grid.width = this.tool.settings.size.width / this.grid.x - this.grid.height = this.tool.settings.size.height / this.grid.y - this.renderer.resize(size) document.title = `Dotgrid — ${size.width}x${size.height}` diff --git a/desktop/sources/scripts/renderer.js b/desktop/sources/scripts/renderer.js index 19c948a..620bb32 100644 --- a/desktop/sources/scripts/renderer.js +++ b/desktop/sources/scripts/renderer.js @@ -23,8 +23,8 @@ function Renderer (dotgrid) { this.drawMirror() this.drawRulers() - this.drawRender() // this.drawGrid() + this.drawRender() // this.drawVertices() this.drawHandles() this.drawTranslation() @@ -255,13 +255,13 @@ function Renderer (dotgrid) { this.drawRender = function () { let img = new Image() img.src = dotgrid.manager.svg64() - this.context.drawImage(img, 0, 0, this.el.width, this.el.height) + this.context.drawImage(img, 0, 0, this.el.width - 30, this.el.height - 30) } this.drawDebug = function () { this.context.strokeRect(0, 0, this.el.width, this.el.height) - this.context.strokeRect(this.el.width / 2, 0, this.el.width, this.el.height) - this.context.strokeRect(0, this.el.height / 2, this.el.width, this.el.height) + this.context.strokeRect((this.el.width / 2) + 15, 0, this.el.width, this.el.height) + this.context.strokeRect(0, (this.el.height / 2) + 15, this.el.width, this.el.height) } function isEqual (a, b) { return a && b && Math.abs(a.x) == Math.abs(b.x) && Math.abs(a.y) == Math.abs(b.y) }