This commit is contained in:
Devine Lu Linvega 2019-01-09 16:53:28 +12:00
parent 44eb30cad5
commit 82dc0919c8
5 changed files with 24 additions and 24 deletions

View File

@ -3,7 +3,7 @@ const path = require('path')
const url = require('url') const url = require('url')
const shell = require('electron').shell const shell = require('electron').shell
let is_shown = true let isShown = true
app.on('ready', () => { app.on('ready', () => {
app.win = new BrowserWindow({ app.win = new BrowserWindow({
@ -27,11 +27,11 @@ app.on('ready', () => {
}) })
app.win.on('hide', function () { app.win.on('hide', function () {
is_shown = false isShown = false
}) })
app.win.on('show', function () { app.win.on('show', function () {
is_shown = true isShown = true
}) })
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
@ -59,7 +59,7 @@ app.toggle_visible = function () {
if (process.platform == 'win32') { if (process.platform == 'win32') {
if (!app.win.isMinimized()) { app.win.minimize() } else { app.win.restore() } if (!app.win.isMinimized()) { app.win.minimize() } else { app.win.restore() }
} else { } else {
if (is_shown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() } if (isShown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() }
} }
} }

View File

@ -19,7 +19,7 @@ function Generator (layer, style) {
// Rotate // Rotate
const center = { x: (DOTGRID.tool.settings.size.width / 2) + offset.x + (7.5), y: (DOTGRID.tool.settings.size.height / 2) + offset.y + 30 } const center = { x: (DOTGRID.tool.settings.size.width / 2) + offset.x + (7.5), y: (DOTGRID.tool.settings.size.height / 2) + offset.y + 30 }
seg.vertices[k2] = rotate_point(seg.vertices[k2], center, angle) seg.vertices[k2] = rotatePoint(seg.vertices[k2], center, angle)
// Scale // Scale
seg.vertices[k2].x *= scale seg.vertices[k2].x *= scale
@ -40,7 +40,7 @@ function Generator (layer, style) {
let vertex = vertices[id] let vertex = vertices[id]
let next = vertices[parseInt(id) + 1] let next = vertices[parseInt(id) + 1]
let after_next = vertices[parseInt(id) + 2] let afterNext = vertices[parseInt(id) + 2]
if (id == 0 && !prev || id == 0 && prev && (prev.x != vertex.x || prev.y != vertex.y)) { if (id == 0 && !prev || id == 0 && prev && (prev.x != vertex.x || prev.y != vertex.y)) {
html += `M${vertex.x},${vertex.y} ` html += `M${vertex.x},${vertex.y} `
@ -61,7 +61,7 @@ function Generator (layer, style) {
let clock = mirror > 0 ? '1,1' : '1,0' let clock = mirror > 0 ? '1,1' : '1,0'
html += this._arc(vertex, next, clock) html += this._arc(vertex, next, clock)
} else if (type == 'bezier') { } else if (type == 'bezier') {
html += this._bezier(next, after_next) html += this._bezier(next, afterNext)
skip = 1 skip = 1
} }
} }
@ -113,5 +113,5 @@ function Generator (layer, style) {
} }
function copy (data) { return data ? JSON.parse(JSON.stringify(data)) : [] } function copy (data) { return data ? JSON.parse(JSON.stringify(data)) : [] }
function rotate_point (point, origin, angle) { angle = angle * Math.PI / 180.0; return { x: (Math.cos(angle) * (point.x - origin.x) - Math.sin(angle) * (point.y - origin.y) + origin.x).toFixed(1), y: (Math.sin(angle) * (point.x - origin.x) + Math.cos(angle) * (point.y - origin.y) + origin.y).toFixed(1) } } function rotatePoint (point, origin, angle) { angle = angle * Math.PI / 180.0; return { x: (Math.cos(angle) * (point.x - origin.x) - Math.sin(angle) * (point.y - origin.y) + origin.x).toFixed(1), y: (Math.sin(angle) * (point.x - origin.x) + Math.cos(angle) * (point.y - origin.y) + origin.y).toFixed(1) } }
} }

View File

@ -100,12 +100,12 @@ function Interface (dotgrid) {
this.update = function (force = false, id) { this.update = function (force = false, id) {
if (this.prev_operation == dotgrid.cursor.operation && force == false) { return } if (this.prev_operation == dotgrid.cursor.operation && force == false) { return }
let multi_vertices = null let multiVertices = null
let segments = dotgrid.tool.layer() let segments = dotgrid.tool.layer()
const sum_segments = dotgrid.tool.length() const sumSegments = dotgrid.tool.length()
for (const i in segments) { for (const i in segments) {
if (segments[i].vertices.length > 2) { multi_vertices = true; break } if (segments[i].vertices.length > 2) { multiVertices = true; break }
} }
document.getElementById('option_line').className.baseVal = !dotgrid.tool.canCast('line') ? 'icon inactive' : 'icon' document.getElementById('option_line').className.baseVal = !dotgrid.tool.canCast('line') ? 'icon inactive' : 'icon'
@ -116,7 +116,7 @@ function Interface (dotgrid) {
document.getElementById('option_thickness').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' document.getElementById('option_thickness').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon'
document.getElementById('option_linecap').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' document.getElementById('option_linecap').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon'
document.getElementById('option_linejoin').className.baseVal = dotgrid.tool.layer().length < 1 || !multi_vertices ? 'icon inactive' : 'icon' document.getElementById('option_linejoin').className.baseVal = dotgrid.tool.layer().length < 1 || !multiVertices ? 'icon inactive' : 'icon'
document.getElementById('option_mirror').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' document.getElementById('option_mirror').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon'
document.getElementById('option_fill').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' document.getElementById('option_fill').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon'
@ -126,9 +126,9 @@ function Interface (dotgrid) {
// Source // Source
document.getElementById('option_save').className.baseVal = sum_segments < 1 ? 'icon inactive source' : 'icon source' document.getElementById('option_save').className.baseVal = sumSegments < 1 ? 'icon inactive source' : 'icon source'
document.getElementById('option_export').className.baseVal = sum_segments < 1 ? 'icon inactive source' : 'icon source' document.getElementById('option_export').className.baseVal = sumSegments < 1 ? 'icon inactive source' : 'icon source'
document.getElementById('option_render').className.baseVal = sum_segments < 1 ? 'icon inactive source' : 'icon source' document.getElementById('option_render').className.baseVal = sumSegments < 1 ? 'icon inactive source' : 'icon source'
document.getElementById('option_grid').className.baseVal = dotgrid.renderer.showExtras ? 'icon inactive source' : 'icon source' document.getElementById('option_grid').className.baseVal = dotgrid.renderer.showExtras ? 'icon inactive source' : 'icon source'

View File

@ -62,18 +62,18 @@ function Controller () {
} }
this.generate_svg = function (m) { this.generate_svg = function (m) {
let svg_html = '' let html = ''
for (const id in this.layout) { for (const id in this.layout) {
let key = this.layout[id] let key = this.layout[id]
let acc = this.accelerator_for_key(key.name, m) let acc = this.accelerator_for_key(key.name, m)
svg_html += `<rect x="${key.x + 1}" y="${key.y + 1}" width="${key.width - 2}" height="${key.height - 2}" rx="4" ry="4" title="${key.name}" stroke="#ccc" fill="none" stroke-width="1"/>` html += `<rect x="${key.x + 1}" y="${key.y + 1}" width="${key.width - 2}" height="${key.height - 2}" rx="4" ry="4" title="${key.name}" stroke="#ccc" fill="none" stroke-width="1"/>`
svg_html += `<rect x="${key.x + 3}" y="${key.y + 3}" width="${key.width - 6}" height="${key.height - 12}" rx="3" ry="3" title="${key.name}" stroke="${acc.basic ? '#000' : acc.ctrl ? '#ccc' : '#fff'}" fill="${acc.basic ? '#000' : acc.ctrl ? '#ccc' : '#fff'}" stroke-width="1"/>` html += `<rect x="${key.x + 3}" y="${key.y + 3}" width="${key.width - 6}" height="${key.height - 12}" rx="3" ry="3" title="${key.name}" stroke="${acc.basic ? '#000' : acc.ctrl ? '#ccc' : '#fff'}" fill="${acc.basic ? '#000' : acc.ctrl ? '#ccc' : '#fff'}" stroke-width="1"/>`
svg_html += `<text x="${key.x + 10}" y="${key.y + 20}" font-size='11' font-family='Input Mono' stroke-width='0' fill='${acc.basic ? '#fff' : '#000'}'>${key.name.toUpperCase()}</text>` html += `<text x="${key.x + 10}" y="${key.y + 20}" font-size='11' font-family='Input Mono' stroke-width='0' fill='${acc.basic ? '#fff' : '#000'}'>${key.name.toUpperCase()}</text>`
svg_html += acc && acc.basic ? `<text x="${key.x + 10}" y="${key.y + 35}" font-size='7' font-family='Input Mono' stroke-width='0' fill='#fff'>${acc.basic}</text>` : '' html += acc && acc.basic ? `<text x="${key.x + 10}" y="${key.y + 35}" font-size='7' font-family='Input Mono' stroke-width='0' fill='#fff'>${acc.basic}</text>` : ''
svg_html += acc && acc.ctrl ? `<text x="${key.x + 10}" y="${key.y + 45}" font-size='7' font-family='Input Mono' stroke-width='0' fill='#000'>${acc.ctrl}</text>` : '' html += acc && acc.ctrl ? `<text x="${key.x + 10}" y="${key.y + 45}" font-size='7' font-family='Input Mono' stroke-width='0' fill='#000'>${acc.ctrl}</text>` : ''
} }
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="900" height="300" version="1.0" style="fill:none;stroke:black;stroke-width:2px;">${svg_html}</svg>` return `<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="900" height="300" version="1.0" style="fill:none;stroke:black;stroke-width:2px;">${html}</svg>`
} }
this.documentation = function () { this.documentation = function () {

View File

@ -61,7 +61,7 @@ function Picker (dotgrid) {
} }
this.listen = function (e, is_down = false) { this.listen = function (e, is_down = false) {
if (is_down && !is_color_char(e.key)) { if (is_down && !isColorChar(e.key)) {
e.preventDefault() e.preventDefault()
return return
} }
@ -90,7 +90,7 @@ function Picker (dotgrid) {
return re.test(val) return re.test(val)
} }
function is_color_char (val) { function isColorChar (val) {
const re = /[0-9A-Fa-f]/g const re = /[0-9A-Fa-f]/g
return re.test(val) return re.test(val)
} }