Browse Source

Merge branch 'master' of https://github.com/lewish/asciiflow2

(also recompile)
master
LMLB 2 years ago
parent
commit
a98685a50e
5 changed files with 33 additions and 17 deletions
  1. +8
    -7
      index.html
  2. +3
    -0
      index.js
  3. +6
    -6
      js-compiled.js
  4. +2
    -2
      js-compiled.js.map
  5. +14
    -2
      js-lib/draw/line.js

+ 8
- 7
index.html View File

@ -342,12 +342,12 @@ textarea {
</div>
<div id="file-tools">
<button id="export-button" class="tool export-image"></button>
<button id="import-button" class="tool import-image"></button>
<button id="clear-button" class="tool clear-image"></button>
<button id="undo-button" class="tool undo-image"></button>
<button id="redo-button" class="tool redo-image"></button>
<button id="options-button" class="tool info-image"></button>
<button id="export-button" class="tool export-image" title="Export"></button>
<button id="import-button" class="tool import-image" title="Import"></button>
<button id="clear-button" class="tool clear-image" title="Clear"></button>
<button id="undo-button" class="tool undo-image" title="Undo"></button>
<button id="redo-button" class="tool redo-image" title="Redo"></button>
<button id="options-button" class="tool info-image" title="Info"></button>
</div>
@ -365,7 +365,8 @@ textarea {
<button id="use-lines-button">Lines Mode</button>
<button id="use-ascii-button">ASCII Mode</button><br>
<p>Moving around.<br>
Desktop: <span>Hold CTRL and drag the screen.</span><br>
Desktop Windows: <span>Hold CTRL and drag the screen.</span><br>
Desktop OSX: <span>Hold CMD and drag the screen.</span><br>
Mobile: <span>Drag quickly to move. Press and hold to start drawing. Pinch to zoom in/out.</span></p>
<div class="info-icon box-image"></div><div class="info-description">Draw boxes. <span>You can resize them later with the Resize tool.</span></div><br>
<div class="info-icon line-image"></div><div class="info-description">Draw lines. <span>Connect it to another line to change the orientation.</span></div><br>


+ 3
- 0
index.js View File

@ -14,6 +14,9 @@ electron.app.on("ready", () => {
width: 800,
height: 600,
icon: path.join(__dirname, "images", "favicon.png"),
webPreferences: {
nodeIntegration: false,
},
});
mainWindow.setMenu(null);
mainWindow.loadURL(url.format({


+ 6
- 6
js-compiled.js View File

@ -1,13 +1,13 @@
(function(){var g;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}function k(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}var ba="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},ca="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;
function m(a,b){if(b){var c=ca;a=a.split(".");for(var e=0;e<a.length-1;e++){var f=a[e];f in c||(c[f]={});c=c[f]}a=a[a.length-1];e=c[a];b=b(e);b!=e&&null!=b&&ba(c,a,{configurable:!0,writable:!0,value:b})}}m("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}});
m("Array.prototype.includes",function(a){return a?a:function(a,c){var b=this;b instanceof String&&(b=String(b));var f=b.length;c=c||0;for(0>c&&(c=Math.max(c+f,0));c<f;c++){var d=b[c];if(d===a||Object.is(d,a))return!0}return!1}});m("Math.sign",function(a){return a?a:function(a){a=Number(a);return 0===a||isNaN(a)?a:0<a?1:-1}});function q(a,b){this.x=a;this.y=b}function r(a,b){a=a.touches[void 0===b?0:b];return new q(a.pageX,a.pageY)}
function t(a,b){return null!==b&&void 0!==b&&a.x===b.x&&a.y===b.y}function u(a,b){return new q(a.x-b.x,a.y-b.y)}q.prototype.add=function(a){return new q(this.x+a.x,this.y+a.y)};q.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};q.prototype.scale=function(a){return new q(this.x*a,this.y*a)};function v(a){return new q(a.x,a.y-1)}function x(a){return new q(a.x,a.y+1)}function z(a){return new q(a.x-1,a.y)}function A(a){return new q(a.x+1,a.y)};var B=["+","\u2012","\u2013","-","|"],C=[">","<","^","v"],da=B.concat(C),D=[new q(-1,0),new q(1,0),new q(0,-1),new q(0,1)];function E(a,b){this.a=Math.min(a.x,b.x);this.b=Math.min(a.y,b.y);this.c=Math.max(a.x,b.x);this.f=Math.max(a.y,b.y)}function F(a){return new q(a.a,a.b)}function G(a,b){return b.x>=a.a&&b.x<=a.c&&b.y>=a.b&&b.y<=a.f}function ea(){this.a=this.value=null}function H(a){return null===a.a?a.value:a.a}function I(a){return da.includes(H(a))}function J(a){return null===a.value&&null===a.a}function fa(a,b,c,e){this.a=a;this.b=b;this.f=c;this.c=e;this.i=this.g=this.u=this.h=!1}
function K(a){return a.a+a.b+a.f+a.c}function L(a,b){this.position=a;this.value=b}function ha(a,b){this.position=a;this.a=b};function ia(a){for(var b=0;b<a.a.length;b++)for(var c=0;c<a.a[b].length;c++)null!==H(a.a[b][c])&&M(a,new q(b,c),"\u2009");N(a)}function O(a,b){a=a.a[b.x][b.y];if(void 0===a||null===a)throw Error("Cell not found");return a}function M(a,b,c){var e=O(a,b);a.b.push(new ha(b,e));e.a=c;a.c=!0}function P(a,b,c){H(O(a,b))!==c&&M(a,b,c)}function Q(a){for(var b=k(a.b),c=b.next();!c.done;c=b.next())c.value.a.a=null;a.b.length=0}
function R(a,b){var c=H(O(a,b)),e=B.includes(c),f=C.includes(c);if(!e&&!f)return c;var d=S(a,b);if(e&&d.a&&d.b&&!d.f&&!d.c)return"-";if(e&&!d.a&&!d.b&&d.f&&d.c)return"|";if(4===K(d))return"-";if(f&&3===K(d)){if(!d.a)return"<";if(!d.f)return"^";if(!d.c)return"v";if(!d.b)return">"}if((e||f)&&3===K(d)){d.h=I(O(a,v(z(b))));d.u=I(O(a,v(A(b))));d.g=I(O(a,x(z(b))));d.i=I(O(a,x(A(b))));if(!d.b&&d.h&&d.g||!d.a&&d.u&&d.i)return"|";if(!d.c&&d.h&&d.u||!d.f&&d.i&&d.g)return"-";c=J(O(a,v(z(b))));e=J(O(a,v(A(b))));
if(d.f&&d.a&&d.b&&(!c||!e))return"-";c=J(O(a,x(z(b))));a=J(O(a,x(A(b))));return!(d.c&&d.a&&d.b)||c&&a?"+":"-"}if(f&&1===K(d)){if(d.a)return">";if(d.f)return"v";if(d.c)return"^";if(d.b)return"<"}return c}function S(a,b){var c=I(O(a,z(b))),e=I(O(a,A(b))),f=I(O(a,v(b)));a=I(O(a,x(b)));return new fa(c,e,f,a)}
function t(a,b){return null!==b&&void 0!==b&&a.x===b.x&&a.y===b.y}function u(a,b){return new q(a.x-b.x,a.y-b.y)}q.prototype.add=function(a){return new q(this.x+a.x,this.y+a.y)};q.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};q.prototype.scale=function(a){return new q(this.x*a,this.y*a)};function v(a){return new q(a.x,a.y-1)}function x(a){return new q(a.x,a.y+1)}function z(a){return new q(a.x-1,a.y)}function A(a){return new q(a.x+1,a.y)};var B=["+","\u2012","\u2013","-","|"],C=[">","<","^","v"],da=B.concat(C),D=[new q(-1,0),new q(1,0),new q(0,-1),new q(0,1)];function E(a,b){this.a=Math.min(a.x,b.x);this.b=Math.min(a.y,b.y);this.c=Math.max(a.x,b.x);this.f=Math.max(a.y,b.y)}function F(a){return new q(a.a,a.b)}function G(a,b){return b.x>=a.a&&b.x<=a.c&&b.y>=a.b&&b.y<=a.f}function ea(){this.a=this.value=null}function H(a){return null===a.a?a.value:a.a}function I(a){return da.includes(H(a))}function J(a){return null===a.value&&null===a.a}function fa(a,b,c,e){this.a=a;this.c=b;this.f=c;this.b=e;this.i=this.g=this.u=this.h=!1}
function K(a){return a.a+a.c+a.f+a.b}function L(a,b){this.position=a;this.value=b}function ha(a,b){this.position=a;this.a=b};function ia(a){for(var b=0;b<a.a.length;b++)for(var c=0;c<a.a[b].length;c++)null!==H(a.a[b][c])&&M(a,new q(b,c),"\u2009");N(a)}function O(a,b){a=a.a[b.x][b.y];if(void 0===a||null===a)throw Error("Cell not found");return a}function M(a,b,c){var e=O(a,b);a.b.push(new ha(b,e));e.a=c;a.c=!0}function P(a,b,c){H(O(a,b))!==c&&M(a,b,c)}function Q(a){for(var b=k(a.b),c=b.next();!c.done;c=b.next())c.value.a.a=null;a.b.length=0}
function R(a,b){var c=H(O(a,b)),e=B.includes(c),f=C.includes(c);if(!e&&!f)return c;var d=S(a,b);if(e&&d.a&&d.c&&!d.f&&!d.b)return"-";if(e&&!d.a&&!d.c&&d.f&&d.b)return"|";if(4===K(d))return"-";if(f&&3===K(d)){if(!d.a)return"<";if(!d.f)return"^";if(!d.b)return"v";if(!d.c)return">"}if((e||f)&&3===K(d)){d.h=I(O(a,v(z(b))));d.u=I(O(a,v(A(b))));d.g=I(O(a,x(z(b))));d.i=I(O(a,x(A(b))));if(!d.c&&d.h&&d.g||!d.a&&d.u&&d.i)return"|";if(!d.b&&d.h&&d.u||!d.f&&d.i&&d.g)return"-";c=J(O(a,v(z(b))));e=J(O(a,v(A(b))));
if(d.f&&d.a&&d.c&&(!c||!e))return"-";c=J(O(a,x(z(b))));a=J(O(a,x(A(b))));return!(d.b&&d.a&&d.c)||c&&a?"+":"-"}if(f&&1===K(d)){if(d.a)return">";if(d.f)return"v";if(d.b)return"^";if(d.c)return"<"}return c}function S(a,b){var c=I(O(a,z(b))),e=I(O(a,A(b))),f=I(O(a,v(b)));a=I(O(a,x(b)));return new fa(c,e,f,a)}
function N(a,b){var c=[],e=a.b.map(function(a){return a.position.x.toString()+a.position.y.toString()}),f=a.b.filter(function(a,b){return e.indexOf(e[b])===b});a.b.length=0;f=k(f);for(var d=f.next();!d.done;d=f.next()){var h=d.value;d=h.position;h=h.a;c.push(new L(d,null===h.value?" ":h.value));var l=H(h);if("\u2009"===l||" "===l)l=null;I(h)&&(l=R(a,d));h.a=null;h.value=l}b=b?a.f:a.g;0<c.length&&(50<b.length&&b.shift(),b.push(c));a.c=!0}
function ja(a){if(0!==a.g.length){var b=a.g.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,M(a,c.position,c.value);N(a,!0)}}function ka(a){if(0!==a.f.length){var b=a.f.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,M(a,c.position,c.value);N(a)}};function T(a,b,c,e,f){f=void 0===f?"+":f;var d=new E(b,c),h=d.c,l=d.f,n=e?c.x:b.x;e=e?b.y:c.y;for(var w=d.a;w<h;w++){var p=new q(w,e),y=S(a,new q(w,e));" "===f&&2===y.f+y.c||P(a,p,f)}for(d=d.b;d<l;d++)h=new q(n,d),w=S(a,new q(n,d))," "===f&&2===w.a+w.b||P(a,h,f);M(a,b,f);M(a,c,f);P(a,new q(n,e),f)};function U(a){this.a=a;this.b=null}g=U.prototype;g.start=function(a){this.b=a};g.j=function(a){Q(this.a);T(this.a,this.b,a,!0);T(this.a,this.b,a,!1)};g.m=function(){N(this.a)};g.o=function(){return"crosshair"};g.l=function(){};function V(a){this.c=a;this.a=this.b=null}g=V.prototype;g.start=function(a){this.b=a;this.j(a)};g.j=function(a){Q(this.c);this.a=a;a=Math.min(this.b.y,this.a.y);for(var b=Math.max(this.b.x,this.a.x),c=Math.max(this.b.y,this.a.y),e=Math.min(this.b.x,this.a.x);e<=b;e++)for(var f=a;f<=c;f++)M(this.c,new q(e,f),"\u2009")};g.m=function(){N(this.c)};g.o=function(){return"crosshair"};g.l=function(){};function la(a){this.a=a;this.value="X";document.getElementById("freeform-tool-input").value="";document.getElementById("freeform-tool-input").style.display="none";setTimeout(function(){document.getElementById("freeform-tool-input").style.display="block";setTimeout(function(){document.getElementById("freeform-tool-input").focus()},0)},0)}g=la.prototype;g.start=function(a){M(this.a,a,this.value)};g.j=function(a){M(this.a,a,this.value)};g.m=function(){N(this.a)};g.o=function(){return"crosshair"};
g.l=function(a){this.value=document.getElementById("freeform-tool-input").value.charAt(0);document.getElementById("freeform-tool-input").blur();document.getElementById("freeform-tool-input").style.display="none";1===a.length&&(this.value=a)};function W(a,b){this.a=a;this.c=b;this.b=null}g=W.prototype;g.start=function(a){this.b=a};g.j=function(a){Q(this.a);var b=S(this.a,this.b),c=S(this.a,a);T(this.a,this.b,a,b.f&&b.c||c.a&&c.b);this.c&&M(this.a,a,"^")};g.m=function(){N(this.a)};g.o=function(){return"crosshair"};g.l=function(){};function ma(a){this.a=a;this.b=null;this.c=[]}g=ma.prototype;
function ja(a){if(0!==a.g.length){var b=a.g.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,M(a,c.position,c.value);N(a,!0)}}function ka(a){if(0!==a.f.length){var b=a.f.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,M(a,c.position,c.value);N(a)}};function T(a,b,c,e,f){f=void 0===f?"+":f;var d=new E(b,c),h=d.c,l=d.f,n=e?c.x:b.x;e=e?b.y:c.y;for(var w=d.a;w<h;w++){var p=new q(w,e),y=S(a,new q(w,e));" "===f&&2===y.f+y.b||P(a,p,f)}for(d=d.b;d<l;d++)h=new q(n,d),w=S(a,new q(n,d))," "===f&&2===w.a+w.c||P(a,h,f);M(a,b,f);M(a,c,f);P(a,new q(n,e),f)};function U(a){this.a=a;this.b=null}g=U.prototype;g.start=function(a){this.b=a};g.j=function(a){Q(this.a);T(this.a,this.b,a,!0);T(this.a,this.b,a,!1)};g.m=function(){N(this.a)};g.o=function(){return"crosshair"};g.l=function(){};function V(a){this.c=a;this.a=this.b=null}g=V.prototype;g.start=function(a){this.b=a;this.j(a)};g.j=function(a){Q(this.c);this.a=a;a=Math.min(this.b.y,this.a.y);for(var b=Math.max(this.b.x,this.a.x),c=Math.max(this.b.y,this.a.y),e=Math.min(this.b.x,this.a.x);e<=b;e++)for(var f=a;f<=c;f++)M(this.c,new q(e,f),"\u2009")};g.m=function(){N(this.c)};g.o=function(){return"crosshair"};g.l=function(){};function la(a){this.a=a;this.value="X";document.getElementById("freeform-tool-input").value="";document.getElementById("freeform-tool-input").style.display="none";setTimeout(function(){document.getElementById("freeform-tool-input").style.display="block";setTimeout(function(){document.getElementById("freeform-tool-input").focus()},0)},0)}g=la.prototype;g.start=function(a){M(this.a,a,this.value)};g.j=function(a){M(this.a,a,this.value)};g.m=function(){N(this.a)};g.o=function(){return"crosshair"};
g.l=function(a){this.value=document.getElementById("freeform-tool-input").value.charAt(0);document.getElementById("freeform-tool-input").blur();document.getElementById("freeform-tool-input").style.display="none";1===a.length&&(this.value=a)};function W(a,b){this.a=a;this.c=b;this.b=null}g=W.prototype;g.start=function(a){this.b=a};g.j=function(a){Q(this.a);var b=S(this.a,this.b),c=S(this.a,a);T(this.a,this.b,a,b.f&&b.b||c.a&&c.c);this.c&&M(this.a,a,c.f?"^":c.b?"v":c.a?"<":">")};g.m=function(){N(this.a)};g.o=function(){return"crosshair"};g.l=function(){};function ma(a){this.a=a;this.b=null;this.c=[]}g=ma.prototype;
g.start=function(a){this.b=a;this.c=[];if(I(O(this.a,this.b))){for(var b=[],c=k(D),e=c.next();!e.done;e=c.next()){e=e.value;var f=na(this,this.b,e);f=k(f);for(var d=f.next();!d.done;d=f.next()){d=d.value;var h=0!==e.x,l=-1!==C.indexOf(H(O(this.a,a))),n=-1!==C.indexOf(H(O(this.a,d)));if(1===K(S(this.a,d)))b.push({position:d,s:h,w:l,v:n});else for(var w=k(D),p=w.next();!p.done;p=w.next())if(p=p.value,0!==e.add(p).length()&&2!==e.add(p).length()&&(p=na(this,d,p),0!==p.length)){p=k(p).next().value;var y=
-1!==C.indexOf(H(O(this.a,p)));b.push({position:p,s:h,w:l,A:n,v:y})}}}this.c=b;this.j(this.b)}};g.j=function(a){Q(this.a);for(var b=k(this.c),c=b.next();!c.done;c=b.next())c=c.value,T(this.a,this.b,c.position,c.s," ");b=k(this.c);for(c=b.next();!c.done;c=b.next())c=c.value,T(this.a,a,c.position,c.s);b=k(this.c);for(c=b.next();!c.done;c=b.next())c=c.value,c.w&&M(this.a,a,"^"),c.v&&M(this.a,c.position,"^"),c.A&&M(this.a,new q(c.s?c.position.x:a.x,c.s?a.y:c.position.y),"^")};g.m=function(){N(this.a)};
function na(a,b,c){for(var e=new q(b.x,b.y),f=[];;){var d=e.add(c);if(!I(O(a.a,d)))return t(b,e)||f.push(e),f;e=d;3===K(S(a.a,e))&&f.push(e)}}g.o=function(a){return I(O(this.a,a))?"pointer":"default"};g.l=function(){};function oa(a){this.c=a;this.g=this.f=this.b=this.a=null;this.h=!0;this.i=[]}g=oa.prototype;g.start=function(a){null!==this.a&&null!==this.b&&G(new E(this.a,this.b),a)?(this.f=a,pa(this,this.a,this.b),qa(this,a,this.f)):(this.a=a,this.b=null,this.h=!1,this.j(a))};function pa(a,b,c){var e=a.c.b.filter(function(a){a=H(a.a);return null!==a&&"\u2009"!==a}),f=F(new E(b,c));a.i=e.map(function(a){return new L(u(a.position,f),H(a.a))})}


+ 2
- 2
js-compiled.js.map
File diff suppressed because it is too large
View File


+ 14
- 2
js-lib/draw/line.js View File

@ -1,6 +1,6 @@
import {DrawFunction} from "./function.js";
import {drawLine} from "./utils.js";
import {ALT_SPECIAL_VALUE} from "../constants.js";
import {SPECIAL_ARROW_LEFT, SPECIAL_ARROW_UP, SPECIAL_ARROW_RIGHT, SPECIAL_ARROW_DOWN} from "../constants.js";
import {State} from "../state.js";
import {Vector} from "../vector.js";
@ -36,7 +36,19 @@ export class DrawLine {
drawLine(this.state, this.startPosition, position, clockwise);
if (this.isArrow) {
this.state.drawValue(position, ALT_SPECIAL_VALUE);
let endValue;
if (endContext.up) {
endValue = SPECIAL_ARROW_UP;
} else if (endContext.down) {
endValue = SPECIAL_ARROW_DOWN;
} else if (endContext.left) {
endValue = SPECIAL_ARROW_LEFT;
} else {
endValue = SPECIAL_ARROW_RIGHT;
}
this.state.drawValue(position, endValue);
}
}


Loading…
Cancel
Save