Renderer is now the manager

This commit is contained in:
Devine Lu Linvega 2019-01-09 15:09:20 +12:00
parent cd02c01f0d
commit 55670a4a14
4 changed files with 18 additions and 15 deletions

View File

@ -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()
}

View File

@ -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)
}

View File

@ -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')

View File

@ -22,9 +22,10 @@
<script type="text/javascript" src="desktop/sources/scripts/lib/theme.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/lib/history.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/dotgrid.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/manager.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/cursor.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/guide.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/renderer.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/interface.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/tool.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/generator.js"></script>