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

16
node_modules/art/shapes/ellipse.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
var Shape = require('./generic');
module.exports = Shape(function(width, height){
this.width = width;
this.height = height;
var rx = width / 2, ry = height / 2;
this.path
.move(0, ry)
.arc(width, 0, rx, ry)
.arc(-width, 0, rx, ry)
.close();
});

136
node_modules/art/shapes/font.js generated vendored Normal file
View File

@@ -0,0 +1,136 @@
var Shape = require('./generic');
var fonts = {};
var parseFontString = function(font){
var regexp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?)[ptexm\%]*(?:\s*\/.*?)?\s+)?\s*\"?([^\"]*)/i,
match = regexp.exec(font);
return {
fontFamily: match[3],
fontSize: match[2],
fontStyle: (/italic/.exec(match[1]) || ''),
fontWeight: (/bold/.exec(match[1]) || '')
};
};
var Font = Shape(function(text, font, alignment){
if (typeof font == 'string') font = parseFontString(font);
if (font) this.font = font; else font = this.font;
var family = font.fontFamily || font['font-family'],
weight = font.fontWeight || font['font-weight'] || 'normal',
style = font.fontStyle || font['font-style'] || 'normal',
size = parseFloat(font.fontSize || font['font-size'] || font.size);
font = font.glyphs ? font : fonts[weight + style + family];
if (!font) throw new Error('The specified font has not been found.');
var scale = size / font.face['units-per-em'];
var width = 0, height = size, path = '', row = '';
var x = 0, y = scale * font.face.ascent || size - (scale * font.face.descent);
var regexp = /([mclrvxe])([^a-z]*)/g, match;
// TODO: Refactor to use SVG paths as the source
var cx = 0, cy = 0, fx = 0, fy = 0;
for (var i = 0, l = text.length; i < l; ++i){
if (text.charAt(i) == '\n'){
if (alignment == 'end' || alignment == 'right'){
cx -= x;
path += 'm' + (-x) + ',0';
}
if (alignment == 'middle' || alignment == 'center'){
cx -= x / 2;
path += 'm' + (-x / 2) + ',0';
}
path += row;
path += 'm' + (-cx) + ',' + (-cy);
cx = cy = 0;
row = '';
x = 0;
y += size * 1.1;
height += size * 1.1;
continue;
}
var glyph = font.glyphs[text.charAt(i)] || font.glyphs.missing || font.glyphs[' '];
if (!glyph) continue;
var w = scale * (glyph.w || font.w);
if (glyph.d){
var s = scale;
if (glyph.path){
var parts = glyph.path;
} else {
var parts = [], index = -1,
bits = ('m' + glyph.d + 'x').match(/[a-df-z]|[\-+]?(?:[\d\.]e[\-+]?|[^\s\-+,a-z])+/ig),
part;
for (var j = 0, k = bits.length; j < k; j++){
var bit = bits[j];
if (bit.match(/^[a-z]/i)){
parts[++index] = part = [bit];
} else {
part.push(Number(bit));
}
}
glyph.path = parts;
}
for (var j = 0; j < parts.length; j++){
var c = Array.prototype.slice.call(parts[j]), f = c.shift();
switch (f){
case 'l':
row += 'l ' + (x + (s * c[0]) - cx) + ',' + (y + (s * c[1]) - cy);
//row += 'L ' + (x + (s * c[0])) + ',' + (y + (s * c[1]));
cx = x + (s * c[0]); cy = y + (s * c[1]);
break;
case 'c':
row += 'c ' + (x + s * c[0] - cx) + ',' + (y + s * c[1] - cy) + ',' + (x + s * c[2] - cx) + ',' + (y + s * c[3] - cy) + ',' + (x + s * c[4] - cx) + ',' + (y + s * c[5] - cy);
cx = x + (s * c[4]); cy = y + (s * c[5]);
break;
case 'v':
row += 'c ' + (s * c[0]) + ',' + (s * c[1]) + ',' + (s * c[2]) + ',' + (s * c[3]) + ',' + (s * c[4]) + ',' + (s * c[5]);
cx += (s * c[4]); cy += (s * c[5]);
break;
case 'r':
row += 'l ' + (s * c[0]) + ',' + (s * c[1]);
cx += (s * c[0]); cy += (s * c[1]);
break;
case 'm':
row += 'm ' + (x + (s * c[0]) - cx) + ',' + (y + (s * c[1]) - cy);
fx = cx = x + (s * c[0]);
fy = cy = y + (s * c[1]);
break;
case 'x':
row += 'z';
cx = fx;
cy = fy;
break;
}
}
}
x += w;
if (x > width) width = x;
}
if (alignment == 'end' || alignment == 'right') path += 'm' + (-x) + ',0';
if (alignment == 'middle' || alignment == 'center') path += 'm' + (-x / 2) + ',0';
path += row;
this.path.push(path);
this.width = width;
this.height = height;
});
Font.register = function(font){
var face = font.face,
family = face['font-family'],
weight = (face['font-weight'] > 500 ? 'bold' : 'normal'),
style = (face['font-stretch'] == 'oblique' || face['font-style'] == 'oblique' || face['font-style'] == 'italic' ? 'italic' : 'normal');
fonts[weight + style + family] = font;
return this;
};
module.exports = Font;

28
node_modules/art/shapes/generic.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
var Class = require('../core/class');
var Mode = require('../modes/current');
module.exports = function(drawFunction){
return Class(Mode.Shape, {
shape_initialize: Mode.Shape.prototype.initialize,
shape_draw: Mode.Shape.prototype.draw,
initialize: function(arg){
this.shape_initialize();
this.path = new Mode.Path();
if (arg != null) this.draw.apply(this, arguments);
},
draw: function(){
this.path.reset();
this._draw_function.apply(this, arguments);
this.shape_draw(this.path, this.width, this.height);
return this;
},
_draw_function: drawFunction
});
};

37
node_modules/art/shapes/pill.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var Shape = require('./generic');
module.exports = Shape(function(width, height){
this.width = width;
this.height = height;
var path = this.path;
if (width < 0){
path.move(width, 0);
width = -width;
}
if (height < 0){
path.move(0, height);
height = -height;
}
if (width < height){
var r = width / 2;
path.move(0, r)
.arc(width, 0, r)
.line(0, height - width)
.arc(-width, 0, r)
.line(0, width - height);
} else {
var r = height / 2;
path.move(r, 0)
.line(width - height, 0)
.arc(0, height, r)
.line(height - width, 0)
.arc(0, -height, r);
}
path.close();
});

45
node_modules/art/shapes/rectangle.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
var Shape = require('./generic');
module.exports = Shape(function(width, height, radius){
this.width = width;
this.height = height;
var path = this.path;
if (!radius){
path.move(0, 0).line(width, 0).line(0, height).line(-width, 0).line(0, -height);
} else {
if (typeof radius == 'number') radius = [radius, radius, radius, radius];
var tl = radius[0], tr = radius[1], br = radius[2], bl = radius[3];
if (tl < 0) tl = 0;
if (tr < 0) tr = 0;
if (bl < 0) bl = 0;
if (br < 0) br = 0;
path.move(0, tl);
if (width < 0) path.move(width, 0);
if (height < 0) path.move(0, height);
if (tl > 0) path.arc(tl, -tl);
path.line(Math.abs(width) - (tr + tl), 0);
if (tr > 0) path.arc(tr, tr);
path.line(0, Math.abs(height) - (tr + br));
if (br > 0) path.arc(-br, br);
path.line(- Math.abs(width) + (br + bl), 0);
if (bl > 0) path.arc(-bl, -bl);
path.line(0, - Math.abs(height) + (bl + tl));
}
path.close();
});

35
node_modules/art/shapes/wedge.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var Shape = require('./generic');
module.exports = Shape(function(innerRadius, outerRadius, startAngle, endAngle){
var circle = Math.PI * 2,
radiansPerDegree = Math.PI / 180,
sa = startAngle * radiansPerDegree % circle || 0,
ea = endAngle * radiansPerDegree % circle || 0,
ir = Math.min(innerRadius || 0, outerRadius || 0),
or = Math.max(innerRadius || 0, outerRadius || 0),
a = sa > ea ? circle - sa + ea : ea - sa;
this.width = this.height = or * 2;
var path = this.path;
if (a >= circle){
path.move(0, or).arc(or * 2, 0, or).arc(-or * 2, 0, or);
if (ir) path.move(or - ir, 0).counterArc(ir * 2, 0, ir).counterArc(-ir * 2, 0, ir);
} else {
var ss = Math.sin(sa), es = Math.sin(ea),
sc = Math.cos(sa), ec = Math.cos(ea),
ds = es - ss, dc = ec - sc, dr = ir - or,
large = a > Math.PI;
path.move(or + or * ss, or - or * sc).arc(or * ds, or * -dc, or, or, large).line(dr * es, dr * -ec);
if (ir) path.counterArc(ir * -ds, ir * dc, ir, ir, large);
}
path.close();
});