initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

14
node_modules/art/core/class.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
module.exports = function(mixins){
var proto = {};
for (var i = 0, l = arguments.length; i < l; i++){
var mixin = arguments[i];
if (typeof mixin == 'function') mixin = mixin.prototype;
for (var key in mixin) proto[key] = mixin[key];
}
if (!proto.initialize) proto.initialize = function(){};
proto.constructor = function(a,b,c,d,e,f,g,h){
return new proto.initialize(a,b,c,d,e,f,g,h);
};
proto.constructor.prototype = proto.initialize.prototype = proto;
return proto.constructor;
};

221
node_modules/art/core/color.js generated vendored Normal file
View File

@@ -0,0 +1,221 @@
var colors = {
maroon: '#800000', red: '#ff0000', orange: '#ffA500', yellow: '#ffff00', olive: '#808000',
purple: '#800080', fuchsia: "#ff00ff", white: '#ffffff', lime: '#00ff00', green: '#008000',
navy: '#000080', blue: '#0000ff', aqua: '#00ffff', teal: '#008080',
black: '#000000', silver: '#c0c0c0', gray: '#808080'
};
var map = function(array, fn){
var results = [];
for (var i = 0, l = array.length; i < l; i++)
results[i] = fn(array[i], i);
return results;
};
var Color = function(color, type){
if (color.isColor){
this.red = color.red;
this.green = color.green;
this.blue = color.blue;
this.alpha = color.alpha;
} else {
var namedColor = colors[color];
if (namedColor){
color = namedColor;
type = 'hex';
}
switch (typeof color){
case 'string': if (!type) type = (type = color.match(/^rgb|^hsb|^hsl/)) ? type[0] : 'hex'; break;
case 'object': type = type || 'rgb'; color = color.toString(); break;
case 'number': type = 'hex'; color = color.toString(16); break;
}
color = Color['parse' + type.toUpperCase()](color);
this.red = color[0];
this.green = color[1];
this.blue = color[2];
this.alpha = color[3];
}
this.isColor = true;
};
var limit = function(number, min, max){
return Math.min(max, Math.max(min, number));
};
var listMatch = /([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,?\s*([-.\d]*\%?)/;
var hexMatch = /^#?([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{0,2})$/i;
Color.parseRGB = function(color){
return map(color.match(listMatch).slice(1), function(bit, i){
if (bit) bit = parseFloat(bit) * (bit[bit.length - 1] == '%' ? 2.55 : 1);
return (i < 3) ? Math.round(((bit %= 256) < 0) ? bit + 256 : bit) : limit(((bit === '') ? 1 : Number(bit)), 0, 1);
});
};
Color.parseHEX = function(color){
if (color.length == 1) color = color + color + color;
return map(color.match(hexMatch).slice(1), function(bit, i){
if (i == 3) return (bit) ? parseInt(bit, 16) / 255 : 1;
return parseInt((bit.length == 1) ? bit + bit : bit, 16);
});
};
Color.parseHSB = function(color){
var hsb = map(color.match(listMatch).slice(1), function(bit, i){
if (bit) bit = parseFloat(bit);
if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
else if (i < 3) return limit(Math.round(bit), 0, 100);
else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
});
var a = hsb[3];
var br = Math.round(hsb[2] / 100 * 255);
if (hsb[1] == 0) return [br, br, br, a];
var hue = hsb[0];
var f = hue % 60;
var p = Math.round((hsb[2] * (100 - hsb[1])) / 10000 * 255);
var q = Math.round((hsb[2] * (6000 - hsb[1] * f)) / 600000 * 255);
var t = Math.round((hsb[2] * (6000 - hsb[1] * (60 - f))) / 600000 * 255);
switch (Math.floor(hue / 60)){
case 0: return [br, t, p, a];
case 1: return [q, br, p, a];
case 2: return [p, br, t, a];
case 3: return [p, q, br, a];
case 4: return [t, p, br, a];
default: return [br, p, q, a];
}
};
Color.parseHSL = function(color){
var hsb = map(color.match(listMatch).slice(1), function(bit, i){
if (bit) bit = parseFloat(bit);
if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
else if (i < 3) return limit(Math.round(bit), 0, 100);
else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
});
var h = hsb[0] / 60;
var s = hsb[1] / 100;
var l = hsb[2] / 100;
var a = hsb[3];
var c = (1 - Math.abs(2 * l - 1)) * s;
var x = c * (1 - Math.abs(h % 2 - 1));
var m = l - c / 2;
var p = Math.round((c + m) * 255);
var q = Math.round((x + m) * 255);
var t = Math.round((m) * 255);
switch (Math.floor(h)){
case 0: return [p, q, t, a];
case 1: return [q, p, t, a];
case 2: return [t, p, q, a];
case 3: return [t, q, p, a];
case 4: return [q, t, p, a];
default: return [p, t, q, a];
}
};
var toString = function(type, array){
if (array[3] != 1) type += 'a';
else array.pop();
return type + '(' + array.join(', ') + ')';
};
Color.prototype = {
toHSB: function(array){
var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
var hue = 0, saturation = (delta != 0) ? delta / max : 0, brightness = max / 255;
if (saturation){
var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
if ((hue /= 6) < 0) hue++;
}
var hsb = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(brightness * 100), alpha];
return (array) ? hsb : toString('hsb', hsb);
},
toHSL: function(array){
var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
var hue = 0, saturation = (delta != 0) ? delta / (255 - Math.abs((max + min) - 255)) : 0, lightness = (max + min) / 512;
if (saturation){
var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
if ((hue /= 6) < 0) hue++;
}
var hsl = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(lightness * 100), alpha];
return (array) ? hsl : toString('hsl', hsl);
},
toHEX: function(array){
var a = this.alpha;
var alpha = ((a = Math.round((a * 255)).toString(16)).length == 1) ? a + a : a;
var hex = map([this.red, this.green, this.blue], function(bit){
bit = bit.toString(16);
return (bit.length == 1) ? '0' + bit : bit;
});
return (array) ? hex.concat(alpha) : '#' + hex.join('') + ((alpha == 'ff') ? '' : alpha);
},
toRGB: function(array){
var rgb = [this.red, this.green, this.blue, this.alpha];
return (array) ? rgb : toString('rgb', rgb);
}
};
Color.prototype.toString = Color.prototype.toRGB;
Color.hex = function(hex){
return new Color(hex, 'hex');
};
if (this.hex == null) this.hex = Color.hex;
Color.hsb = function(h, s, b, a){
return new Color([h || 0, s || 0, b || 0, (a == null) ? 1 : a], 'hsb');
};
if (this.hsb == null) this.hsb = Color.hsb;
Color.hsl = function(h, s, l, a){
return new Color([h || 0, s || 0, l || 0, (a == null) ? 1 : a], 'hsl');
};
if (this.hsl == null) this.hsl = Color.hsl;
Color.rgb = function(r, g, b, a){
return new Color([r || 0, g || 0, b || 0, (a == null) ? 1 : a], 'rgb');
};
if (this.rgb == null) this.rgb = Color.rgb;
Color.detach = function(color){
color = new Color(color);
return [Color.rgb(color.red, color.green, color.blue).toString(), color.alpha];
};
module.exports = Color;

282
node_modules/art/core/path.js generated vendored Normal file
View File

@@ -0,0 +1,282 @@
var Class = require('./class');
module.exports = Class({
initialize: function(path){
this.reset().push(path);
},
/* parser */
push: function(){
var p = Array.prototype.join.call(arguments, ' ')
.match(/[a-df-z]|[\-+]?(?:[\d\.]e[\-+]?|[^\s\-+,a-z])+/ig);
if (!p) return this;
var last, cmd = p[0], i = 1;
while (cmd){
switch (cmd){
case 'm': this.move(p[i++], p[i++]); break;
case 'l': this.line(p[i++], p[i++]); break;
case 'c': this.curve(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
case 's': this.curve(p[i++], p[i++], null, null, p[i++], p[i++]); break;
case 'q': this.curve(p[i++], p[i++], p[i++], p[i++]); break;
case 't': this.curve(p[i++], p[i++]); break;
case 'a': this.arc(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
case 'h': this.line(p[i++], 0); break;
case 'v': this.line(0, p[i++]); break;
case 'M': this.moveTo(p[i++], p[i++]); break;
case 'L': this.lineTo(p[i++], p[i++]); break;
case 'C': this.curveTo(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
case 'S': this.curveTo(p[i++], p[i++], null, null, p[i++], p[i++]); break;
case 'Q': this.curveTo(p[i++], p[i++], p[i++], p[i++]); break;
case 'T': this.curveTo(p[i++], p[i++]); break;
case 'A': this.arcTo(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
case 'H': this.lineTo(p[i++], this.penY); break;
case 'V': this.lineTo(this.penX, p[i++]); break;
case 'Z': case 'z': this.close(); break;
default: cmd = last; i--; continue;
}
last = cmd;
if (last == 'm') last = 'l';
else if (last == 'M') last = 'L';
cmd = p[i++];
}
return this;
},
/* utility methods */
reset: function(){
this.penX = this.penY = 0;
this.penDownX = this.penDownY = null;
this._pivotX = this._pivotY = 0;
this.onReset();
return this;
},
move: function(x,y){
this.onMove(this.penX, this.penY, this._pivotX = this.penX += (+x), this._pivotY = this.penY += (+y));
return this;
},
moveTo: function(x,y){
this.onMove(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
return this;
},
line: function(x,y){
return this.lineTo(this.penX + (+x), this.penY + (+y));
},
lineTo: function(x,y){
if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
this.onLine(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
return this;
},
curve: function(c1x, c1y, c2x, c2y, ex, ey){
var x = this.penX, y = this.penY;
return this.curveTo(
x + (+c1x), y + (+c1y),
c2x == null ? null : x + (+c2x),
c2y == null ? null : y + (+c2y),
ex == null ? null : x + (+ex),
ey == null ? null : y + (+ey)
);
},
curveTo: function(c1x, c1y, c2x, c2y, ex, ey){
var x = this.penX, y = this.penY;
if (c2x == null){
c2x = +c1x; c2y = +c1y;
c1x = (x * 2) - (this._pivotX || 0); c1y = (y * 2) - (this._pivotY || 0);
}
if (ex == null){
this._pivotX = +c1x; this._pivotY = +c1y;
ex = +c2x; ey = +c2y;
c2x = (ex + (+c1x) * 2) / 3; c2y = (ey + (+c1y) * 2) / 3;
c1x = (x + (+c1x) * 2) / 3; c1y = (y + (+c1y) * 2) / 3;
} else {
this._pivotX = +c2x; this._pivotY = +c2y;
}
if (this.penDownX == null){ this.penDownX = x; this.penDownY = y; }
this.onBezierCurve(x, y, +c1x, +c1y, +c2x, +c2y, this.penX = +ex, this.penY = +ey);
return this;
},
arc: function(x, y, rx, ry, outer, counterClockwise, rotation){
return this.arcTo(this.penX + (+x), this.penY + (+y), rx, ry, outer, counterClockwise, rotation);
},
arcTo: function(x, y, rx, ry, outer, counterClockwise, rotation){
ry = Math.abs(+ry || +rx || (+y - this.penY));
rx = Math.abs(+rx || (+x - this.penX));
if (!rx || !ry || (x == this.penX && y == this.penY)) return this.lineTo(x, y);
var tX = this.penX, tY = this.penY, clockwise = !+counterClockwise, large = !!+outer;
var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad);
x -= tX; y -= tY;
// Ellipse Center
var cx = cos * x / 2 + sin * y / 2,
cy = -sin * x / 2 + cos * y / 2,
rxry = rx * rx * ry * ry,
rycx = ry * ry * cx * cx,
rxcy = rx * rx * cy * cy,
a = rxry - rxcy - rycx;
if (a < 0){
a = Math.sqrt(1 - a / rxry);
rx *= a; ry *= a;
cx = x / 2; cy = y / 2;
} else {
a = Math.sqrt(a / (rxcy + rycx));
if (large == clockwise) a = -a;
var cxd = -a * cy * rx / ry,
cyd = a * cx * ry / rx;
cx = cos * cxd - sin * cyd + x / 2;
cy = sin * cxd + cos * cyd + y / 2;
}
// Rotation + Scale Transform
var xx = cos / rx, yx = sin / rx,
xy = -sin / ry, yy = cos / ry;
// Start and End Angle
var sa = Math.atan2(xy * -cx + yy * -cy, xx * -cx + yx * -cy),
ea = Math.atan2(xy * (x - cx) + yy * (y - cy), xx * (x - cx) + yx * (y - cy));
cx += tX; cy += tY;
x += tX; y += tY;
// Circular Arc
if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
this.onArc(
tX, tY, this._pivotX = this.penX = x, this._pivotY = this.penY = y,
cx, cy, rx, ry, sa, ea, !clockwise, rotation
);
return this;
},
counterArc: function(x, y, rx, ry, outer){
return this.arc(x, y, rx, ry, outer, true);
},
counterArcTo: function(x, y, rx, ry, outer){
return this.arcTo(x, y, rx, ry, outer, true);
},
close: function(){
if (this.penDownX != null){
this.onClose(this.penX, this.penY, this.penX = this.penDownX, this.penY = this.penDownY);
this.penDownX = null;
}
return this;
},
/* overridable handlers */
onReset: function(){
},
onMove: function(sx, sy, ex, ey){
},
onLine: function(sx, sy, ex, ey){
this.onBezierCurve(sx, sy, sx, sy, ex, ey, ex, ey);
},
onBezierCurve: function(sx, sy, c1x, c1y, c2x, c2y, ex, ey){
var gx = ex - sx, gy = ey - sy,
g = gx * gx + gy * gy,
v1, v2, cx, cy, u;
cx = c1x - sx; cy = c1y - sy;
u = cx * gx + cy * gy;
if (u > g){
cx -= gx;
cy -= gy;
} else if (u > 0 && g != 0){
cx -= u/g * gx;
cy -= u/g * gy;
}
v1 = cx * cx + cy * cy;
cx = c2x - sx; cy = c2y - sy;
u = cx * gx + cy * gy;
if (u > g){
cx -= gx;
cy -= gy;
} else if (u > 0 && g != 0){
cx -= u/g * gx;
cy -= u/g * gy;
}
v2 = cx * cx + cy * cy;
if (v1 < 0.01 && v2 < 0.01){
this.onLine(sx, sy, ex, ey);
return;
}
// Avoid infinite recursion
if (isNaN(v1) || isNaN(v2)){
throw new Error('Bad input');
}
// Split curve
var s1x = (c1x + c2x) * 0.5, s1y = (c1y + c2y) * 0.5,
l1x = (c1x + sx) * 0.5, l1y = (c1y + sy) * 0.5,
l2x = (l1x + s1x) * 0.5, l2y = (l1y + s1y) * 0.5,
r2x = (ex + c2x) * 0.5, r2y = (ey + c2y) * 0.5,
r1x = (r2x + s1x) * 0.5, r1y = (r2y + s1y) * 0.5,
l2r1x = (l2x + r1x) * 0.5, l2r1y = (l2y + r1y) * 0.5;
// TODO: Manual stack if necessary. Currently recursive without tail optimization.
this.onBezierCurve(sx, sy, l1x, l1y, l2x, l2y, l2r1x, l2r1y);
this.onBezierCurve(l2r1x, l2r1y, r1x, r1y, r2x, r2y, ex, ey);
},
onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
// Inverse Rotation + Scale Transform
var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad),
xx = cos * rx, yx = -sin * ry,
xy = sin * rx, yy = cos * ry;
// Bezier Curve Approximation
var arc = ea - sa;
if (arc < 0 && !ccw) arc += Math.PI * 2;
else if (arc > 0 && ccw) arc -= Math.PI * 2;
var n = Math.ceil(Math.abs(arc / (Math.PI / 2))),
step = arc / n,
k = (4 / 3) * Math.tan(step / 4);
var x = Math.cos(sa), y = Math.sin(sa);
for (var i = 0; i < n; i++){
var cp1x = x - k * y, cp1y = y + k * x;
sa += step;
x = Math.cos(sa); y = Math.sin(sa);
var cp2x = x + k * y, cp2y = y - k * x;
this.onBezierCurve(
sx, sy,
cx + xx * cp1x + yx * cp1y, cy + xy * cp1x + yy * cp1y,
cx + xx * cp2x + yx * cp2y, cy + xy * cp2x + yy * cp2y,
(sx = (cx + xx * x + yx * y)), (sy = (cy + xy * x + yy * y))
);
}
},
onClose: function(sx, sy, ex, ey){
this.onLine(sx, sy, ex, ey);
}
});

149
node_modules/art/core/transform.js generated vendored Normal file
View File

@@ -0,0 +1,149 @@
var Class = require('./class');
function Transform(xx, yx, xy, yy, x, y){
if (xx && typeof xx == 'object'){
yx = xx.yx; yy = xx.yy; y = xx.y;
xy = xx.xy; x = xx.x; xx = xx.xx;
}
this.xx = xx == null ? 1 : xx;
this.yx = yx || 0;
this.xy = xy || 0;
this.yy = yy == null ? 1 : yy;
this.x = (x == null ? this.x : x) || 0;
this.y = (y == null ? this.y : y) || 0;
this._transform();
return this;
};
module.exports = Class({
initialize: Transform,
_transform: function(){},
xx: 1, yx: 0, x: 0,
xy: 0, yy: 1, y: 0,
transform: function(xx, yx, xy, yy, x, y){
var m = this;
if (xx && typeof xx == 'object'){
yx = xx.yx; yy = xx.yy; y = xx.y;
xy = xx.xy; x = xx.x; xx = xx.xx;
}
if (!x) x = 0;
if (!y) y = 0;
return this.transformTo(
m.xx * xx + m.xy * yx,
m.yx * xx + m.yy * yx,
m.xx * xy + m.xy * yy,
m.yx * xy + m.yy * yy,
m.xx * x + m.xy * y + m.x,
m.yx * x + m.yy * y + m.y
);
},
transformTo: Transform,
translate: function(x, y){
return this.transform(1, 0, 0, 1, x, y);
},
move: function(x, y){
this.x += x || 0;
this.y += y || 0;
this._transform();
return this;
},
scale: function(x, y){
if (y == null) y = x;
return this.transform(x, 0, 0, y, 0, 0);
},
rotate: function(deg, x, y){
if (x == null || y == null){
x = (this.left || 0) + (this.width || 0) / 2;
y = (this.top || 0) + (this.height || 0) / 2;
}
var rad = deg * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
this.transform(1, 0, 0, 1, x, y);
var m = this;
return this.transformTo(
cos * m.xx - sin * m.yx,
sin * m.xx + cos * m.yx,
cos * m.xy - sin * m.yy,
sin * m.xy + cos * m.yy,
m.x,
m.y
).transform(1, 0, 0, 1, -x, -y);
},
moveTo: function(x, y){
var m = this;
return this.transformTo(m.xx, m.yx, m.xy, m.yy, x, y);
},
rotateTo: function(deg, x, y){
var m = this;
var flip = m.yx / m.xx > m.yy / m.xy ? -1 : 1;
if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = -flip;
return this.rotate(deg - Math.atan2(flip * m.yx, flip * m.xx) * 180 / Math.PI, x, y);
},
scaleTo: function(x, y){
// Normalize
var m = this;
var h = Math.sqrt(m.xx * m.xx + m.yx * m.yx);
m.xx /= h; m.yx /= h;
h = Math.sqrt(m.yy * m.yy + m.xy * m.xy);
m.yy /= h; m.xy /= h;
return this.scale(x, y);
},
resizeTo: function(width, height){
var w = this.width, h = this.height;
if (!w || !h) return this;
return this.scaleTo(width / w, height / h);
},
/*
inverse: function(){
var a = this.xx, b = this.yx,
c = this.xy, d = this.yy,
e = this.x, f = this.y;
if (a * d - b * c == 0) return null;
return new Transform(
d/(a * d-b * c), b/(b * c-a * d),
c/(b * c-a * d), a/(a * d-b * c),
(d * e-c * f)/(b * c-a * d), (b * e-a * f)/(a * d-b * c)
);
},
*/
inversePoint: function(x, y){
var a = this.xx, b = this.yx,
c = this.xy, d = this.yy,
e = this.x, f = this.y;
var det = b * c - a * d;
if (det == 0) return null;
return {
x: (d * (e - x) + c * (y - f)) / det,
y: (a * (f - y) + b * (x - e)) / det
};
},
point: function(x, y){
var m = this;
return {
x: m.xx * x + m.xy * y + m.x,
y: m.yx * x + m.yy * y + m.y
};
}
});