2020-05-22 17:58:13 +02:00
|
|
|
(function(){var e,i,n;e=class{constructor(t){this.target=t,this.el=$("<canvas>").attr("class","viewer")[0],this.offset=10,this.points=[],this.preprocess(),this.getBound(),this.prepare(),this.render()}canvasPoint(e){return new t.Point(e[0]/this.target.resolution+this.base.x,-e[1]/this.target.resolution+this.base.y)}preprocess(){return this.points=this.target.data}getBound(){var t,e,i,n,r,s,a,o;for(n={x:0,y:0},i={x:0,y:0},t=0,e=(r=this.points).length;t<e;t++)a=(s=r[t])[0]/this.target.resolution,o=s[1]/this.target.resolution,a<n.x&&(n.x=a),o<n.y&&(n.y=o),a>i.x&&(i.x=a),o>i.y&&(i.y=o);return this.bound=[n,i],this.base={x:0-this.bound[0].x+this.offset,y:this.bound[1].y+this.offset},this.width=i.x-n.x+2*this.offset,this.height=i.y-n.y+2*this.offset}drawPoint(e,i,n){return new t.Path.Circle({center:this.canvasPoint(e),radius:n,fillColor:i})}drawGrid(e,i){var n,r,s,a,o,h;for(h=this.target.resolution*e,r=Math.ceil(this.bound[0].x/e);r*e<this.bound[1].x;)a=new t.Point(r*e+this.base.x,-this.bound[0].y+this.base.y),n=new t.Point(r*e+this.base.x,-this.bound[1].y+this.base.y),(s=new t.Path).strokeColor=i,s.moveTo(a),s.lineTo(n),r++;for(r=Math.ceil(this.bound[0].y/e);r*e<this.bound[1].y;)a=new t.Point(this.bound[0].x+this.base.x,-r*e+this.base.y),n=new t.Point(this.bound[1].x+this.base.x,-r*e+this.base.y),(s=new t.Path).strokeColor=i,s.moveTo(a),s.lineTo(n),r++;return(o=new t.PointText(this.bound[0].x+this.base.x,this.base.y-this.bound[1].y+this.offset)).justification="left",o.fillColor="#494949",o.content=`Resolution: ${this.target.resolution}, grid size: ${h} mm`}drawAxis(e){var i,n,r;return(n=new t.Path).strokeColor=e,r=new t.Point(this.bound[0].x+this.base.x,this.base.y),i=new t.Point(this.bound[1].x+this.base.x,this.base.y),n.moveTo(r),n.lineTo(i),(n=new t.Path).strokeColor=e,r=new t.Point(this.base.x,-this.bound[0].y+this.base.y),i=new t.Point(this.base.x,-this.bound[1].y+this.base.y),n.moveTo(r),n.lineTo(i),this.drawPoint([0,0],e,3)}prepare(){var e;return(e=this.el.getContext("2d")).translate(this.base.x,this.base.y),e.canvas.width=this.width,e.canvas.height=this.height,t.setup(this.el)}render(){}},n=class extends e{constructor(t){super(t)}p2c(t,e){var i;return i=e*Math.PI/180,[t*Math.cos(i),t*Math.sin(i)]}preprocess(){var t,e,i,n,r,s;if("polar"!==this.target.coordinate)return this.points=this.target.data;for(this.point=[],t=0,r=[],e=0,i=(n=this.target.data).length;e<i;e++)s=n[e],this.points.push(this.p2c(s,this.target.start+t*this.target.angularResolution)),r.push(t+=1);return r}render(){var e,i,n,r,s,a,o;for(this.drawGrid(20,"#DBDBDB"),this.drawAxis("#0A84FF"),i=0,n=(s=this.points).length;i<n;i++)o=s[i],"polar"===this.target.coordinate&&((r=new t.Path).strokeColor="#c2a10e",a=this.canvasPoint([0,0]),e=this.canvasPoint(o),r.moveTo(a),r.lineTo(e)),this.drawPoint(o,"red",3);return t.view.draw()}},(i=class extends this.OS.GUI.BaseApplication{constructor(t){super("LuaPlayground",t)}main(){return this.datarea=this.find("editorea"),this.output=this.find("output"),ace.config.set("basePath","/scripts/ace"),this.editor=ace.edit(this.datarea),this.editor.setOptions({enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,highlightActiveLine:!0,highlightSelectedWord:!0,behavioursEnabled:!0,wrap:!0,fontSize:"11pt",showInvisibles:!0}),this.editor.getSession().setUseWrapMode(!0),this.editor.session.setMode("ace/mode/lua"),this.editor.setTheme("ace/theme/monokai"),this.on("vboxchange",()=>this.editor.resize()),this.find("log-clear").set("onbtclick",t=>this.log("clean")),this.find("code-run").set("onbtclick",t=>this.run()),this.find("code-stop").set("onbtclick",t=>{if(this.socket)return this.socket.close()}),this.socket=null,this.bindKey("CTRL-R",()=>this.run())}menu(){return[{text:"__(Code)",child:[{text:"__(Run)",dataid:this.name+"-Run",shortcut:"C-R"}],onchildselect:t=>this.run()}]}log(t,e){var i;return"clean"===t?$(this.output).empty():(i=$("<p>").attr("class",t.toLowerCase())[0],$(i).html(`${t}: ${e.__()}`),$(this.output).append(i),$(this.output).scrollTop(this.output.scrollHeight))}run(){var t;if((t=this.editor.getValue().trim())&&""!=
|
2019-05-06 16:08:46 +02:00
|
|
|
/*!
|
|
|
|
* Paper.js v0.12.0 - The Swiss Army Knife of Vector Graphics Scripting.
|
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://scratchdisk.com/ & https://puckey.studio/
|
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Date: Mon Dec 3 14:19:11 2018 +0100
|
|
|
|
*
|
|
|
|
***
|
|
|
|
*
|
|
|
|
* Straps.js - Class inheritance library with support for bean-style accessors
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 - 2016 Juerg Lehni
|
|
|
|
* http://scratchdisk.com/
|
|
|
|
*
|
|
|
|
* Distributed under the MIT license.
|
|
|
|
*
|
|
|
|
***
|
|
|
|
*
|
|
|
|
* Acorn.js
|
|
|
|
* https://marijnhaverbeke.nl/acorn/
|
|
|
|
*
|
|
|
|
* Acorn is a tiny, fast JavaScript parser written in JavaScript,
|
|
|
|
* created by Marijn Haverbeke and released under an MIT license.
|
|
|
|
*
|
|
|
|
*/
|
2020-05-22 17:58:13 +02:00
|
|
|
var t=function(t,e){var i=(t=t||require("./node/self.js")).window,n=t.document,r=new function(){function t(t,e,r,s,a){function u(n,u){"string"==typeof(u=u||(u=o(e,n))&&(u.get?u:u.value))&&"#"===u[0]&&(u=t[u.substring(1)]||u);var c,f="function"==typeof u,d=u,_=a||f&&!u.base?u&&u.get?n in t:t[n]:null;a&&_||(f&&_&&(u.base=_),f&&!1!==s&&(c=n.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(l[c[3].toLowerCase()+c[4]]=c[2]),d&&!f&&d.get&&"function"==typeof d.get&&i.isPlainObject(d)||(d={value:d,writable:!0}),(o(t,n)||{configurable:!0}).configurable&&(d.configurable=!0,d.enumerable=null!=r?r:!c),h(t,n,d))}var l={};if(e){for(var c in e)e.hasOwnProperty(c)&&!n.test(c)&&u(c);for(var c in l){var f=l[c],d=t["set"+f],_=t["get"+f]||d&&t["is"+f];!_||!0!==s&&0!==_.length||u(c,{get:_,set:d})}}return t}function i(){for(var t=0,e=arguments.length;t<e;t++){var i=arguments[t];i&&c(this,i)}return this}var n=/^(statics|enumerable|beans|preserve)$/,r=[],s=r.slice,a=Object.create,o=Object.getOwnPropertyDescriptor,h=Object.defineProperty,u=r.forEach||function(t,e){for(var i=0,n=this.length;i<n;i++)t.call(e,this[i],i,this)},l=function(t,e){for(var i in this)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)},c=Object.assign||function(t){for(var e=1,i=arguments.length;e<i;e++){var n=arguments[e];for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])}return t},f=function(t,e,i){if(t){var n=o(t,"length");(n&&"number"==typeof n.value?u:l).call(t,e,i=i||t)}return i};return t(i,{inject:function(e){if(e){var i=!0===e.statics?e:e.statics,n=e.beans,r=e.preserve;i!==e&&t(this.prototype,e,e.enumerable,n,r),t(this,i,null,n,r)}for(var s=1,a=arguments.length;s<a;s++)this.inject(arguments[s]);return this},extend:function(){for(var e,i,n,r=this,s=0,o=arguments.length;s<o&&(!e||!i);s++)n=arguments[s],e=e||n.initialize,i=i||n.prototype;return i=(e=e||function(){r.apply(this,arguments)}).prototype=i||a(this.prototype),h(i,"constructor",{value:e,writable:!0,configurable:!0}),t(e,this),arguments.length&&this.inject.apply(e,arguments),e.base=r,e}}).inject({enumerable:!1,initialize:i,set:i,inject:function(){for(var e=0,i=arguments.length;e<i;e++){var n=arguments[e];n&&t(this,n,n.enumerable,n.beans,n.preserve)}return this},extend:function(){var t=a(this);return t.inject.apply(t,arguments)},each:function(t,e){return f(this,t,e)},clone:function(){return new this.constructor(this)},statics:{set:c,each:f,create:a,define:h,describe:o,clone:function(t){return c(new t.constructor,t)},isPlainObject:function(t){var e=null!=t&&t.constructor;return e&&(e===Object||e===i||"Object"===e.name)},pick:function(t,i){return t!==e?t:i},slice:function(t,e,i){return s.call(t,e,i)}}})};"undefined"!=typeof module&&(module.exports=r),r.inject({enumerable:!1,toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+r.each(this,(function(t,e){if(!/^_/.test(e)){var i=typeof t;this.push(e+": "+("number"===i?h.instance.number(t):"string"===i?"'"+t+"'":t))}}),[]).join(", ")+" }"},getClassName:function(){return this._class||""},importJSON:function(t){return r.importJSON(t,this)},exportJSON:function(t){return r.exportJSON(this,t)},toJSON:function(){return r.serialize(this)},set:function(t,e){return t&&r.filter(this,t,e,this._prioritize),this}},{beans:!1,statics:{exports:{},extend:function t(){var e=t.base.apply(this,arguments),i=e.prototype._class;return i&&!r.exports[i]&&(r.exports[i]=e),e},equals:function(t,e){if(t===e)return!0;if(t&&t.equals)return t.equals(e);if(e&&e.equals)return e.equals(t);if(t&&e&&"object"==typeof t&&"object"==typeof e){if(Array.isArray(t)&&Array.isArray(e)){if((i=t.length)!==e.length)return!1;for(;i--;)if(!r.equals(t[i],e[i]))return!1}else{var i,n=Object.keys(t);if((i=n.length)!==Object.keys(e).length)return!1;for(;i--;){var s=n[i];if(!e.hasOwnProperty(s)||!r.equals(t[s],e[s]))return!1}}return!0}return!1},read:function(t,i,n,s){if(this===r){var a=this.peek(t,i);return t.__index++,a}var o=this.prototype,h=o._readIndex,u=i||h&&t.__index||0,l=t.length,c=t[u];if(s=s||l-u,c instanceof this||n&&n.readNull&&null==c&&s<=1)return h&&(t.__index=u
|