Remove digital module, delete file

This commit is contained in:
mmcwilliams 2019-02-08 13:12:33 -05:00
parent aebacbccaf
commit 4a86d5d441
2 changed files with 0 additions and 220 deletions

View File

@ -1,67 +0,0 @@
'use strict'
//Original idea for "display" module.
const path = require('path')
const delay = require('../delay')
const exec = require('../exec')
const { ipcMain, BrowserWindow} = require('electron')
let digitalWindow
class Digital {
constructor() {
}
async open () {
digitalWindow = new BrowserWindow({
width: 800,
height: 600,
minWidth : 800,
minHeight : 600,
icon: path.join(__dirname, '../../assets/icons/icon.png')
})
digitalWindow.loadURL('file://' + __dirname + '../../../views/digital.html')
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
digitalWindow.webContents.openDevTools()
}
digitalWindow.on('closed', () => {
digitalWindow = null
})
}
async fullScreen () {
return digitalWindow.setFullScreen(true)
}
async setImage (src) {
return digitalWindow.webContents.send('digital', { src })
}
async setMeter () {
return digitalWindow.webContents.send('digital', { meter : true })
}
async setGrid () {
return digitalWindow.webContents.send('digital', { grid : true })
}
async setFocus (num = 1) {
let imagePath = path.join(__dirname, `../../data/focus${num}.jpg`)
return digitalWindow.webContents.send('digital', { src : imagePath })
}
async getDir (dirPath, num = 0) {
}
async getFrame (videoPath, num = 0) {
}
async close () {
if (digitalWindow) {
digitalWindow.close()
}
return true
}
async move () {
}
}
module.exports = Digital

View File

@ -1,153 +0,0 @@
<!doctype html>
<html>
<head>
<title>digital</title>
<style>
body{
background: #000;
}
body.meter {
background: rgb(117, 117, 117);
}
#img {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-size: 100%;
max-width: 100%;
max-height: 100%;
margin: auto;
overflow: auto;
}
#can{
margin: 0;
background: #fff;
display: none;
position: fixed;
left: 0;
top: 0;
}
#can.show{
display: block;
}
</style>
</head>
<body>
<img id="img">
</img>
<canvas id="can">
</canvas>
<script>
'use strict';
const { remote, ipcRenderer } = require('electron')
async function setImage (src) {
return new Promise(async (resolve, reject) => {
//let img = new Image()
let img = document.getElementById('img')
let body = document.querySelector('body')
if (body.classList.contains('meter')) {
body.classList.remove('meter')
}
img.onload = () => {
document.body.appendChild(img)
return resolve(img)
}
img.onerror = reject
img.src = src
})
}
async function setMeter () {
let body = document.querySelector('body')
if (!body.classList.contains('meter')) {
body.classList.add('meter')
}
}
async function setGrid () {
const can = document.getElementById('can')
const ctx = can.getContext('2d')
if (!can.classList.contains('show')) {
can.classList.add('show')
}
can.width = window.innerWidth
can.height = window.innerHeight
can.style.width = `${window.innerWidth}px`
can.style.height = `${window.innerHeight}px`
try{
await drawGrid(can, ctx)
} catch (err) {
alert(JSON.stringify(err))
}
}
async function drawGrid (can, ctx) {
const count = 20
const half = Math.round(count / 2)
const w = can.width
const h = can.height
const wsec = w / count
const hsec= h / count
ctx.moveTo(w / 2, 0)
ctx.lineTo(w / 2, h)
ctx.stroke()
ctx.moveTo(0, h / 2)
ctx.lineTo(w, h / 2)
ctx.stroke()
for (let i = 0; i < count; i++) {
ctx.moveTo(wsec * i, hsec * i)
ctx.lineTo(wsec * i, h - (hsec * i))
ctx.stroke()
ctx.moveTo(wsec * i, hsec * i)
ctx.lineTo(w - (wsec * i), hsec * i)
ctx.stroke()
}
ctx.font = '30px Arial'
for (let i = 0; i < half; i++) {
ctx.fillText(`${(half - i)}`, (wsec * i) + 15, (h / 2) - 15)
ctx.fillText(`${(half - i)}`, (w - (wsec * i)) - 25, (h / 2) - 15)
ctx.fillText(`${(half - i)}`, (w / 2) + 15, (hsec * i) + 25 )
ctx.fillText(`${(half - i)}`, (w / 2) + 15, (h - (hsec * i)) - 15)
}
}
async function onDigital (event, arg) {
if (arg.src) {
try {
await setImage(arg.src)
} catch (err) {
console.error(err)
}
} else if (arg.meter) {
try {
await setMeter()
} catch (err) {
console.error(err)
}
} else if (arg.grid) {
try {
await setGrid()
} catch (err) {
console.error(err)
}
}
return event.returnValue = true
}
async function onEscape (evt) {
let isEscape = false
let win
evt = evt || window.event
if ('key' in evt) {
isEscape = (evt.key == 'Escape' || evt.key == 'Esc')
} else {
isEscape = (evt.keyCode == 27)
}
if (isEscape) {
win = remote.getCurrentWindow()
win.close()
}
}
ipcRenderer.on('digital', onDigital)
document.onkeydown = onEscape
</script>
</body>
</html>