![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-acomp/js/DataOverRGBTx.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ACore = require("../ACore"); var _Color = _interopRequireDefault(require("absol/src/Color/Color")); /** * @augments {HTMLCanvasElement} * @augments {AElement} * @constructor */ function DataOverRGBTx() { this.ctx = this.getContext('2d'); this.commands = []; this._state = 'none'; this.runCommand = this.runCommand.bind(this); } DataOverRGBTx.tag = 'DataOverRGBTx'.toLowerCase(); DataOverRGBTx.render = function () { return (0, _ACore._)({ tag: 'canvas', class: 'as-data-over-rgb-tx', attr: { width: 300, height: 300 } }); }; DataOverRGBTx.prototype.begin = function () { this.viewColor('rgb(255, 0, 0)', 2); this.viewColor('rgb(255, 255, 0)', 8); this.viewColor('rgb(255, 0, 0)', 2); }; DataOverRGBTx.prototype.sendBit = function (bit) { if (bit) { this.viewColor('rgb(0, 255, 255)', 2); } else { this.viewColor('rgb(255, 255, 0)', 2); } this.viewColor('rgb(255, 0, 0)', 2); }; DataOverRGBTx.prototype.sendByte = function (byte) { for (var i = 0; i < 8; ++i) { this.sendBit(byte & 1); byte >>= 1; } }; DataOverRGBTx.prototype.sendString = function (text) { for (var i = 0; i < text.length; ++i) { this.sendByte(text.charCodeAt(i)); } this.sendByte(0); return this; }; DataOverRGBTx.prototype.then = function (cb) { this.pushCmd({ type: 'cb', cb }); return this; }; DataOverRGBTx.prototype.viewColor = function (color, frame) { frame = frame || 1; frame *= 5; this.pushCmd({ type: 'color', value: color }); for (var i = 1; i < frame; ++i) { this.pushCmd({ type: 'noop' }); } }; DataOverRGBTx.prototype.pushCmd = function (cmd) { this.commands.push(cmd); this.trigger(); return this; }; DataOverRGBTx.prototype.runCommand = function () { if (this.commands.length === 0) { this._state = 'none'; return; } var cmd = this.commands.shift(); if (cmd.type === 'color') { this.ctx.fillStyle = cmd.value; this.ctx.fillRect(0, 0, this.width, this.height); } else if (cmd.type === 'cb') { //noop cmd.cb(); } else {//noop } if (this.commands.length > 0) { requestAnimationFrame(this.runCommand); } else { this._state = 'none'; } }; DataOverRGBTx.prototype.trigger = function () { if (this._state === 'none') { this._state = 'running'; requestAnimationFrame(this.runCommand); } }; var _default = DataOverRGBTx; exports.default = _default;