-
Notifications
You must be signed in to change notification settings - Fork 1
/
bct-bundle.js
19 lines (13 loc) · 6.96 KB
/
bct-bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";var _huemanities=require("huemanities"),bct=new _huemanities.BasicColorTerminal;
},{"huemanities":6}],2:[function(require,module,exports){
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),Artifier=function(){function e(){_classCallCheck(this,e),this.artifyImageOnload()}return _createClass(e,[{key:"artifyImageOnload",value:function(){var e=this;document.addEventListener("DOMContentLoaded",function(){var t=document.querySelector(".Canvas"),n=t.getContext("2d");document.querySelector(".Uploader").addEventListener("change",function(a){var r=new Image,i=new FileReader;i.onload=function(e){r.src=e.target.result},i.readAsDataURL(a.target.files[0]),r.onload=function(){t.height=r.height,t.width=r.width,n.drawImage(r,0,0);var a=new ImageData(e.artFunction(n,t.width,t.height),r.width);n.putImageData(a,0,0)}})})}},{key:"artFunction",value:function(){}},{key:"getPixelAt",value:function(e,t,n,a){var r=4*e*n+4*t;return[a[r],a[r+1],a[r+2],a[r+3]]}},{key:"appendArray",value:function(e,t){for(var n=0;n<t.length;n++)e.push(t[n])}}]),e}();exports.default=Artifier;
},{}],3:[function(require,module,exports){
"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),_constants=require("./constants.js"),_Artifier2=require("./Artifier.js"),_Artifier3=_interopRequireDefault(_Artifier2),BasicColorTerminal=function(t){function e(){_classCallCheck(this,e);var t=_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return t.colors=[_constants.RED,_constants.ORANGE,_constants.YELLOW,_constants.GREEN,_constants.BLUE,_constants.PURPLE,_constants.PINK,_constants.WHITE,_constants.BLACK,_constants.GRAY,_constants.BROWN],t}return _inherits(e,t),_createClass(e,[{key:"artFunction",value:function(t,e,r){for(var n=t.getImageData(0,0,e,r).data,o=this.colors,s=[],a=0;a<r;a++)for(var i=0;i<e;i++){for(var c=this.getPixelAt(a,i,e,n),u=void 0,l=1e9,f=0;f<o.length;f++){var _=o[f],p=_[0]-c[0],b=_[1]-c[1],h=_[2]-c[2],y=p*p+b*b+h*h;y<l&&(l=y,u=_)}this.appendArray(s,u)}return new Uint8ClampedArray(s)}}]),e}(_Artifier3.default);exports.default=BasicColorTerminal;
},{"./Artifier.js":2,"./constants.js":5}],4:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_Artifier2=require("./Artifier.js"),_Artifier3=_interopRequireDefault(_Artifier2),GlitchRothko=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this))}return _inherits(t,e),_createClass(t,[{key:"artFunction",value:function(e,t,r){for(var n=e.getImageData(0,0,t,r).data,i=[],a=[],o=[],u=[],s=0;s<r;s++)for(var l=0;l<t;l++){var c=this.getPixelAt(s,l,t,n),f=this.getHighestOfThree(c);"red"===f&&this.appendArray(i,c),"green"===f&&this.appendArray(a,c),"blue"===f&&this.appendArray(o,c),"grayscale"===f&&this.appendArray(u,c)}var p=[];return this.appendArray(p,i),this.appendArray(p,a),this.appendArray(p,o),this.appendArray(p,u),new Uint8ClampedArray(p)}},{key:"getHighestOfThree",value:function(e){var t=void 0,r=void 0;return e[0]===e[1]&&e[0]===e[2]?"grayscale":(e[0]>e[1]?(t="red",r=0):(t="green",r=1),e[2]>e[r]&&(t="blue"),t)}}]),t}(_Artifier3.default);exports.default=GlitchRothko;
},{"./Artifier.js":2}],5:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RED=exports.RED=[255,0,0,255],ORANGE=exports.ORANGE=[255,165,0,255],YELLOW=exports.YELLOW=[255,255,0,255],GREEN=exports.GREEN=[0,128,0,255],BLUE=exports.BLUE=[0,0,255,255],PURPLE=exports.PURPLE=[128,0,128,255],PINK=exports.PINK=[255,192,203,255],WHITE=exports.WHITE=[0,0,0,255],BLACK=exports.BLACK=[255,255,255,255],GRAY=exports.GRAY=[128,128,128,255],BROWN=exports.BROWN=[128,42,42,255];
},{}],6:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.BasicColorTerminal=exports.GlitchRothko=void 0;var _GlitchRothko=require("./GlitchRothko"),_GlitchRothko2=_interopRequireDefault(_GlitchRothko),_BasicColorTerminal=require("./BasicColorTerminal"),_BasicColorTerminal2=_interopRequireDefault(_BasicColorTerminal);exports.GlitchRothko=_GlitchRothko2.default,exports.BasicColorTerminal=_BasicColorTerminal2.default;
},{"./BasicColorTerminal":3,"./GlitchRothko":4}]},{},[1]);