was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 6  →  ?path2? @ 7
/tags/1.0.0/dist/was.js
@@ -129,9 +129,8 @@
}
});
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasCSVToArray(csv) {
var l = [];
var s = [];
@@ -170,9 +169,9 @@
return l;
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/*************************************************************************/
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasArrayToCSV(a) {
var csv = [];
for(var i=0; i<a.length; ++i) {
@@ -185,3 +184,30 @@
}
return csv.join();
}
 
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasMapValueToRange(value, xMin, xMax, yMin, yMax) {
return yMin + (
( yMax - yMin ) * ( value - xMin ) / ( xMax - xMin )
);
}
 
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function HexToRGB(hex) {
var shortRegEx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(
shortRegEx,
function(m, r, g, b) {
return r + r + g + g + b + b;
}
);
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
/tags/1.0.0/dist/was.min.js
@@ -1,4 +1,4 @@
/*! was - v1.0.0 - 2017-05-28
* http://grimore.org
* Copyright (c) 2017 Wizardry and Steamworks <office@grimore.org>; Licensed GPL-3.0 */
function wasCSVToArray(a){var b=[],c=[],d="";do{var e=a.charAt(0);if(a=a.slice(1,a.length),","!==e)if('"'!==e||a.charAt(0)!==e)if('"'!==e)d+=e;else{if(c[c.length-1]!==e){c.push(e);continue}c.pop()}else d+=e,a=a.slice(1,a.length);else{if('"'!==c[c.length-1]){b.push(d),d="";continue}d+=e}}while(""!==a);return b.push(d),b}function wasArrayToCSV(a){for(var b=[],c=0;c<a.length;++c){var d=a[c].toString().replace('"','""');/"\s,\r\n/.test(d)?b[c]='"'+d+'"':b[c]=d}return b.join()}Array.prototype.product||(Array.prototype.product=function(a){var b=this;return $.map(new Array(Math.max(this.length,b.length)),function(c,d){var e={};return e[b[d]]=a[d],e})}),$.extend({product:function(a,b){return $.map(new Array(Math.max(this.length,a.length)),function(c,d){var e={};return e[a[d]]=b[d],e})}}),Array.prototype.stride||(Array.prototype.stride=function(a){return this.filter(function(b,c){return c%a==0})}),$.extend({stride:function(a,b){return a.filter(function(a,c){return c%b==0})}}),Array.prototype.chunk||(Array.prototype.chunk=function(a){return this.length?[this.slice(0,a)].concat(this.slice(a).chunk(a)):[]}),$.extend({chunk:function(a,b){return a.length?[a.slice(0,b)].concat(a.slice(b).chunk(b)):[]}}),Array.prototype.equals||(Array.prototype.equals=function(a){if(!a)return!1;if(this.length!==a.length)return!1;for(var b=0,c=this.length;b<c;b++)if(this[b]instanceof Array&&a[b]instanceof Array){if(!this[b].equals(a[b]))return!1}else if(this[b]!==a[b])return!1;return!0}),$.extend({equals:function(a){if(!a)return!1;if(this.length!==a.length)return!1;for(var b=0,c=this.length;b<c;b++)if(this[b]instanceof Array&&a[b]instanceof Array){if(!this[b].equals(a[b]))return!1}else if(this[b]!==a[b])return!1;return!0}});
function wasCSVToArray(a){var b=[],c=[],d="";do{var e=a.charAt(0);if(a=a.slice(1,a.length),","!==e)if('"'!==e||a.charAt(0)!==e)if('"'!==e)d+=e;else{if(c[c.length-1]!==e){c.push(e);continue}c.pop()}else d+=e,a=a.slice(1,a.length);else{if('"'!==c[c.length-1]){b.push(d),d="";continue}d+=e}}while(""!==a);return b.push(d),b}function wasArrayToCSV(a){for(var b=[],c=0;c<a.length;++c){var d=a[c].toString().replace('"','""');/"\s,\r\n/.test(d)?b[c]='"'+d+'"':b[c]=d}return b.join()}function wasMapValueToRange(a,b,c,d,e){return d+(e-d)*(a-b)/(c-b)}function HexToRGB(a){var b=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;a=a.replace(b,function(a,b,c,d){return b+b+c+c+d+d});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return c?{r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)}:null}Array.prototype.product||(Array.prototype.product=function(a){var b=this;return $.map(new Array(Math.max(this.length,b.length)),function(c,d){var e={};return e[b[d]]=a[d],e})}),$.extend({product:function(a,b){return $.map(new Array(Math.max(this.length,a.length)),function(c,d){var e={};return e[a[d]]=b[d],e})}}),Array.prototype.stride||(Array.prototype.stride=function(a){return this.filter(function(b,c){return c%a==0})}),$.extend({stride:function(a,b){return a.filter(function(a,c){return c%b==0})}}),Array.prototype.chunk||(Array.prototype.chunk=function(a){return this.length?[this.slice(0,a)].concat(this.slice(a).chunk(a)):[]}),$.extend({chunk:function(a,b){return a.length?[a.slice(0,b)].concat(a.slice(b).chunk(b)):[]}}),Array.prototype.equals||(Array.prototype.equals=function(a){if(!a)return!1;if(this.length!==a.length)return!1;for(var b=0,c=this.length;b<c;b++)if(this[b]instanceof Array&&a[b]instanceof Array){if(!this[b].equals(a[b]))return!1}else if(this[b]!==a[b])return!1;return!0}),$.extend({equals:function(a){if(!a)return!1;if(this.length!==a.length)return!1;for(var b=0,c=this.length;b<c;b++)if(this[b]instanceof Array&&a[b]instanceof Array){if(!this[b].equals(a[b]))return!1}else if(this[b]!==a[b])return!1;return!0}});
/tags/1.0.0/lib/formats/csv/csv.js
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/*************************************************************************/
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasCSVToArray(csv) {
var l = [];
var s = [];
@@ -39,9 +39,9 @@
return l;
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/*************************************************************************/
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasArrayToCSV(a) {
var csv = [];
for(var i=0; i<a.length; ++i) {
/tags/1.0.0/lib/mathematics/algebra.js
@@ -0,0 +1,8 @@
/*************************************************************************/
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasMapValueToRange(value, xMin, xMax, yMin, yMax) {
return yMin + (
( yMax - yMin ) * ( value - xMin ) / ( xMax - xMin )
);
}
/tags/1.0.0/lib/physics/colorimetry.js
@@ -0,0 +1,19 @@
/*************************************************************************/
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function HexToRGB(hex) {
var shortRegEx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(
shortRegEx,
function(m, r, g, b) {
return r + r + g + g + b + b;
}
);
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}