diff options
author | Devine Lu Linvega <[email protected]> | 2018-11-17 13:38:08 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-11-17 13:38:08 +1200 |
commit | 468dbff4cf2fb7964a97f38dfb193f480eac3058 (patch) | |
tree | 9b6680d5b9246db21c9264721650a8df98b8ad08 | |
parent | ceb3be7bca3cbbe6ff08fa4373e2775a0a0a72b6 (diff) | |
download | Orca-468dbff4cf2fb7964a97f38dfb193f480eac3058.tar.gz Orca-468dbff4cf2fb7964a97f38dfb193f480eac3058.zip |
Started re-implementing drawing
34 files changed, 103 insertions, 92 deletions
diff --git a/desktop/core/lib/_bang.js b/desktop/core/lib/_bang.js index db6e148..3e133c0 100644 --- a/desktop/core/lib/_bang.js +++ b/desktop/core/lib/_bang.js @@ -2,7 +2,7 @@ const FnBase = require('./_base') -function FnBang (pico, x, y, passive) { +function FnBang (pico, x, y, isPassive) { FnBase.call(this, pico, x, y, '*', true) this.name = 'bang' diff --git a/desktop/core/lib/_base.js b/desktop/core/lib/_base.js index 5e4b45e..2f17107 100644 --- a/desktop/core/lib/_base.js +++ b/desktop/core/lib/_base.js @@ -1,16 +1,16 @@ 'use strict' -function FnBase (pico, x, y, glyph = '.', passive = false) { +function FnBase (pico, x, y, glyph = '.', isPassive = false) { this.x = x this.y = y - this.passive = passive + this.isPassive = isPassive this.name = 'unknown' - this.glyph = passive ? glyph.toUpperCase() : glyph + this.glyph = isPassive ? glyph.toUpperCase() : glyph this.info = 'Missing docs.' this.ports = { input: {}, haste: {}, bang: null } this.docs = 'Hello!' - if (!passive) { + if (!isPassive) { this.ports.bang = true } diff --git a/desktop/core/lib/_comment.js b/desktop/core/lib/_comment.js index f9d1f7c..a03e8a8 100644 --- a/desktop/core/lib/_comment.js +++ b/desktop/core/lib/_comment.js @@ -2,11 +2,12 @@ const FnBase = require('./_base') -function FnComment (pico, x, y, passive) { +function FnComment (pico, x, y, isPassive) { FnBase.call(this, pico, x, y, ';', true) this.name = 'comment' this.info = 'Block Comment' + this.isPassive = false this.haste = function () { let count = 0 diff --git a/desktop/core/lib/_midi.js b/desktop/core/lib/_midi.js index 6446a1d..91bd475 100644 --- a/desktop/core/lib/_midi.js +++ b/desktop/core/lib/_midi.js @@ -2,7 +2,7 @@ const FnBase = require('./_base') -function FnMidi (pico, x, y, passive) { +function FnMidi (pico, x, y, isPassive) { FnBase.call(this, pico, x, y, ':', true) this.name = 'midi' diff --git a/desktop/core/lib/_null.js b/desktop/core/lib/_null.js index c682f34..5a0ca63 100644 --- a/desktop/core/lib/_null.js +++ b/desktop/core/lib/_null.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnNull (pico, x, y, passive) { - FnBase.call(this, pico, x, y, '.', passive) +function FnNull (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, '.', isPassive) this.name = 'null' this.info = 'void' diff --git a/desktop/core/lib/a.js b/desktop/core/lib/a.js index 589c4f8..d7bef28 100644 --- a/desktop/core/lib/a.js +++ b/desktop/core/lib/a.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnA (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'a', passive) +function FnA (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'a', isPassive) this.name = 'add' this.info = 'Creates the result of the addition of east and west fns, southward.' diff --git a/desktop/core/lib/b.js b/desktop/core/lib/b.js index 511ed2c..0b5049e 100644 --- a/desktop/core/lib/b.js +++ b/desktop/core/lib/b.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnB (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'b', passive) +function FnB (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'b', isPassive) this.name = 'banger' this.info = 'Bangs southward in the presence of `1`, `N`, `S`, `W`, `E` or `Z` northward.' diff --git a/desktop/core/lib/c.js b/desktop/core/lib/c.js index ca2dbc4..d7845dc 100644 --- a/desktop/core/lib/c.js +++ b/desktop/core/lib/c.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnC (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'c', passive) +function FnC (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'c', isPassive) this.name = 'clock' this.info = 'Adds a constant value southward.' diff --git a/desktop/core/lib/d.js b/desktop/core/lib/d.js index 39594a5..8dd934a 100644 --- a/desktop/core/lib/d.js +++ b/desktop/core/lib/d.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnD (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'd', passive) +function FnD (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'd', isPassive) } module.exports = FnD diff --git a/desktop/core/lib/e.js b/desktop/core/lib/e.js index 4f72a9c..f1a4ea2 100644 --- a/desktop/core/lib/e.js +++ b/desktop/core/lib/e.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnE (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'e', passive) +function FnE (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'e', isPassive) this.name = 'east' this.info = 'Moves eastward, or bangs.' diff --git a/desktop/core/lib/f.js b/desktop/core/lib/f.js index 560db9a..d162e48 100644 --- a/desktop/core/lib/f.js +++ b/desktop/core/lib/f.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnF (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'f', passive) +function FnF (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'f', isPassive) this.name = 'if' this.info = 'Bangs if east and west fns are equal, southward.' diff --git a/desktop/core/lib/g.js b/desktop/core/lib/g.js index 6e02ea5..3addeb5 100644 --- a/desktop/core/lib/g.js +++ b/desktop/core/lib/g.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnG (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'g', passive) +function FnG (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'g', isPassive) this.name = 'generator' this.info = 'Generates a direction fn from bang.' diff --git a/desktop/core/lib/h.js b/desktop/core/lib/h.js index f61ee4a..ed48ecd 100644 --- a/desktop/core/lib/h.js +++ b/desktop/core/lib/h.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnH (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'h', passive) +function FnH (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'h', isPassive) this.name = 'halt' this.info = 'Stops southward fn from operating.' diff --git a/desktop/core/lib/i.js b/desktop/core/lib/i.js index 2ae8735..5b34573 100644 --- a/desktop/core/lib/i.js +++ b/desktop/core/lib/i.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnI (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'i', passive) +function FnI (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'i', isPassive) this.name = 'increment' this.info = 'Increments southward numeric fn on bang.' diff --git a/desktop/core/lib/j.js b/desktop/core/lib/j.js index e231068..3bcb7e2 100644 --- a/desktop/core/lib/j.js +++ b/desktop/core/lib/j.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnJ (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'j', passive) +function FnJ (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'j', isPassive) this.name = 'jump' this.info = 'Copies the northward fn, southwardly.' diff --git a/desktop/core/lib/k.js b/desktop/core/lib/k.js index cd9d5b2..894cc49 100644 --- a/desktop/core/lib/k.js +++ b/desktop/core/lib/k.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnK (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'k', passive) +function FnK (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'k', isPassive) this.name = 'kill' this.info = 'Kills southward fns, on bang.' diff --git a/desktop/core/lib/l.js b/desktop/core/lib/l.js index e49090c..998c177 100644 --- a/desktop/core/lib/l.js +++ b/desktop/core/lib/l.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnL (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'l', passive) +function FnL (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'l', isPassive) this.name = 'loop' this.info = 'Loop a number of characters ahead.' diff --git a/desktop/core/lib/m.js b/desktop/core/lib/m.js index 96ac87f..4f1b6c4 100644 --- a/desktop/core/lib/m.js +++ b/desktop/core/lib/m.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnM (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'm', passive) +function FnM (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'm', isPassive) this.name = 'modulo' this.info = 'Creates the result of the modulo operation of east and west fns, southward.' diff --git a/desktop/core/lib/n.js b/desktop/core/lib/n.js index 4bd594e..c263280 100644 --- a/desktop/core/lib/n.js +++ b/desktop/core/lib/n.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnN (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'n', passive) +function FnN (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'n', isPassive) this.name = 'north' this.info = 'Moves Northward, or bangs.' diff --git a/desktop/core/lib/o.js b/desktop/core/lib/o.js index 8942cfc..01a00e3 100644 --- a/desktop/core/lib/o.js +++ b/desktop/core/lib/o.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnO (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'o', passive) +function FnO (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'o', isPassive) } module.exports = FnO diff --git a/desktop/core/lib/p.js b/desktop/core/lib/p.js index b9f5de8..40f8385 100644 --- a/desktop/core/lib/p.js +++ b/desktop/core/lib/p.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnP (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'p', passive) +function FnP (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'p', isPassive) } module.exports = FnP diff --git a/desktop/core/lib/q.js b/desktop/core/lib/q.js index f9d0c46..3eb4fd0 100644 --- a/desktop/core/lib/q.js +++ b/desktop/core/lib/q.js @@ -2,7 +2,7 @@ const FnBase = require('./_base') -function FnQ (pico, x, y, passive) { +function FnQ (pico, x, y, isPassive) { FnBase.call(this, pico, x, y, 'q', true) } diff --git a/desktop/core/lib/r.js b/desktop/core/lib/r.js index 6d92761..226468e 100644 --- a/desktop/core/lib/r.js +++ b/desktop/core/lib/r.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnR (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'r', passive) +function FnR (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'r', isPassive) this.name = 'raycast' this.info = 'Sends a bang to the nearest fn following the direction of the bang.' diff --git a/desktop/core/lib/s.js b/desktop/core/lib/s.js index e91b2e3..56f56fc 100644 --- a/desktop/core/lib/s.js +++ b/desktop/core/lib/s.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnS (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 's', passive) +function FnS (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 's', isPassive) this.name = 'south' this.info = 'Moves southward, or bangs.' diff --git a/desktop/core/lib/t.js b/desktop/core/lib/t.js index e58facb..e4913d6 100644 --- a/desktop/core/lib/t.js +++ b/desktop/core/lib/t.js @@ -2,14 +2,15 @@ const FnBase = require('./_base') -function FnT (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'u', passive) +function FnT (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'u', isPassive) this.name = 'track' this.info = 'Read character at position.' this.ports.haste.len = { x: -1, y: 0 } this.ports.haste.key = { x: -2, y: 0 } + this.ports.output = true this.haste = function () { this.len = this.listen(this.ports.haste.len, true) diff --git a/desktop/core/lib/u.js b/desktop/core/lib/u.js index c6e3d91..18ae10f 100644 --- a/desktop/core/lib/u.js +++ b/desktop/core/lib/u.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnU (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'u', passive) +function FnU (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'u', isPassive) } module.exports = FnU diff --git a/desktop/core/lib/v.js b/desktop/core/lib/v.js index 4255440..1e6209e 100644 --- a/desktop/core/lib/v.js +++ b/desktop/core/lib/v.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnV (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'v', passive) +function FnV (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'v', isPassive) this.name = 'values' this.info = 'Count the number of fns present eastwardly.' diff --git a/desktop/core/lib/w.js b/desktop/core/lib/w.js index 45a0fe9..ef0a12c 100644 --- a/desktop/core/lib/w.js +++ b/desktop/core/lib/w.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnW (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'w', passive) +function FnW (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'w', isPassive) this.name = 'west' this.info = 'Moves westward, or bangs.' diff --git a/desktop/core/lib/x.js b/desktop/core/lib/x.js index 4e939d6..15d1193 100644 --- a/desktop/core/lib/x.js +++ b/desktop/core/lib/x.js @@ -2,13 +2,14 @@ const FnBase = require('./_base') -function FnX (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'x', passive) +function FnX (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'x', isPassive) this.name = 'split' this.info = 'Bangs eastward when westward fn is 0, and southward when fn is 1.' this.ports.input.val = { x: 1, y: 0 } + this.ports.output = true this.operation = function () { const val = this.listen(this.ports.input.val) diff --git a/desktop/core/lib/y.js b/desktop/core/lib/y.js index 02c6134..cf2fcf6 100644 --- a/desktop/core/lib/y.js +++ b/desktop/core/lib/y.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnY (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'y', passive) +function FnY (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'y', isPassive) this.name = 'type' this.info = 'Compares the type(num/alpha/special) of westward and eastward fns, and return 1 or 0 southward.' diff --git a/desktop/core/lib/z.js b/desktop/core/lib/z.js index aacbb25..4d470a3 100644 --- a/desktop/core/lib/z.js +++ b/desktop/core/lib/z.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnZ (pico, x, y, passive) { - FnBase.call(this, pico, x, y, 'z', passive) +function FnZ (pico, x, y, isPassive) { + FnBase.call(this, pico, x, y, 'z', isPassive) this.name = 'creep' this.info = 'Moves to a the next available location in a cycle of E, S, W, N based on the runtime frame.' diff --git a/desktop/core/pico.js b/desktop/core/pico.js index 50128c4..e335965 100644 --- a/desktop/core/pico.js +++ b/desktop/core/pico.js @@ -52,8 +52,8 @@ function Pico (w, h) { } if (this.lib.alpha[g.toLowerCase()]) { - const passive = g === g.toUpperCase() - return new this.lib.alpha[g.toLowerCase()](this, x, y, passive) + const isPassive = g === g.toUpperCase() + return new this.lib.alpha[g.toLowerCase()](this, x, y, isPassive) } } @@ -81,7 +81,7 @@ function Pico (w, h) { for (const id in fns) { const fn = fns[id] if (this.isLocked(fn.x, fn.y)) { continue } - if (fn.passive || fn.bang()) { + if (fn.isPassive || fn.bang()) { fn.locks() fn.haste() } @@ -90,7 +90,7 @@ function Pico (w, h) { for (const id in fns) { const fn = fns[id] if (this.isLocked(fn.x, fn.y)) { continue } - if (fn.passive || fn.bang()) { + if (fn.isPassive || fn.bang()) { fn.run() } } diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index b486802..3ec1c0e 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -112,12 +112,12 @@ function Terminal (pico) { for (const id in fns) { const g = fns[id] if (pico.isLocked(g.x, g.y)) { continue } - for (const id in g.ports) { - const port = g.ports[id] - // h[`${g.x + port.x}:${g.y + port.y}`] = port.output ? 2 : port.bang ? 1 : 3 - } + if (g.isPassive) { h[`${g.x}:${g.y}`] = 4 } + // for (const id in g.ports) { + // const port = g.ports[id] + // // h[`${g.x + port.x}:${g.y + port.y}`] = port.output ? 2 : port.bang ? 1 : 3 + // } } - return h } @@ -202,6 +202,10 @@ function Terminal (pico) { ctx.fillStyle = this.theme.active.b_low ctx.fillRect(x * this.tile.w, (y) * this.tile.h, this.tile.w, this.tile.h) ctx.fillStyle = this.theme.active.f_high + } else if (styles.isPort === 4) { // Passive + ctx.fillStyle = this.theme.active.b_med + ctx.fillRect(x * this.tile.w, (y) * this.tile.h, this.tile.w, this.tile.h) + ctx.fillStyle = this.theme.active.f_low } } else if (styles.isLocked) { ctx.fillStyle = this.theme.active.background @@ -214,6 +218,7 @@ function Terminal (pico) { } this.resize = function () { + this.size = { width: this.tile.w * pico.w, height: this.tile.h * pico.h + (this.tile.h * 3), ratio: 0.5 } this.el.width = this.size.width this.el.height = this.size.height + this.tile.h this.el.style.width = (this.size.width * this.size.ratio) + 'px' diff --git a/examples/benchmark.pico b/examples/benchmark.pico index a48d84a..76eb589 100644 --- a/examples/benchmark.pico +++ b/examples/benchmark.pico @@ -1,23 +1,26 @@ -................................................................................... -................................................................................... -...A.....B....C.....F.....I......Lc...M.......Tc...X....Y.......................... -................................................................................... -................................................................................... -...A2....B1...C2....F2....I2....0Lc...M2.....3Tc...X1...Y2......................... -................................................................................... -................................................................................... -...A.2...B0...C.2...F.2...I.2...1Lc...M.2...4.Tc...X0...Y.2........................ -................................................................................... -................................................................................... -...A22...Bw...C22...F22...I22...2Lc...M22...03Tc...Xa...Y22........................ -................................................................................... -................................................................................... -...A23...Bs...C23...F23...I23...3Lc...M23...13Tc........Y23........................ -................................................................................... -................................................................................... -...A2K...Be...C2K...F2K...I2K.........M9K...c3Tc........Y2K........................ -................................................................................... -................................................................................... -...AK2...Bw...CK2...FKK...IK2.........MK6...50T.........YKK........................ -................................................................................... -...................................................................................
\ No newline at end of file +............................................................................... +............................................................................... +...;.....;.....;.....;.....;.....;.....;.....;.....;.....;.....;.....;.....;... +...A.....B.....C.....F.....I.....Lc....M.....Tc....X.....Y..................... +............................................................................... +............................................................................... +...A2....B1....C2....F2....I2...0Lc....M2...3Tc....X1....Y2.................... +............................................................................... +............................................................................... +...A.2...B0....C.2...F.2...I.2..1Lc....M.2.4.Tc....X0....Y.2................... +............................................................................... +............................................................................... +...A22...Bw....C22...F22...I22..2Lc....M22.03Tc....Xa....Y22................... +............................................................................... +............................................................................... +...A23...Bs....C23...F23...I23..3Lc....M23.13Tc..........Y23................... +............................................................................... +............................................................................... +...A2K...Be....C2K...F2K...I2K.........M9K.c3Tc..........Y2K................... +............................................................................... +............................................................................... +...AK2...Bw....CK2...FKK...IK2.........MK6.50T...........YKK................... +............................................................................... +............................................................................... +............................................................................... +...............................................................................
\ No newline at end of file |