Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
neauoire committed Feb 14, 2018
1 parent fc3b495 commit d1a9469
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
builds/
.DS_Store
*/.DS_Store
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Hundredrabbits

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
61 changes: 61 additions & 0 deletions desktop/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const {app, BrowserWindow, webFrame, Menu} = require('electron')
const path = require('path')
const url = require('url')
const shell = require('electron').shell;

let win

let is_shown = true;

app.inspect = function()
{
app.win.toggleDevTools();
}

app.toggle_fullscreen = function()
{
app.win.setFullScreen(app.win.isFullScreen() ? false : true);
}

app.toggle_visible = function()
{
if(is_shown){ app.win.hide(); } else{ app.win.show(); }
}

app.inject_menu = function(m)
{
Menu.setApplicationMenu(Menu.buildFromTemplate(m));
}

app.win = null;

app.on('ready', () =>
{
app.win = new BrowserWindow({width: 700, height: 700, minWidth:700, minHeight:700, frame:false, autoHideMenuBar: true,backgroundColor: '#000000', resizable:true, autoHideMenuBar: true,icon: __dirname + '/icon.ico'})

app.win.loadURL(`file://${__dirname}/sources/index.html`)

app.win.on('closed', () => {
win = null
app.quit()
})

app.win.on('hide',function() {
is_shown = false;
})

app.win.on('show',function() {
is_shown = true;
})
})

app.on('window-all-closed', () =>
{
app.quit()
})

app.on('activate', () => {
if (app.win === null) {
createWindow()
}
})
20 changes: 20 additions & 0 deletions desktop/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Clock",
"version": "0.1.0",
"main": "main.js",
"scripts": {
"start": "electron .",
"time":"node time.js",
"clean" : "rm -r ~/Desktop/Clock-darwin-x64/ ; rm -r ~/Desktop/Clock-linux-x64/ ; rm -r ~/Desktop/Clock-win32-x64/ ; echo 'cleaned build location'",
"build_osx" : "electron-packager . Clock --platform=darwin --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.icns ; echo 'Built for OSX'",
"build_linux" : "electron-packager . Clock --platform=linux --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'",
"build_win" : "electron-packager . Clock --platform=win32 --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for WIN'",
"build" : "npm run clean ; npm run build_osx ; npm run build_linux ; npm run build_win"
},
"devDependencies": {
"electron": "^1.8.1"
},
"dependencies": {
"electron-packager": "^8.4.0"
}
}
25 changes: 25 additions & 0 deletions desktop/sources/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<head>
<script type="text/javascript" src="scripts/pico.js"></script>
<script type="text/javascript" src="scripts/program.js"></script>
<script type="text/javascript" src="scripts/grid.js"></script>

<script type="text/javascript" src="scripts/cells/cell.js"></script>
<script type="text/javascript" src="scripts/cells/generator.js"></script>

<link rel="stylesheet" type="text/css" href="links/reset.css"/>
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
<link rel="stylesheet" type="text/css" href="links/main.css"/>

<title>Pico</title>
</head>
<body>
<script>

var pico = new Pico();
pico.install();
pico.start();

</script>
</body>
</html>
15 changes: 15 additions & 0 deletions desktop/sources/links/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Input */

@font-face {
font-family: 'input_mono_regular';
src: url('../media/fonts/input_mono_regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'input_mono_medium';
src: url('../media/fonts/input_mono_medium.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
2 changes: 2 additions & 0 deletions desktop/sources/links/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
body { background:black; color:white; font-family: 'input_mono_regular'; padding:60px; }
grid { display: block;white-space: pre;font-size: 11px;line-height: 10px; }
1 change: 1 addition & 0 deletions desktop/sources/links/reset.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions desktop/sources/scripts/cells/cell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function Cell(x,y)
{
this.x = x;
this.y = y;
this.glyph = "."

this.run = function()
{

}
}
6 changes: 6 additions & 0 deletions desktop/sources/scripts/cells/generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function Generator(x,y)
{
Cell.call(this,x,y);

this.glyph = "G";
}
28 changes: 28 additions & 0 deletions desktop/sources/scripts/grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function Grid()
{
this.el = document.createElement("grid");

this.install = function(host)
{
host.appendChild(this.el)
}

this.update = function()
{
console.log(pico.program.cells)
var html = "";

var y = 0;
while(y < pico.program.h){
var x = 0;
while(x < pico.program.w){
html += pico.program.glyph_at(x,y);
x += 1
}
html += "\n"
y += 1;
}

this.el.innerHTML = html;
}
}
26 changes: 26 additions & 0 deletions desktop/sources/scripts/pico.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function Pico()
{
this.el = document.createElement("app");

this.program = new Program(64,48);
this.grid = new Grid();

this.install = function()
{
this.grid.install(this.el);
this.program.reset();
document.body.appendChild(this.el)
}

this.start = function()
{
this.program.add(10,10,"G");
setInterval(() => { this.run(); }, 1000)
}

this.run = function()
{
this.program.run();
this.grid.update();
}
}
44 changes: 44 additions & 0 deletions desktop/sources/scripts/program.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function Program(w,h)
{
this.w = w;
this.h = h;
this.s = "";

this.reset = function()
{
var y = 0;
while(y < this.h){
var x = 0;
while(x < this.w){
this.s += "."
x += 1
}
y += 1;
}
}

this.add = function(x,y,glyph)
{
var index = this.index_at(x,y);
this.s = this.s.substr(0, index)+glyph+this.s.substr(index+glyph.length);
pico.grid.update();
}

this.run = function()
{
for(id in this.cells){
var cell = this.cells[id];
cell.run();
}
}

this.glyph_at = function(x,y)
{
return this.s.substr(this.index_at(x,y),1);
}

this.index_at = function(x,y)
{
return x + (this.w * y);
}
}

0 comments on commit d1a9469

Please sign in to comment.