Last active
January 2, 2016 16:39
-
-
Save zarazum/8331920 to your computer and use it in GitHub Desktop.
aekoanvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
// THIS IS THE SECTION WHERE PROCODING INJECTS THE CANVAS SCRIPT | |
// | |
// | |
// AEKOANVAS — Tripno game playground sketch | |
// Using Procoding.js, a lightweight Canvas Library | |
// (c) 2013 Michael Markert for Procoding | |
var ctx = canvas.getContext("2d"); | |
var waitDraw = 100; | |
var waitBlank = 100; | |
var frameCount = 0; | |
var bg = 'rgba(0, 0, 0, 0.5)'; | |
var circleFill = 'rgba(0,0,0, 0.75)'; | |
var fg = 'rgba(71, 71, 71, 0.50)'; | |
var bbg = 'rgba(127, 127, 127, 0.80)'; | |
//console.log(bg,fg,bbg); | |
var linesCount = 101; | |
var circlesCount = 101; | |
var lines = []; | |
var circles = []; | |
function rnd(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
// drawing routines | |
function drawCircles(count) { | |
var zr, zx, zy, i; | |
// ctx.fillStyle = circleFill; | |
// ctx.strokeStyle = 'none'; | |
// ctx.lineWidth = 0; | |
for (i = 0; i < count; i++) { | |
zr = rnd(width / 200, width / 50); | |
zx = rnd(zr, width - 2 * zr); | |
zy = rnd(zr, height - 2 * zr); | |
// zr = rnd(width / 50) + width / 200; | |
// zx = zr + rnd(width - 2 * zr); | |
// zy = zr + rnd(height - 2 * zr); | |
ctx.circle(zx, zy, zr); | |
} | |
} | |
function drawLines(count) { | |
var fx, fy, tx, ty, i, c; | |
var h, s, l, alpha; | |
ctx.strokeStyle = fg; | |
//console.log(c); | |
ctx.lineWidth = 1; | |
for (i = 0; i < count; i++) { | |
fx = Math.floor((width) * Math.random()); | |
fy = Math.floor((height) * Math.random()); | |
tx = width; | |
ty = Math.floor((height) * Math.random()); | |
ctx.line(fx, fy, tx, ty); | |
} | |
} | |
function blank() { | |
ctx.fillStyle = bbg; | |
ctx.fillRect(0, 0, width, height); | |
} | |
// init | |
function init() { | |
var fx, fy, tx, ty, color, i; | |
var zx,zy,zr; | |
// setup events | |
// window.addEventListener('keydown', keyDown, | |
// setup drawing routine | |
setInterval(function(){ | |
drawLines(501); | |
ctx.fillStyle = circleFill; | |
ctx.strokeStyle = 'none'; | |
ctx.lineWidth = 0; | |
for (i = 0; i < 200; i++) { | |
zr = rnd(width / 200, width / 50); | |
zx = rnd(-zr, width); | |
zy = rnd(-zr, height); | |
// zr = rnd(width / 50) + width / 200; | |
// zx = zr + rnd(width - 2 * zr); | |
// zy = zr + rnd(height - 2 * zr); | |
ctx.fillRect(zx, zy, zr,zr); | |
} | |
// drawCircles(1000); | |
//blank(); | |
}, waitDraw); | |
//setInterval(drawLines, waitDraw); | |
// setInterval(blank, waitBlank); | |
} | |
// call init once | |
init(); | |
// | |
// | |
// THIS WAS THE SECTION WHERE PROCODING INJECTED THE CANVAS SCRIPT | |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
} catch (e) { | |
_procoding_throwError(e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.tinylog-container { | |
z-index: 10000; | |
position: fixed; | |
bottom: 0; | |
width: 100%; | |
height: 30%; | |
font-family: sans-serif; | |
color: red; | |
background-color: rgba(0, 0, 0, 0.9); | |
} | |
.tinylog-output { | |
position: relative; | |
font-family: monospace; | |
overflow: auto; | |
height: 100%; | |
font-weight: bold; | |
} | |
.tinylog-entry { | |
min-height: 16px; | |
} | |
.tinylog-entry-text { | |
white-space: pre-wrap; | |
font-size: 12px; | |
margin: 1px 5px 0 5px; | |
max-width: 100%; | |
overflow: auto; | |
} | |
.tinylog-resizer { | |
height: 5px; | |
margin-top: -5px; | |
cursor: n-resize; | |
background-color: darkgrey; | |
} | |
.tinylog-buttons-container { | |
position: absolute; | |
opacity: .35; | |
top: 2px; | |
right: 18px; | |
} | |
.tinylog-buttons-container:hover { | |
opacity: 1; | |
} | |
.tinylog-button { | |
cursor: pointer; | |
display: inline-block; | |
color: white; | |
border: 1px solid #ccc; | |
background-color: #ccc; | |
text-align: center; | |
padding: 6px; | |
padding-top: 2px; | |
-moz-border-radius: 4px; | |
border-radius: 4px; | |
font-size: 14px; | |
width: 12px; | |
height: 12px; | |
} | |
.tinylog-button:hover { | |
border: 1px solid #999; | |
background-color: #eee; | |
color: #222; | |
} | |
.tinylog-button:before { | |
content: attr(data-symbol); | |
} | |
.tinylog-button:not(:first-child) { | |
margin-left: 3px; | |
} | |
.tinylog-save-button { | |
visibility: hidden; | |
position: relative; | |
text-decoration: none; | |
} | |
.tinylog-save-button-image { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
border: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="creator" content="Procoding" /> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<meta name="viewport" id="viewport" content="width=device-width initial-scale=1 maximum-scale=1 user-scalable=no" /> | |
<title>aekoanvas.pro</title> <!-- displayName --> | |
<link rel="stylesheet" type="text/css" href="style.css" /> <!-- style.css --> | |
<link rel="stylesheet" type="text/css" href="./default.tinylog.css"/> <!-- libPath --> | |
<script type="text/javascript" src="Procoding.js"></script> <!-- Procoding.js --> | |
<script type="text/javascript">console.TINYLOG = true</script> | |
<script type="text/javascript" src="./tinylog.min.js" defer="defer"></script><!-- libPath --> | |
<script type="text/javascript" src="jsinit.js" defer="defer"></script> <!-- jsinit --> | |
<!--script type="text/javascript" src="canvas.js?version=410949750.109795" defer="defer"></script--> <!-- canvas script --> | |
</head> | |
<body> | |
<canvas id="canvas" resize></canvas> | |
<script type="text/javascript"> | |
setTimeout( function() { procoding.runStandalone(); }, 500 );</script> <!-- export script --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _procoding_throwError(e){if(procoding.error===0){procoding.error=e.message}else{procoding.error=procoding.error+": "+e.message}if(tinylog){tinylog.log(procoding.error);if(procoding.error){if(procoding.error.stack){tinylog.log(procoding.error.stack)}}}console.debug(procoding.error)}var canvas;var width,height;var procoding={};procoding.error=0;procoding.prefs={};procoding.intervals={};procoding.animationFrame=0;try{procoding.init=function(){if(tinylog.entries.length<0){tinylog.uninit()}canvas=document.querySelector("#canvas");procoding.canvas=canvas;procoding.prefs.ignoreRetina=false;procoding.prefs.pauseTimers=true;procoding.prefs.restartTimers=true;window.ontouchmove=function(e){e.preventDefault()};window.onscroll=function(e){e.preventDefault()}};procoding.runStandalone=function(){setTimeout(function(){procoding.init();procoding.initSize();window.addEventListener("resize",procoding.resize,false);setTimeout(procoding.run,500)},100)};procoding.run=function(){var t=document.createElement("script");t.src="canvas.js?version="+(new Date).getTime();t.onload=t.onreadystatechange=function(){};document.head.appendChild(t)};procoding.start=function(){if(procoding.animationFrame){window.requestAnimationFrame=procoding.animationFrame;procoding.animationFrame=0}if(procoding.prefs.restartTimers){location.reload()}};procoding.stop=function(){if(window.requestAnimationFrame){procoding.animationFrame=window.requestAnimationFrame;window.requestAnimationFrame=function(){return 0}}if(procoding.prefs.pauseTimers){var t;for(t=0;t<99999;t++){window.clearInterval(t)}}};procoding.forwardKeyEvent=function(t){procoding._forwardKeyEvent(t,0)};procoding._forwardKeyEvent=function(t,n){var r=t.length-1;if(t.length>=0){var i=document.createEvent("Events");i.initEvent("keydown",true,true);i.key=t.charCodeAt(r);i.keyCode=n;document.dispatchEvent(i)}};procoding.forwardKeyCodeEvent=function(t){var n=t;switch(t){case"LEFT":n=37;break;case"RIGHT":n=39;break;case"UP":n=38;break;case"DOWN":n=40;break;default:if(t.length){n=t.charCodeAt(0)}break}var r=document.createEvent("Events");r.initEvent("keydown",true,true);r.keyCode=n;document.dispatchEvent(r)};procoding._initSize=function(){procoding.initSize("portrait")};procoding.initSize=function(){var t=window.devicePixelRatio;if(procoding.prefs.ignoreRetina){t=1}var n=1/t;width=window.innerWidth*t;height=window.innerHeight*t;procoding.width=width;procoding.height=height;var r=document.querySelector("#viewport");r.setAttribute("content","width="+width+" initial-scale="+n+" maximum-scale="+n+" user-scalable=no");document.head.removeChild(r);document.head.appendChild(r);canvas.width=width;canvas.height=height};procoding.resize=function(t){var n=false;if(t==="landscape"){n=true}width=window.innerWidth;height=window.innerHeight;procoding.width=width;procoding.height=height;canvas.width=width;canvas.height=height}}catch(e){_procoding_throwError(e)}(function(){var e=console.log;console.log=function(t){tinylog.log(t);e.apply(console,arguments)}})();(function(){var e=console.info;console.info=function(t){tinylog.log(t);e.apply(console,arguments)}})();(function(){var e=console.warn;console.warn=function(t){tinylog.log(t);e.apply(console,arguments)}})();(function(){var e=console.error;console.error=function(t){tinylog.log(t);e.apply(console,arguments)}})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************** | |
Procoding.js | |
Copyright (c) 2013 by Michael Markert | |
http://procoding.audiocommander.de | |
version 0.3 | |
built June 2013 | |
*****************************************/ | |
/************************************** | |
The MIT License (MIT) | |
Copyright (c) 2013 Michael Markert | |
http://www.audiocommander.de | |
http://procoding.audiocommander.de | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE. | |
*********************************************************************************/ | |
CanvasRenderingContext2D.prototype.clear = function (color, x, y, w, h) { | |
if (typeof color === "string") { | |
this.save(); | |
this.fillStyle = color; | |
this.fillRect(x || 0, y || 0, w || this.canvas.width, h || this.canvas.height); | |
this.restore() | |
} else { | |
this.clearRect(x || 0, y || 0, w || this.canvas.width, h || this.canvas.height) | |
} | |
}; | |
CanvasRenderingContext2D.prototype.line = function (fx, fy, tx, ty) { | |
this.save(); | |
this.beginPath(); | |
this.moveTo(fx, fy); | |
this.lineTo(tx, ty); | |
this.stroke(); | |
this.restore() | |
}; | |
CanvasRenderingContext2D.prototype.circle = function (x, y, r) { | |
this.save(); | |
this.beginPath(); | |
this.arc(x, y, r, 0, Math.PI * 2, true); | |
this.closePath(); | |
this.fill(); | |
this.stroke(); | |
this.restore() | |
}; | |
CanvasRenderingContext2D.prototype.ellipse = function (x, y, rx, ry, centered) { | |
this.save(); | |
this.beginPath(); | |
this.translate(x - rx, y - ry); | |
this.scale(rx, ry); | |
this.arc(1, 1, 1, 0, Math.PI * 2, false); | |
this.closePath(); | |
this.restore(); | |
this.fill(); | |
this.stroke() | |
}; | |
CanvasRenderingContext2D.prototype.rect = function (x, y, w, h) { | |
this.save(); | |
this.fillRect(x, y, w, h); | |
this.strokeRect(x, y, w, h); | |
this.restore() | |
}; | |
CanvasRenderingContext2D.prototype.text = function (txt, x, y, w, font, align, shorten, length) { | |
length = length || txt.length; | |
if (shorten && txt.length > length) { | |
txt = txt.slice(0, length) + "…" | |
} | |
this.save(); | |
x = x || this.canvas.width / 2; | |
y = y || this.canvas.height / 2; | |
w = w || this.canvas.width; | |
this.font = font || w / length + "px American Typewriter"; | |
this.textAlign = align || "center"; | |
this.fillText(txt, x, y, w); | |
this.restore() | |
}; | |
CanvasRenderingContext2D.prototype.image = function (img, fit) { | |
this.save(); | |
var ratioW = this.canvas.width / img.width; | |
var ratioH = this.canvas.height / img.height; | |
var ratio; | |
if (fit) { | |
ratio = ratioW < ratioH ? ratioW : ratioH | |
} else { | |
ratio = ratioW < ratioH ? ratioH : ratioW | |
} | |
var imgWidth = img.width * ratio; | |
var imgHeight = img.height * ratio; | |
if (fit) { | |
this.drawImage(img, this.canvas.width / 2 - img.width / 2, this.canvas.height / 2 - img.height / 2, imgWidth, imgHeight) | |
} else { | |
this.drawImage(img, 0, 0, imgWidth, imgHeight) | |
} | |
this.restore() | |
}; | |
PColor.prototype.cycleHue = function (amount, format) { | |
if (amount === undefined) { | |
amount = 10 | |
} | |
var newValue = Math.wrap(this.hue, amount, 360); | |
this.hue = newValue; | |
return this.toString(format) | |
}; | |
PColor.cycleHue = function (color, amount, format) { | |
return new PColor(color).cycleHue(amount, format) | |
}; | |
PColor.prototype.saturate = function (amount, format) { | |
if (amount === undefined) { | |
amount = 10 | |
} | |
var newValue = Math.constrain(this.saturation + amount, 0, 100); | |
this.saturation = newValue; | |
return this.toString(format) | |
}; | |
PColor.saturate = function (color, amount, format) { | |
return new PColor(color).saturate(amount, format) | |
}; | |
PColor.prototype.lighten = function (amount, format) { | |
if (amount === undefined) { | |
amount = 10 | |
} | |
var newValue = Math.constrain(this.lightness + amount, 0, 100); | |
this.lightness = newValue; | |
return this.toString(format) | |
}; | |
PColor.lighten = function (color, amount, format) { | |
return new PColor(color).lighten(amount, format) | |
}; | |
PColor.prototype.grayscale = function (format) { | |
return this.saturate(-100, format) | |
}; | |
PColor.grayscale = function (color, format) { | |
return new PColor(color).grayscale(format) | |
}; | |
PColor.prototype.complementary = function (format) { | |
return this.cycleHue(180, format) | |
}; | |
PColor.complementary = function (color, format) { | |
return new PColor(color).complementary(format) | |
}; | |
PColor.randomColor = function (css, chance, format) { | |
if (css === undefined) { | |
css = "green"; | |
chance = 100 | |
} else { | |
chance = chance || 20 | |
} | |
chance = Math.constrain(chance, 0, 100); | |
var change = Math.random(0, chance); | |
change = Math.norm(change, 0, 100); | |
format = format || "hsl"; | |
var c = new PColor(css); | |
c.cycleHue(change * 360); | |
if (change > .55) { | |
c.saturation = Math.wrap(c.saturation, change * 100, 100); | |
c.lightness = Math.wrap(c.lightness, change * 100, 100) | |
} else { | |
if (Math.random() < .5) { | |
c.saturation = Math.constrain(c.saturation + change * 100, 0, 100) | |
} else { | |
c.saturation = Math.constrain(c.saturation - change * 100, 0, 100) | |
} if (Math.random() < .5) { | |
c.lightness = Math.constrain(c.lightness + change * 100, 0, 100) | |
} else { | |
c.lightness = Math.constrain(c.lightness - change * 100, 0, 100) | |
} | |
} | |
return c.toString(format) | |
}; | |
function PColor(css) { | |
css = css || "black"; | |
if (typeof css !== "string") { | |
css = "black" | |
} | |
css = css.toLowerCase(); | |
css = css.replace(/\s\s*/g, ""); | |
var _hue = NaN; | |
var _saturation = NaN; | |
var _lightness = NaN; | |
var _red = NaN; | |
var _green = NaN; | |
var _blue = NaN; | |
var _alpha = NaN; | |
var _hex = ""; | |
var _name = ""; | |
Object.defineProperty(this, "hue", { | |
get: function () { | |
return _hue | |
}, | |
set: function (newValue) { | |
_hue = Math.round(newValue); | |
_updateValuesFromHsl() | |
} | |
}); | |
Object.defineProperty(this, "saturation", { | |
get: function () { | |
return _saturation | |
}, | |
set: function (newValue) { | |
_saturation = Math.round(newValue); | |
_updateValuesFromHsl() | |
} | |
}); | |
Object.defineProperty(this, "lightness", { | |
get: function () { | |
return _lightness | |
}, | |
set: function (newValue) { | |
_lightness = Math.round(newValue); | |
_updateValuesFromHsl() | |
} | |
}); | |
Object.defineProperty(this, "red", { | |
get: function () { | |
return _red | |
}, | |
set: function (newValue) { | |
_red = Math.round(newValue); | |
_updateValuesFromRgb() | |
} | |
}); | |
Object.defineProperty(this, "green", { | |
get: function () { | |
return _green | |
}, | |
set: function (newValue) { | |
_green = Math.round(newValue); | |
_updateValuesFromRgb() | |
} | |
}); | |
Object.defineProperty(this, "blue", { | |
get: function () { | |
return _blue | |
}, | |
set: function (newValue) { | |
_blue = Math.round(newValue); | |
_updateValuesFromRgb() | |
} | |
}); | |
Object.defineProperty(this, "alpha", { | |
get: function () { | |
return _alpha | |
}, | |
set: function (newValue) { | |
_alpha = newValue | |
} | |
}); | |
Object.defineProperty(this, "name", { | |
get: function () { | |
return _name | |
}, | |
set: function (newValue) { | |
_name = newValue; | |
_hex = PColor.hexFromName(_name); | |
_updateValuesFromHex() | |
} | |
}); | |
Object.defineProperty(this, "hex", { | |
get: function () { | |
return _hex | |
}, | |
set: function (newValue) { | |
_hex = newValue; | |
_name = PColor.nameFromHex(_hex); | |
_updateValuesFromHex() | |
} | |
}); | |
var _getHslFromRgb = function () { | |
var hsl = PColor.rgbToHsl(_red, _green, _blue); | |
if (hsl.length === 3) { | |
_hue = hsl[0]; | |
_saturation = hsl[1]; | |
_lightness = hsl[2] | |
} | |
}; | |
var _getRgbFromHsl = function () { | |
var rgb = PColor.hslToRgb(_hue, _saturation, _lightness); | |
if (rgb.length === 3) { | |
_red = rgb[0]; | |
_green = rgb[1]; | |
_blue = rgb[2] | |
} | |
}; | |
var _updateValuesFromHsl = function () { | |
_getRgbFromHsl(); | |
_hex = "#" + Number(_red).toString(16) + Number(_green).toString(16) + Number(_blue).toString(16); | |
_alpha = _alpha || 1 | |
}; | |
var _updateValuesFromRgb = function () { | |
_hex = "#" + Number(_red).toString(16) + Number(_green).toString(16) + Number(_blue).toString(16); | |
_alpha = _alpha || 1; | |
_getHslFromRgb() | |
}; | |
var _updateValuesFromHex = function () { | |
if (_hex.length === 7) { | |
_red = parseInt(_hex[1] + _hex[2], 16); | |
_green = parseInt(_hex[3] + _hex[4], 16); | |
_blue = parseInt(_hex[5] + _hex[6], 16); | |
_alpha = _alpha || 1; | |
_getHslFromRgb() | |
} | |
}; | |
this.toString = function (format) { | |
format = format || "hsla"; | |
format = format.toLowerCase(); | |
if (format === "name") { | |
return _name | |
} | |
if (format === "hex") { | |
return _hex | |
} | |
var str; | |
if (format === "hsl" || format === "hsla") { | |
str = format + "(" + _hue + ", " + _saturation + "%, " + _lightness + "%"; | |
if (format === "hsla") { | |
str += ", " + _alpha | |
} | |
str += ")"; | |
return str | |
} | |
if (format === "rgb" || format === "rgba") { | |
str = format + "(" + _red + ", " + _green + ", " + _blue; | |
if (format === "rgba") { | |
str += ", " + _alpha | |
} | |
str += ")"; | |
return str | |
} | |
}; | |
var result = []; | |
result = /\b(?:aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|feldspar|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgrey|lightgreen|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslateblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|violetred|wheat|white|whitesmoke|yellow|yellowgreen)\b/.exec(css); | |
if (result && result.length) { | |
_name = css; | |
_hex = PColor.hexFromName(_name); | |
_updateValuesFromHex(); | |
return this | |
} | |
result = /^rgb[a]*\(([\d]+),\s*([\d]+)%*,\s*([\d]+)%*(?:,\s*([\d*.\d]+))?\)/.exec(css); | |
if (result && result.length >= 4) { | |
_name = result[0]; | |
_red = parseInt(result[1], 10); | |
_green = parseInt(result[2], 10); | |
_blue = parseInt(result[3], 10); | |
if (result.length === 5) { | |
_alpha = parseFloat(result[4]) | |
} | |
_updateValuesFromRgb(); | |
return this | |
} | |
result = /^hsl[a]*\(([\d]+),\s*([\d]+)%*,\s*([\d]+)%*(?:,\s*([\d*.\d]+))?\)/.exec(css); | |
if (result && result.length >= 4) { | |
_name = result[0]; | |
_hue = parseInt(result[1], 10); | |
_saturation = parseInt(result[2], 10); | |
_lightness = parseInt(result[3], 10); | |
if (result.length === 5) { | |
_alpha = parseFloat(result[4]) | |
} | |
_updateValuesFromHsl(); | |
return this | |
} | |
result = /(?:[0-9A-Fa-f]{6})|(?:[0-9A-Fa-f]{3})/.exec(css); | |
if (result && result.length) { | |
_name = PColor.nameFromHex(css); | |
if (_name.length === 0) { | |
_name = css; | |
_hex = css | |
} else { | |
_hex = PColor.hexFromName(this.name) | |
} | |
_updateValuesFromHex(); | |
return this | |
} | |
console.warn("Error getting color from " + css); | |
_name = css; | |
return this | |
} | |
PColor.rgbToHsl = function (r, g, b) { | |
r /= 255, g /= 255, b /= 255; | |
var max = Math.max(r, g, b), | |
min = Math.min(r, g, b); | |
var h, s, l = (max + min) / 2; | |
if (max == min) { | |
h = s = 0 | |
} else { | |
var d = max - min; | |
s = l > .5 ? d / (2 - max - min) : d / (max + min); | |
switch (max) { | |
case r: | |
h = (g - b) / d + (g < b ? 6 : 0); | |
break; | |
case g: | |
h = (b - r) / d + 2; | |
break; | |
case b: | |
h = (r - g) / d + 4; | |
break | |
} | |
h /= 6 | |
} | |
h = Math.round(Math.map(h, 0, 1, 0, 360)); | |
s = Math.round(Math.map(s, 0, 1, 0, 100)); | |
l = Math.round(Math.map(l, 0, 1, 0, 100)); | |
return [h, s, l] | |
}; | |
PColor.hslToRgb = function (h, s, l) { | |
h = Math.norm(h, 0, 360); | |
s = Math.norm(s, 0, 100); | |
l = Math.norm(l, 0, 100); | |
var r, g, b; | |
function hue2rgb(p, q, t) { | |
if (t < 0) { | |
t += 1 | |
} | |
if (t > 1) { | |
t -= 1 | |
} | |
if (t < 1 / 6) { | |
return p + (q - p) * 6 * t | |
} | |
if (t < 1 / 2) { | |
return q | |
} | |
if (t < 2 / 3) { | |
return p + (q - p) * (2 / 3 - t) * 6 | |
} | |
return p | |
} | |
if (s === 0) { | |
r = g = b = l | |
} else { | |
var q = l < .5 ? l * (1 + s) : l + s - l * s; | |
var p = 2 * l - q; | |
r = hue2rgb(p, q, h + 1 / 3); | |
g = hue2rgb(p, q, h); | |
b = hue2rgb(p, q, h - 1 / 3) | |
} | |
r = Math.round(r * 255); | |
g = Math.round(g * 255); | |
b = Math.round(b * 255); | |
return [r, g, b] | |
}; | |
PColor.hexFromName = function (name) { | |
var hex = PColor.namedColors[name.toLowerCase()]; | |
if (hex === "undefined") { | |
hex = "#000000" | |
} | |
return hex | |
}; | |
PColor.nameFromHex = function (hex) { | |
hex = hex.toLowerCase(); | |
hex = hex.replace("#", ""); | |
if (hex.length === 3) { | |
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] | |
} | |
hex = "#" + hex; | |
var name = ""; | |
for (var n in PColor.namedColors) { | |
if (PColor.namedColors[n] === hex) { | |
name = n; | |
break | |
} | |
} | |
return name | |
}; | |
PColor.namedColors = { | |
aliceblue: "#f0f8ff", | |
antiquewhite: "#faebd7", | |
aqua: "#00ffff", | |
aquamarine: "#7fffd4", | |
azure: "#f0ffff", | |
beige: "#f5f5dc", | |
bisque: "#ffe4c4", | |
black: "#000000", | |
blanchedalmond: "#ffebcd", | |
blue: "#0000ff", | |
blueviolet: "#8a2be2", | |
brown: "#a52a2a", | |
burlywood: "#deb887", | |
cadetblue: "#5f9ea0", | |
chartreuse: "#7fff00", | |
chocolate: "#d2691e", | |
coral: "#ff7f50", | |
cornflowerblue: "#6495ed", | |
cornsilk: "#fff8dc", | |
crimson: "#dc143c", | |
cyan: "#00ffff", | |
darkblue: "#00008b", | |
darkcyan: "#008b8b", | |
darkgoldenrod: "#b8860b", | |
darkgray: "#a9a9a9", | |
darkgrey: "#a9a9a9", | |
darkgreen: "#006400", | |
darkkhaki: "#bdb76b", | |
darkmagenta: "#8b008b", | |
darkolivegreen: "#556b2f", | |
darkorange: "#ff8c00", | |
darkorchid: "#9932cc", | |
darkred: "#8b0000", | |
darksalmon: "#e9967a", | |
darkseagreen: "#8fbc8f", | |
darkslateblue: "#483d8b", | |
darkslategray: "#2f4f4f", | |
darkslategrey: "#2f4f4f", | |
darkturquoise: "#00ced1", | |
darkviolet: "#9400d3", | |
deeppink: "#ff1493", | |
deepskyblue: "#00bfff", | |
dimgray: "#696969", | |
dimgrey: "#696969", | |
dodgerblue: "#1e90ff", | |
firebrick: "#b22222", | |
floralwhite: "#fffaf0", | |
forestgreen: "#228b22", | |
fuchsia: "#ff00ff", | |
gainsboro: "#dcdcdc", | |
ghostwhite: "#f8f8ff", | |
gold: "#ffd700", | |
goldenrod: "#daa520", | |
gray: "#808080", | |
grey: "#808080", | |
green: "#008000", | |
greenyellow: "#adff2f", | |
honeydew: "#f0fff0", | |
hotpink: "#ff69b4", | |
"indianred ": "#cd5c5c", | |
"indigo ": "#4b0082", | |
ivory: "#fffff0", | |
khaki: "#f0e68c", | |
lavender: "#e6e6fa", | |
lavenderblush: "#fff0f5", | |
lawngreen: "#7cfc00", | |
lemonchiffon: "#fffacd", | |
lightblue: "#add8e6", | |
lightcoral: "#f08080", | |
lightcyan: "#e0ffff", | |
lightgoldenrodyellow: "#fafad2", | |
lightgray: "#d3d3d3", | |
lightgrey: "#d3d3d3", | |
lightgreen: "#90ee90", | |
lightpink: "#ffb6c1", | |
lightsalmon: "#ffa07a", | |
lightseagreen: "#20b2aa", | |
lightskyblue: "#87cefa", | |
lightslategray: "#778899", | |
lightslategrey: "#778899", | |
lightsteelblue: "#b0c4de", | |
lightyellow: "#ffffe0", | |
lime: "#00ff00", | |
limegreen: "#32cd32", | |
linen: "#faf0e6", | |
magenta: "#ff00ff", | |
maroon: "#800000", | |
mediumaquamarine: "#66cdaa", | |
mediumblue: "#0000cd", | |
mediumorchid: "#ba55d3", | |
mediumpurple: "#9370d8", | |
mediumseagreen: "#3cb371", | |
mediumslateblue: "#7b68ee", | |
mediumspringgreen: "#00fa9a", | |
mediumturquoise: "#48d1cc", | |
mediumvioletred: "#c71585", | |
midnightblue: "#191970", | |
mintcream: "#f5fffa", | |
mistyrose: "#ffe4e1", | |
moccasin: "#ffe4b5", | |
navajowhite: "#ffdead", | |
navy: "#000080", | |
oldlace: "#fdf5e6", | |
olive: "#808000", | |
olivedrab: "#6b8e23", | |
orange: "#ffa500", | |
orangered: "#ff4500", | |
orchid: "#da70d6", | |
palegoldenrod: "#eee8aa", | |
palegreen: "#98fb98", | |
paleturquoise: "#afeeee", | |
palevioletred: "#d87093", | |
papayawhip: "#ffefd5", | |
peachpuff: "#ffdab9", | |
peru: "#cd853f", | |
pink: "#ffc0cb", | |
plum: "#dda0dd", | |
powderblue: "#b0e0e6", | |
purple: "#800080", | |
red: "#ff0000", | |
rosybrown: "#bc8f8f", | |
royalblue: "#4169e1", | |
saddlebrown: "#8b4513", | |
salmon: "#fa8072", | |
sandybrown: "#f4a460", | |
seagreen: "#2e8b57", | |
seashell: "#fff5ee", | |
sienna: "#a0522d", | |
silver: "#c0c0c0", | |
skyblue: "#87ceeb", | |
slateblue: "#6a5acd", | |
slategray: "#708090", | |
slategrey: "#708090", | |
snow: "#fffafa", | |
springgreen: "#00ff7f", | |
steelblue: "#4682b4", | |
tan: "#d2b48c", | |
teal: "#008080", | |
thistle: "#d8bfd8", | |
tomato: "#ff6347", | |
turquoise: "#40e0d0", | |
violet: "#ee82ee", | |
wheat: "#f5deb3", | |
white: "#ffffff", | |
whitesmoke: "#f5f5f5", | |
yellow: "#ffff00", | |
yellowgreen: "#9acd32" | |
}; | |
var mouseX = 0; | |
var mouseY = 0; | |
var pmouseX = 0; | |
var pmouseY = 0; | |
var mousePressed = false; | |
function __updateMouseValues(e) { | |
pmouseX = mouseX; | |
pmouseY = mouseY; | |
if (e.touches && e.touches.length) { | |
mouseX = e.touches[0].clientX; | |
mouseY = e.touches[0].clientY | |
} else { | |
mouseX = e.clientX; | |
mouseY = e.clientY | |
} | |
} | |
function _mouseDown(e) { | |
mousePressed = true; | |
__updateMouseValues(e); | |
if (typeof mouseDown !== "undefined") { | |
mouseDown(e) | |
} | |
} | |
function _mouseUp(e) { | |
mousePressed = false; | |
__updateMouseValues(e); | |
if (typeof mouseUp !== "undefined") { | |
mouseUp(e) | |
} | |
} | |
function _mouseMove(e) { | |
__updateMouseValues(e); | |
if (mousePressed) { | |
_mouseDrag(e) | |
} else if (typeof mouseMove !== "undefined") { | |
mouseMove(e) | |
} | |
} | |
function _mouseDrag(e) { | |
if (typeof mouseDrag !== "undefined") { | |
mouseDrag(e) | |
} | |
} | |
function _touchStart(e) { | |
mousePressed = true; | |
__updateMouseValues(e); | |
if (typeof touchStart !== "undefined") { | |
touchStart(e) | |
} | |
} | |
function _touchMove(e) { | |
__updateMouseValues(e); | |
if (typeof touchMove !== "undefined") { | |
touchMove(e) | |
} | |
} | |
function _touchEnd(e) { | |
mousePressed = false; | |
__updateMouseValues(e); | |
if (typeof touchEnd !== "undefined") { | |
touchEnd(e) | |
} | |
} | |
function _touchCancel(e) { | |
mousePressed = false; | |
__updateMouseValues(e); | |
if (typeof touchCancel !== "undefined") { | |
touchCancel(e) | |
} | |
}! function () { | |
addEventListener("mousedown", _mouseDown); | |
addEventListener("mouseup", _mouseUp); | |
addEventListener("mousemove", _mouseMove); | |
addEventListener("touchstart", _touchStart); | |
addEventListener("touchend", _touchEnd); | |
addEventListener("touchmove", _touchMove); | |
addEventListener("touchcancel", _touchCancel) | |
}(); | |
if (!window.requestAnimationFrame) { | |
window.requestAnimationFrame = function () { | |
return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame || function (callback) { | |
return window.setTimeout(callback, 1e3 / 60) | |
} | |
}() | |
} | |
function PImage(ctx, x, y, w, h) { | |
if (ctx === undefined) { | |
console.error("PImage needs a valid drawing context as first parameter"); | |
return | |
} | |
this.ctx = ctx; | |
this.x = x || 0; | |
this.y = y || 0; | |
this.width = w || 100; | |
this.height = h || 100; | |
this.imageData = ctx.getImageData(this.x, this.y, this.width, this.height) | |
} | |
PImage.prototype.draw = function () { | |
this.ctx.putImageData(this.imageData, this.x, this.y) | |
}; | |
PImage.prototype.filter = function (filterName) { | |
filterName = filterName || "grayscale"; | |
var input = this.imageData; | |
var output = this.ctx.createImageData(this.width, this.height); | |
var inputData = input.data; | |
var outputData = output.data; | |
var x = this.x; | |
var y = this.y; | |
var w = this.width; | |
var h = this.height; | |
var c = 0; | |
var pixel; | |
var factor; | |
for (y = 1; y < h - 1; y += 1) { | |
for (x = 1; x < w - 1; x += 1) { | |
pixel = (y * w + x) * 4; | |
if (filterName === "blackAndWhite") { | |
factor = inputData[pixel] * .3 + inputData[pixel + 1] * .59 + inputData[pixel + 2] * .11; | |
if (factor > 192) { | |
factor = 255 | |
} else { | |
factor = 0 | |
} | |
for (c = 0; c < 3; c += 1) { | |
outputData[pixel + c] = factor | |
} | |
outputData[pixel + 3] = inputData[pixel + 3] | |
} | |
if (filterName === "grayscale") { | |
factor = inputData[pixel] * .3 + inputData[pixel + 1] * .59 + inputData[pixel + 2] * .11; | |
outputData[pixel] = factor * 1; | |
outputData[pixel + 1] = factor * 1; | |
outputData[pixel + 2] = factor * 1; | |
outputData[pixel + 3] = inputData[pixel + 3] | |
} | |
if (filterName === "invert") { | |
for (c = 0; c < 3; c += 1) { | |
outputData[pixel + c] = 255 - inputData[pixel + c] | |
} | |
outputData[pixel + 3] = inputData[pixel + 3] | |
} | |
} | |
} | |
return output | |
}; | |
! function () { | |
var random = Math.random; | |
Math.random = function (min, max) { | |
if (typeof max === "undefined") { | |
if (typeof min === "undefined") { | |
return random() | |
} | |
max = min; | |
min = 0 | |
} | |
if (min % 1 !== 0 || max % 1 !== 0) { | |
return random() * (max - min) + min | |
} else { | |
return Math.floor(random() * (max - min)) + min | |
} | |
} | |
}(); | |
Math.nrandom = function (mean, stdDeviation) { | |
mean = mean || 0; | |
stdDeviation = stdDeviation || 1; | |
var snd = Math.random() * 2 - 1 + (Math.random() * 2 - 1) + (Math.random() * 2 - 1); | |
return Math.round(snd * stdDeviation + mean) | |
}; | |
Math.bellCurve = function (length, mean, deviation, range) { | |
var values = []; | |
length = length || 0; | |
mean = mean || 0; | |
deviation = deviation || .5; | |
range = range || 3; | |
var i; | |
for (i = 0; i < length; i++) { | |
var c = Math.map(i, 0, length, range * -1, range); | |
var m = (c - mean) * (c - mean) * -1; | |
values[i] = 1 / (deviation * Math.sqrt(Math.PI * 2)) * Math.pow(Math.E, m / deviation * deviation) | |
} | |
return values | |
}; | |
Math.perlin = function () { | |
return [0] | |
}; | |
Math.norm = function (v, min, max) { | |
return (v - min) / (max - min) | |
}; | |
Math.constrain = function (value, min, max) { | |
if (value < min) { | |
return min | |
} | |
if (value > max) { | |
return max | |
} | |
return value | |
}; | |
Math.wrap = function (value, amount, max) { | |
max = max || 360; | |
value = value + amount; | |
return (value % max + max) % max | |
}; | |
Math.roundToDigitsAfterComma = function (value, digits) { | |
if (typeof digits === "undefined") { | |
return Math.round(value) | |
} else { | |
var factor = Math.pow(10, digits); | |
value *= factor; | |
value = Math.round(value); | |
return value / factor | |
} | |
}; | |
Math.map = function (value, srcMin, srcMax, dstMin, dstMax) { | |
return (dstMax - dstMin) * ((value - srcMin) / (srcMax - srcMin)) + dstMin | |
}; | |
Math.dist = function (x1, y1, x2, y2) { | |
var xs = x2 - x1; | |
var ys = y2 - y1; | |
return Math.sqrt(xs * xs + ys * ys) | |
}; | |
Math.degreesToRadians = function (degrees) { | |
return degrees * (Math.PI / 180) | |
}; | |
Math.radiansToDegrees = function (radians) { | |
return radians * (180 / Math.PI) | |
}; | |
Math.toString = function (v, digits, after) { | |
var isNegative = false; | |
if (v < 0) { | |
isNegative = true; | |
v = v * -1 | |
} | |
var str = "" + v; | |
var intStr = "" + parseInt(v, 10); | |
var fltStr = ""; | |
var i; | |
var zeros = digits - intStr.length; | |
if (zeros > 0) { | |
for (i = 0; i < zeros; i++) { | |
intStr = "0" + intStr | |
} | |
} else {} if (isNegative) { | |
intStr = "-" + intStr | |
} | |
var decPoint = str.indexOf("."); | |
if (after > 0) { | |
fltStr = str.slice(decPoint + 1, decPoint + 1 + after); | |
if (decPoint && fltStr.length > 0) { | |
fltStr = fltStr.substr(0, after) | |
} | |
for (i = fltStr.length; i < after; i++) { | |
fltStr += "0" | |
} | |
} | |
if (fltStr.length > 0) { | |
fltStr = "." + fltStr | |
} | |
return intStr + fltStr | |
}; | |
function PVector(x, y) { | |
this.x = 0; | |
this.y = 0; | |
if (typeof x === "object" && x.hasOwnProperty("x")) { | |
this.x = x.x; | |
this.y = x.y | |
} else { | |
this.x = x || 0; | |
this.y = y || 0 | |
} | |
this.add = function (v) { | |
if (typeof v === "object" && v.hasOwnProperty("x")) { | |
this.x += v.x; | |
this.y += v.y | |
} else { | |
this.x += v; | |
this.y += v | |
} | |
}; | |
this.subtract = function (v) { | |
if (typeof v === "object" && v.hasOwnProperty("x")) { | |
this.x -= v.x; | |
this.y -= v.y | |
} else { | |
this.x -= v; | |
this.y -= v | |
} | |
}; | |
this.multiply = function (v) { | |
if (typeof v === "object" && v.hasOwnProperty("x")) { | |
this.x *= v.x; | |
this.y *= v.y | |
} else { | |
this.x *= v; | |
this.y *= v | |
} | |
}; | |
this.divide = function (v) { | |
if (typeof v === "object" && v.hasOwnProperty("x")) { | |
this.x /= v.x; | |
this.y /= v.y | |
} else { | |
this.x /= v; | |
this.y /= v | |
} | |
}; | |
this.dot = function (v, y) { | |
if (typeof v === "object" && v.hasOwnProperty("x")) { | |
return this.x * v.x + this.y * v.y | |
} else { | |
return this.x * v + this.y * y | |
} | |
}; | |
this.magnitude = function () { | |
return Math.sqrt(this.x * this.x + this.y * this.y) | |
}; | |
this.limit = function (l) { | |
if (this.magnitude() > l) { | |
this.normalize(); | |
this.multiply(l) | |
} | |
}; | |
this.angle = function (v) { | |
var v1 = new PVector(this); | |
var v2; | |
if (typeof v === "object" && v.hasOwnProperty("x")) { | |
v2 = new PVector(v.x, v.y) | |
} else { | |
v2 = new PVector(0, 0) | |
} | |
v1.normalize(); | |
v2.normalize(); | |
var d = v1.dot(v2) / v1.magnitude() * v2.magnitude(); | |
return Math.acos(d) | |
}; | |
this.heading = function () { | |
var vec = new PVector(this); | |
vec.normalize(); | |
return Math.atan2(vec.y * -1, vec.x) * -1 | |
}; | |
this.rotate = function (angle) { | |
var x = this.x; | |
var y = this.y; | |
var c = Math.cos(angle); | |
var s = Math.sin(angle); | |
this.x = c * x - s * y; | |
this.y = s * x + c * y | |
}; | |
this.normalize = function () { | |
var m = this.magnitude(); | |
if (m === 0) { | |
m = 1 | |
} | |
this.divide(m) | |
}; | |
this.toArray = function () { | |
return [this.x, this.y] | |
}; | |
this.toString = function () { | |
return "x:" + this.x + ", y:" + this.y | |
} | |
} | |
PVector.fromAngle = function (angle) { | |
angle = angle || .01; | |
return new PVector(Math.cos(angle), Math.sin(angle)) | |
}; | |
PVector.random = function () { | |
return PVector.fromAngle(Math.random() * 2 * Math.PI) | |
}; | |
PVector.add = function (vecA, vecB) { | |
if (typeof vecA === "object" && vecA.hasOwnProperty("x") && typeof vecB === "object" && vecB.hasOwnProperty("x")) { | |
var vecC = new PVector(vecA); | |
vecC.add(vecB); | |
return vecC | |
} | |
}; | |
PVector.subtract = function (vecA, vecB) { | |
if (typeof vecA === "object" && vecA.hasOwnProperty("x") && typeof vecB === "object" && vecB.hasOwnProperty("x")) { | |
var vecC = new PVector(vecA); | |
vecC.subtract(vecB); | |
return vecC | |
} | |
}; | |
PVector.multiply = function (vecA, vecB) { | |
if (typeof vecA === "object" && vecA.hasOwnProperty("x") && typeof vecB === "object" && vecB.hasOwnProperty("x")) { | |
var vecC = new PVector(vecA); | |
vecC.multiply(vecB); | |
return vecC | |
} | |
}; | |
PVector.divide = function (vecA, vecB) { | |
if (typeof vecA === "object" && vecA.hasOwnProperty("x") && typeof vecB === "object" && vecB.hasOwnProperty("x")) { | |
var vecC = new PVector(vecA); | |
vecC.divide(vecB); | |
return vecC | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
-webkit-touch-callout: none; /* Disable Open/Copy/Cancel */ | |
-webkit-user-select: none; /* Prevent selection of any element */ | |
-webkit-tap-highlight-color: rgba(0,0,0,0); /* set highlight color to transparant */ | |
} | |
body { | |
background-color:#000; | |
font-family:Arial,Verdana; | |
font-size:1em; | |
margin: 0; | |
padding: 0; | |
overflow: hidden; /* hide scrollbar scroll */ | |
} | |
canvas { | |
image-rendering: optimizespeed !important; | |
overflow: hidden; /* hide scrollbar scroll */ | |
-webkit-transform-origin: left top; | |
-webkit-transform: scale(1,1); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@source http://purl.eligrey.com/github/tinylog/blob/master/tinylog.js | |
"use strict";var tinylog=tinylog||{encoders:{},decoders:{}},console;if(!console){console={}}(function(m,t){var p=function(){return String.fromCharCode.apply(String,arguments)},s=function(e){return e.toLocaleString()},g="GIF89a"+p(1,0,1,0,145,255,0,255,255,255,0,0,0,192,192,192,0,0,0,33,249,4,1,0,0,2,0,44,0,0,0,0,1,0,1,0,0,2,2,84,1,0,59),q=new RegExp("^"+g),j=m.entries=[],b=m.encoders,o=m.decoders,k=m.encodings=["JSON"],c=s("Unsupported encoding: %s"),v,i=!1,f=!0,r=function(e){return Array.prototype.slice.call(e)},n=function(e,l){j.push([e.getTime(),l])},a=m.uninit=function(){m.postEntry=n},d=m.encode=function(l,x){if(!x){x=j}if(!l){l=k}if(typeof l==="string"){l=[l]}for(var w=0,e=l.length;w<e;w++){if(b[l[w]]){x=l[w]+"\n"+b[l[w]](x)}else{throw new Error(c.replace("%s",l[w]))}}return x},h=m.setEncodings=function(){k.length=0;for(var l=0,e=arguments.length;l<e;l++){k.push(arguments[l])}};m.postEntry=n;m.display=m.setSafetyMargin=function(){};m.log=function(){m.postEntry(new Date(),r(arguments).join(" "))};m.clear=function(){j.length=0};b.JSON=function(e){return unescape(encodeURIComponent(JSON.stringify(e)))};o.JSON=function(e){return JSON.parse(decodeURIComponent(escape(e)))};m.decode=function(w){if(q.test(w)){w=w.substr(g.length)}var e=w.indexOf("\n"),l=w.substr(0,e);if(o[l]){return o[l](w.substr(e+1))}else{throw new Error(c+l)}};if(t.log&&!t.TINYLOG){m.postEntry=function(e,l){n(e,l);t.log(l)}}else{if(typeof document!=="undefined"){(function(){var U="div",G="style",A="className",S="setAttribute",B="data-",L="title",x="tinylog",M=x+" ",O=x+"-save-button",T=M+"tinylog-entry",F=T+"-text",V=document,I=V.defaultView,R=V.documentElement,y=btoa,e=R[G],J=f,K=f,H,Q=function(X,W){return X.appendChild(W)},N=function(W){return V.createElement(W)},C=function(W){return V.createTextNode(W)},P=function(Y,X,W){if(Y.addEventListener){Y.addEventListener(X,W,i)}else{if(Y.attachEvent){Y.attachEvent("on"+X,W)}}return[Y,X,W]},w=function(Y,X,W){if(Y.removeEventListener){Y.removeEventListener(X,W,i)}else{if(Y.detachEvent){Y.detachEvent("on"+X,W)}}},D=function(X){var W=X.childNodes,Y=W.length;while(Y--){X.removeChild(W.item(0))}},l=m.setSafetyMargin=function(W){J=W},z=function(){var ad=e.paddingBottom,Z=N(U),aj=Z[G],ak=Q(Z,N(U)),ab=Q(Z,N(U)),ah=Q(Z,N(U)),ae=Q(ah,N("a")),ag=Q(ae,new Image()),aa=Q(ah,N(U)),al=i,ac=i,Y,W=function(){e.paddingBottom=Z.clientHeight+"px"},am=function(){ag.src="data:image/gif;base64,"+y(g+d());K=i;ae.href="data:application/x-tinylog;base64,"+y(d())},ai=function(an){var ao=I.innerHeight,ap=ak.clientHeight;if(an<0){an=0}else{if(an+ap>ao){an=ao-ap}}aj.height=an+"px";if(J){W()}},X=m.clear=function(){D(ab);j.length=0},af=[P(V,"mousemove",function(an){if(al){ai(I.innerHeight-an.clientY);ab.scrollTop=Y}}),P(V,"mouseup",function(){if(al){al=Y=i}}),P(ak,"dblclick",function(an){an.preventDefault();if(ac){ai(ac);ac=i}else{ac=Z.clientHeight;aj.height="0px"}}),P(ak,"mousedown",function(an){an.preventDefault();al=f;Y=ab.scrollTop}),P(ak,"contextmenu",function(){al=i}),P(ae,"mouseover",function(){if(K){am()}}),P(aa,"click",function(){a()})];a=m.uninit=function(){var an=af.length;while(an--){w.apply(m,af[an])}R.removeChild(Z);e.paddingBottom=ad;X();D(ah);D(Z);m.postEntry=H;m.setEncodings=h;m.setSafetyMargin=l};m.setEncodings=function(){h.apply(m,arguments);am()};m.setSafetyMargin=function(an){l(an);W()};Z[A]=M+x+"-container";ab[A]=M+x+"-output";ah[A]=M+x+"-buttons-container";ae[A]=M+x+"-button "+O;ae[L]=s("Click or open a context menu here to save log");ae[S](B+"symbol","\u2B07");ag[A]=M+O+"-image";am();aa[A]=M+x+"-button "+x+"-close-button";aa[L]=s("Close Log");aa[S](B+"symbol","\u2716");ak[A]=M+x+"-resizer";ak[L]=s("Double-click to toggle log minimization");return[Z,ab]},E=m.display=function(){var Y=z(),W=Y[0],X=Y[1];m.postEntry=function(aa,ac){var ab=Q(X,N(U)),Z=Q(ab,N(U));ab[L]=aa.toLocaleTimeString();ab[A]=T;Z[A]=F;n(aa,ac);K=f;Q(Z,C(ac));X.scrollTop=X.scrollHeight};Q(R,W)};H=m.postEntry=function(W,X){E();m.postEntry(W,X)}}())}else{if(typeof print==="function"){m.postEntry=function(e,l){n(e,l);print(l)}}}}if(!t.log){t.log=m.log}else{try{v=t.log;t.log=function(){n(new Date(),r(arguments).join(" "));v.apply(t,arguments)}}catch(u){v=null}}}(tinylog,console)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment