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

12
node_modules/art/.gitmodules generated vendored Normal file
View File

@@ -0,0 +1,12 @@
[submodule "lib/sheet.js"]
path = lib/sheet.js
url = git://github.com/subtleGradient/Sheet.js.git
[submodule "lib/link"]
path = lib/link
url = git://github.com/sebmarkbage/link.js.git
[submodule "lib/slick"]
path = lib/slick
url = git://github.com/mootools/slick.git
[submodule "lib/ast-js"]
path = lib/ast-js
url = git://github.com/sebmarkbage/ast-js.git

27
node_modules/art/README.md generated vendored Normal file
View File

@@ -0,0 +1,27 @@
# ART
ART is a retained mode vector drawing API designed for multiple output modes.
There's also a built-in SVG parser. It uses Node style CommonJS modules.
The first line in your program should select rendering mode by requiring either:
- __art/modes/canvas__ - HTML5 Canvas
- __art/modes/svg__ - SVG for modern browsers and vector tools
- __art/modes/vml__ - VML for Internet Explorer or Office
- __art/modes/script__ - Code generation for ART modules
- __art/modes/dom__ - SVG or VML depending on environment
- __art/modes/fast__ - Canvas, SVG or VML depending on environment
These modules exposes four core rendering classes:
- __Surface__ - Required rectangular rendering area. Container for the rest.
- __Group__ - Container for Shapes, Text or other Groups.
- __Shape__ - Fill and/or stroke an arbitrary vector path.
- __Text__ - Fill and/or stroke text content rendered using native fonts.
There are also helper classes to work with vector paths, 3x3 transformation
matrices, colors, morphing, common shapes etc.
#Demos
[See ./demos](./demos)

3
node_modules/art/_config.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
exclude: ['index.html.markdown']
keep_files: ['.js']
markdown: kramdown

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
};
}
});

16
node_modules/art/dom/container.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
var Class = require('../core/class');
module.exports = Class({
grab: function(){
for (var i = 0; i < arguments.length; i++) arguments[i].inject(this);
return this;
},
empty: function(){
var node;
while (node = this.firstChild) node.eject();
return this;
}
});

116
node_modules/art/dom/dummy.js generated vendored Normal file
View File

@@ -0,0 +1,116 @@
var Class = require('../core/class');
module.exports = Class({
// placement
_resetPlacement: function(){
var container = this.parentNode;
if (container){
var previous = this.previousSibling, next = this.nextSibling;
if (previous){
previous.nextSibling = next;
} else {
container.firstChild = next;
}
if (next){
next.previousSibling = previous;
} else {
container.lastChild = this.previousSibling;
}
}
this.previousSibling = null;
this.nextSibling = null;
this.parentNode = null;
return this;
},
inject: function(container){
this._resetPlacement();
var last = container.lastChild;
if (last){
last.nextSibling = this;
this.previousSibling = last;
} else {
container.firstChild = this;
}
container.lastChild = this;
this.parentNode = container;
this._place();
return this;
},
injectBefore: function(sibling){
this._resetPlacement();
var container = sibling.parentNode;
if (!container) return this;
var previous = sibling.previousSibling;
if (previous){
previous.nextSibling = this;
this.previousSibling = previous;
} else {
container.firstChild = this;
}
sibling.previousSibling = this;
this.nextSibling = sibling;
this.parentNode = container;
this._place();
return this;
},
eject: function(){
this._resetPlacement();
this._place();
return this;
},
_place: function(){},
// events
dispatch: function(event){
var events = this._events,
listeners = events && events[event.type];
if (listeners){
listeners = listeners.slice(0);
for (var i = 0, l = listeners.length; i < l; i++){
var fn = listeners[i], result;
if (typeof fn == 'function')
result = fn.call(this, event);
else
result = fn.handleEvent(event);
if (result === false) event.preventDefault();
}
}
if (this.parentNode && this.parentNode.dispatch){
this.parentNode.dispatch(event);
}
},
subscribe: function(type, fn, bind){
if (typeof type != 'string'){ // listen type / fn with object
var subscriptions = [];
for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
return function(){ // unsubscribe
for (var i = 0, l = subscriptions.length; i < l; i++)
subscriptions[i]();
return this;
};
} else { // listen to one
var bound = typeof fn === 'function' ? fn.bind(bind || this) : fn,
events = this._events || (this._events = {}),
listeners = events[type] || (events[type] = []);
listeners.push(bound);
return function(){
// unsubscribe
for (var i = 0, l = listeners.length; i < l; i++){
if (listeners[i] === bound){
listeners.splice(i, 1);
break;
}
}
}
}
}
});

83
node_modules/art/dom/native.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
var Class = require('../core/class');
function elementFrom(node){
if (node.toElement) return node.toElement();
if (node.getDOMNode) return node.getDOMNode();
if (node.getNode) return node.getNode();
return node;
}
module.exports = Class({
// conventions
toElement: function(){
return this.element;
},
getDOMNode: function(){
return this.toElement();
},
getNode: function(){
return this.toElement();
},
// placement
inject: function(container){
(container.containerElement || elementFrom(container))
.appendChild(this.element);
return this;
},
injectBefore: function(sibling){
var element = elementFrom(sibling);
element.parentNode.insertBefore(this.element, element);
return this;
},
eject: function(){
var element = this.element, parent = element.parentNode;
if (parent) parent.removeChild(element); // TODO: VML Nodes are dead after being ejected
return this;
},
// events
subscribe: function(type, fn, bind){
if (typeof type != 'string'){ // listen type / fn with object
var subscriptions = [];
for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
return function(){ // unsubscribe
for (var i = 0, l = subscriptions.length; i < l; i++)
subscriptions[i]();
return this;
};
} else { // listen to one
if (!bind) bind = this;
var bound;
if (typeof fn === 'function'){
bound = fn.bind ? fn.bind(bind)
: function(){ return fn.apply(bind, arguments); };
} else {
bound = fn;
}
var element = this.element;
if (element.addEventListener){
element.addEventListener(type, bound, false);
return function(){ // unsubscribe
element.removeEventListener(type, bound, false);
return this;
};
} else {
element.attachEvent('on' + type, bound);
return function(){ // unsubscribe
element.detachEvent('on' + type, bound);
return this;
};
}
}
}
});

32
node_modules/art/dom/shadow.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
var Class = require('../core/class');
var Dummy = require('./dummy');
var Native = require('./native');
module.exports = Class(Dummy, Native, {
dummy_inject: Dummy.prototype.inject,
dummy_injectBefore: Dummy.prototype.injectBefore,
dummy_eject: Dummy.prototype.eject,
native_inject: Native.prototype.inject,
native_injectBefore: Native.prototype.injectBefore,
native_eject: Native.prototype.eject,
inject: function(container){
this.dummy_inject(container);
this.native_inject(container);
return this;
},
injectBefore: function(sibling){
this.dummy_injectBefore(sibling);
this.native_injectBefore(sibling);
return this;
},
eject: function(){
this.dummy_eject();
this.native_eject();
return this;
}
});

9
node_modules/art/index.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
var MODE = require('./modes/current');
MODE.Rectangle = require('./shapes/rectangle');
MODE.Pill = require('./shapes/pill');
MODE.Ellipse = require('./shapes/ellipse');
MODE.Wedge = require('./shapes/wedge');
if (!MODE.Font) MODE.Font = require('./shapes/font');
MODE.Transform = require('./core/transform');
MODE.Color = require('./core/color');
module.exports = MODE;

33
node_modules/art/index.md generated vendored Normal file
View File

@@ -0,0 +1,33 @@
------
# Welcome to [ART](https://github.com/sebmarkbage/art) homepage
### Here\'s something you might find useful:
#### [Demos](demos)
+ [apidump](demos/apidump)
+ [codegen](demos/codegen)
+ [gradients](demos/gradients)
+ [images](demos/images)
+ [morph](demos/morph)
+ [objectmodel](demos/objectmodel)
+ [opacity](demos/opacity)
+ [paths](demos/paths)
+ [svgconverter](demos/svgconverter)
+ [svgviewer](demos/svgviewer)
#### [Docs](docs)
+ [ART](docs/ART/ART.html)
- [ART.Group](docs/ART/ART.Group.html)
- [ART.Path](docs/ART/ART.Path.html)
- [ART.Shape](docs/ART/ART.Shape.html)
- [ART.Transform](docs/ART/ART.Transform.html)
+ **Modes**
- [ART.Base](docs/Modes/ART.Base.html)
- [ART.SVG](docs/Modes/ART.SVG.html)
- [ART.VML](docs/Modes/ART.VML.html)
+ **Shapes**
- [ART.Font](docs/Shapes/ART.Font.html)
- [ART.Shapes](docs/Shapes/ART.Shapes.html)
- [ART.Text](docs/Shapes/ART.Text.html)

95
node_modules/art/lib/Sheet.Cascade.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
var Slick = require('./slick/Source/slick').Slick;
var CSS = require('./sheet.js/Source/SheetParser.CSS').SheetParser.CSS;
function calculateSpecificity(expression){
var specificity = 0;
for (var i = 0, l = expression.length; i < l; i++){
var part = expression[i];
if (part.id) specificity += 10000;
if (part.classes) specificity += part.classes.length * 1000;
if (part.pseudos) specificity += part.pseudos.length * 1000;
if (part.attributes) specificity += part.attributes.length * 1000;
if (part.tag && part.tag != '*') specificity += 100;
}
return specificity;
};
function sortRules(rules){
rules.sort(function(a,b){
if (a.specificity < b.specificity)
return -1;
else if (a.specificity > b.specificity)
return 1;
return 0;
});
};
function nodeContent(node){
var n = node.firstChild, text = '';
while (n){
text += n.nodeValue;
n = n.nextSibling;
}
return text;
}
var SheetCascade = function(){
this.rules = [];
this.cssRules = [];
};
SheetCascade.prototype = {
addSheet: function(sheet){
var rules = sheet.cssRules || CSS.parse(sheet.innerHTML || nodeContent(sheet) || sheet);
for (var i = 0, l = rules.length; i < l; i++){
var rule = rules[i];
this.cssRules.push(rule);
this.addRule(rule.selectorText, rule.style);
}
},
addRule: function(selector, style){
var parsed = Slick.parse(selector);
if (!parsed) return;
var expressions = parsed.expressions;
for (var i = 0, l = expressions.length; i < l; i++){
var expression = expressions[i],
specificity = calculateSpecificity(expression) + this.rules.length;
this.rules.push({
specificity: specificity,
expression: expression,
style: style
});
}
this.sorted = false;
},
getStyle: function(node){
var style = {};
this.applyStyle(node, style);
return style;
},
applyStyle: function(node, targetStyle){
var rules = this.rules;
if (!this.sorted){ sortRules(rules); this.sorted = true; }
for (var i = 0, l = rules.length; i < l; i++){
var rule = rules[i];
if (Slick.match(node, { Slick: true, expressions: [rule.expression] })){
var ruleStyle = rule.style;
for (var name in ruleStyle) targetStyle[name] = ruleStyle[name];
}
}
var cssText = node.getAttribute('style');
if (cssText){
var inlineStyle = CSS.parse(cssText);
for (var name in inlineStyle) targetStyle[name] = inlineStyle[name];
}
}
};
exports.SheetCascade = SheetCascade;

22
node_modules/art/lib/ast-js/Demos/helloworld.html generated vendored Normal file
View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>HelloWorld.js</title>
</head>
<body>
<script>var require = function(){return module.exports;}, module={};</script>
<script src="../src/program.js"></script>
<script src="../src/statement.js"></script>
<script src="../src/expression.js"></script>
<script src="../src/block.js"></script>
<script src="../src/literal.js"></script>
<script src="../src/operator.js"></script>
<script src="../src/variable.js"></script>
<script src="../src/property.js"></script>
<script src="../src/assignment.js"></script>
<script src="../src/condition.js"></script>
<script src="../src/function.js"></script>
<script src="../src/call.js"></script>
<script src="helloworld.js"></script>
</body>
</html>

21
node_modules/art/lib/ast-js/Demos/helloworld.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
var a = new AST.Variable('astr');
var b = new AST.Variable('bstr');
var alertFn = new AST.Variable('alert');
var newFn = new AST.Function(
[a, b], null,
alertFn.call(a.add(b))
);
newFn.compile()('Hello', ' world');
var klass = new AST.Variable('Class').construct({
initialize: newFn
});
var ast = new AST(new AST.Variable('MyClass').assign(klass));
alert(ast.toString());

13
node_modules/art/lib/ast-js/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
AST.js
======
Provides an Abstract Syntax Tree (AST) to generate ECMAScript code.
TODO:
- Add parentheses around expressions when necessary
- Nice indented formatting with options
- Rename invalid or scope colliding variable names
- Escape dangerous characters in regular expression literals
- Statements: for, while, do, switch, with, delete, typeof, instanceof
- Comments
- Lexical parser

13
node_modules/art/lib/ast-js/ast.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
var AST = require('./src/program');
require('./src/statement');
require('./src/expression');
require('./src/block');
require('./src/literal');
require('./src/operator');
require('./src/variable');
require('./src/property');
require('./src/assignment');
require('./src/condition');
require('./src/function');
require('./src/call');
module.exports = AST;

21
node_modules/art/lib/ast-js/license.txt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2010 Calyptus Life AB <http://calyptus.eu>
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.

75
node_modules/art/lib/ast-js/src/assignment.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
var AST = require('./program');
var err = 'Assignment is only possible on variables or properties.',
posterr = 'Only the literal 1 is possible for post assignments.',
assignableOps = /[\+\-\*\/\%]/;
AST.Assignment = function(left, right){
if (!(left instanceof AST.Variable || left instanceof AST.Property)) throw new Error(err);
this.left = left;
this.right = AST.Expression(right);
};
AST.Assignment.prototype = new AST.Expression();
AST.Assignment.prototype.writeTo = function(writer, format){
var left = this.left, right = this.right;
left.writeTo(writer, format);
if (right instanceof AST.Operator && right.left === left && assignableOps.test(right.operator)){
if (right.right instanceof AST.Literal && right.right.value == 1){
if (right.operator == '+'){
writer('++');
return;
} else if (right.operator == '-'){
writer('--');
return;
}
}
writer(' ' + right.operator + '= ');
right = right.right;
} else {
writer(' = ');
}
right.writeTo(writer, format);
};
AST.PostAssignment = function(left, right, operator){
if (!(left instanceof AST.Variable || left instanceof AST.Property)) throw new Error(err);
this.left = left;
this.operator = operator;
this.right = AST.Expression(right);
if (!(this.right instanceof AST.Operator) || this.right.left !== left || !(this.right.right instanceof AST.Literal) || this.right.right.value != 1) throw new Error(posterr);
}
AST.PostAssignment.prototype = new AST.Expression();
AST.PostAssignment.prototype.writeTo = function(writer, format){
this.expression.writeTo(writer, format);
writer(this.operator + this.operator);
};
AST.Expression.prototype.assignTo = function(expr){
return new AST.Assignment(expr, this);
};
AST.Variable.prototype.assign = AST.Property.prototype.assign = function(expr){
return new AST.Assignment(this, expr);
};
AST.Variable.prototype.increment = AST.Property.prototype.increment = function(){
return new AST.Assignment(this, new AST.Add(this, 1));
};
AST.Variable.prototype.decrement = AST.Property.prototype.decrement = function(){
return new AST.Assignment(this, new AST.Subtract(this, 1));
};
AST.Variable.prototype.postIncrement = AST.Property.prototype.postIncrement = function(){
return new AST.PostAssignment(this, new AST.Add(this, 1));
};
AST.Variable.prototype.postDecrement = AST.Property.prototype.postDecrement = function(){
return new AST.PostAssignment(this, new AST.Subtract(this, 1));
};

46
node_modules/art/lib/ast-js/src/block.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var AST = require('./program');
AST.Block = function(obj){
if (this instanceof AST.Block){
if (Object.prototype.toString.call(obj) == '[object Array]')
this.statements = Array.prototype.slice.call(obj);
else
this.statements = Array.prototype.slice.call(arguments);
return;
}
if (obj instanceof AST.Block) return obj;
var block = new AST.Block();
if (Object.prototype.toString.call(obj) == '[object Array]')
block.statements = Array.prototype.slice.call(obj);
else
block.statements = [obj];
return block;
};
AST.Block.prototype = {
writeTo: function(writer, format, curly){
var body = this.statements;
if (!body || !body.length) return;
for (var i = 0, l = body.length; i < l; i++){
var expr = body[i];
if (!(expr instanceof AST.Statement)) body[i] = expr = new AST.Literal(expr);
if (expr instanceof AST.Assignment && expr.left instanceof AST.Variable) writer('var '); // Temp hack - breaks sometimes
expr.writeTo(writer, format);
writer(';\n');
}
},
toString: function(format){
var output = [];
this.writeTo(function(str){
output.push(str);
}, format);
return output.join('');
}
};
AST.prototype = AST.Block.prototype;

43
node_modules/art/lib/ast-js/src/call.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
var AST = require('./program');
AST.Call = function(expr, args){
this.expression = AST.Expression(expr);
var l = args ? args.length : 0;
this.arguments = new Array(l);
for (var i = 0; i < l; i++) this.arguments[i] = AST.Expression(args[i]);
};
AST.Call.prototype = new AST.Expression();
AST.Call.prototype.writeTo = function(write, format){
this.expression.writeTo(write, format);
write('(');
var args = this.arguments;
if (args.length > 0){
args[0].writeTo(write, format);
for (var i = 1, l = args.length; i < l; i++){
write(', ');
args[i].writeTo(write, format);
}
}
write(')');
};
AST.New = function(){
AST.Call.apply(this, arguments);
};
AST.New.prototype = new AST.Call();
AST.New.prototype.writeTo = function(write, format){
write('new ');
AST.Call.prototype.writeTo.call(this, write, format);
};
AST.Expression.prototype.call = function(){
return new AST.Call(this, arguments);
};
AST.Expression.prototype.construct = function(){
return new AST.New(this, arguments);
};

36
node_modules/art/lib/ast-js/src/condition.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
var AST = require('./program');
AST.Ternary = function(condition, then, els){
this.condition = AST.Expression(condition);
this.then = AST.Expression(then);
this.els = AST.Expression(els);
};
AST.Ternary.prototype = new AST.Expression();
AST.Ternary.prototype.writeTo = function(write, format){
this.condition.writeTo(write, format);
write(' ? ');
this.then.writeTo(write, format);
write(' : ');
this.els.writeTo(write, format);
};
AST.If = function(condition, then, els){
this.condition = condition;
this.then = then;
this.els = els;
};
AST.If.prototype = new AST.Statement();
AST.If.prototype.writeTo = function(write, format){
write('if (');
this.condition.writeTo(write, format);
write(')');
this.then.writeTo(write, format);
if (this.els){
write(' else ');
this.els.writeTo(write, format);
}
};

9
node_modules/art/lib/ast-js/src/expression.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
var AST = require('./program');
AST.Expression = function(obj){
if (arguments.length == 0) return;
if (obj && typeof obj.toExpression == 'function') obj = obj.toExpression();
return obj instanceof AST.Expression ? obj : new AST.Literal(obj);
};
AST.Expression.prototype = new AST.Statement();

44
node_modules/art/lib/ast-js/src/function.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
var AST = require('./program');
AST.Function = function(name, args, variables, statements){
if (typeof name != 'string'){
statements = variables;
variables = args;
args = name;
name = null;
}
if (statements instanceof AST.Expression) statements = new AST.Return(statements);
statements = AST.Block(statements);
this.name = name;
this.arguments = args;
this.statements = statements;
this.variables = variables;
};
AST.Function.prototype = new AST.Expression();
AST.Function.prototype.writeTo = function(write, format){
write(this.name ? 'function ' + this.name + '(' : 'function(');
if (this.arguments){
for (var i = 0, l = this.arguments.length; i < l; i++){
if (i > 0) write(', ');
write(this.arguments[i].name);
}
}
write('){\n');
this.statements.writeTo(write, format);
write('}');
};
AST.Function.prototype.compile = function(){
var l = this.arguments.length,
args = new Array(l + 1),
body = [];
for (var i = 0; i < l; i++) args[i] = this.arguments[i].name;
this.statements.writeTo(function(str){ body.push(str); });
args[l] = body.join('');
return Function.apply(Function, args);
};

75
node_modules/art/lib/ast-js/src/literal.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
var AST = require('./program');
// Based on the MooTools JSON implementation
var specialChars = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'},
escapable = new RegExp('[\\\\"\\x00-\\x1f]', 'g'), // RegExp Literal doesn't work in ExtendScript
replaceChars = function(chr){
return specialChars[chr] || ('\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16));
},
encode = function(write, obj, format){
if (obj === null){
write('null');
return;
}
if (typeof obj === 'undefined'){
write('undefined');
return;
}
if (typeof obj.toExpression == 'function')
{
obj = obj.toExpression();
}
if (obj instanceof AST.Expression){
obj.writeTo(write, format);
return;
}
if (typeof obj == 'string'){
write('"' + obj.replace(escapable, replaceChars) + '"');
return;
}
if (typeof obj == 'object' && Object.prototype.toString.call(obj) != '[object RegExp]'){
var first = true;
if (Object.prototype.toString.call(obj) == '[object Array]'){
write('[');
for (var i = 0, l = obj.length; i < l; i++){
if (!Object.hasOwnProperty.call(obj, key)) continue;
if (first) first = false; else write(', ');
encode(write, obj, format);
}
write(']');
} else {
write('{');
for (var key in obj){
if (!Object.hasOwnProperty.call(obj, key)) continue;
if (first) first = false; else write(', ');
encode(write, key, format);
write(': ');
encode(write, obj[key], format);
}
write('}');
}
return;
}
write(String(obj));
};
AST.Literal = function(value){
this.value = value;
};
AST.Literal.prototype = new AST.Expression();
AST.Literal.prototype.writeTo = function(writer, format){
encode(writer, this.value, format);
};

72
node_modules/art/lib/ast-js/src/operator.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
var AST = require('./program');
AST.Operator = function(left, operator, right){
this.left = AST.Expression(left);
this.operator = operator;
this.right = AST.Expression(right);
};
AST.Operator.prototype = new AST.Expression();
AST.Operator.prototype.writeTo = function(write, format){
this.left.writeTo(write, format);
write(' ' + this.operator + ' ');
this.right.writeTo(write, format);
};
AST.Not = function(expr){
this.expression = expr;
};
AST.Not.prototype = new AST.Expression();
AST.Not.prototype.writeTo = function(write, format){
write('!');
this.expression.writeTo(write, format);
};
AST.Expression.prototype.not = function(){
return new AST.Not(this);
};
var operators = {
Equals: '==',
NotEquals: '!=',
StrictEquals: '===',
StrictNotEquals: '!==',
LessThan: '<',
MoreThan: '>',
LessThanOrEquals: '<=',
MoreThanOrEquals: '>=',
And: '&&',
Or: '||',
BitwiseAnd: '&',
BitwiseOr: '|',
BitwiseXor: '^',
LeftShift: '<<',
RightShift: '>>',
ZeroFillRightShift: '>>>',
Add: '+',
Subtract: '-',
Multiply: '*',
Divide: '/',
Mod: '%'
};
for (var key in operators) (function(name, cname, op){
AST[name] = function(left, right){
return new AST.Operator(left, op, right);
};
AST.Expression.prototype[cname] = function(expr){
return new AST[name](this, expr);
};
})(key, key.substr(0, 1).toLowerCase() + key.substr(1), operators[key]);

7
node_modules/art/lib/ast-js/src/program.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
var AST = function(){
return AST.Block.apply(this, arguments);
};
module.exports = AST;

26
node_modules/art/lib/ast-js/src/property.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var AST = require('./program');
AST.Property = function(expr, name){
this.expression = AST.Expression(expr);
this.name = AST.Expression(name);
};
AST.Property.prototype = new AST.Expression();
AST.Property.prototype.writeTo = function(write, format){
this.expression.writeTo(write, format);
if (this.name instanceof AST.Literal && this.name.value){
write('.');
write(String(this.name.value));
return;
}
write('[');
this.name.writeTo(write, format);
write(']');
};
AST.Expression.prototype.property = function(name){
return new AST.Property(this, name);
};

41
node_modules/art/lib/ast-js/src/statement.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
var AST = require('./program');
AST.Statement = function(label){
this.label = label;
};
AST.Statement.prototype = {
writeTo: function(compressed){ },
toString: function(compressed){
var output = [];
this.writeTo(function(str){
output.push(str);
}, compressed);
return output.join('');
}
};
AST.Return = function(expr){
if (arguments.length) this.expression = AST.Expression(expr);
};
AST.Return.prototype = new AST.Statement();
AST.Return.prototype.writeTo = function(write, format){
write('return');
if (!this.expression) return;
write(' ');
this.expression.writeTo(write, format);
};
AST.Break = function(){
};
AST.Break.prototype = new AST.Statement();
AST.Break.prototype.writeTo = function(write, format){
write('break');
};

20
node_modules/art/lib/ast-js/src/variable.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var AST = require('./program');
AST.Variable = function(name){
this.name = name;
};
AST.Variable.prototype = new AST.Expression();
AST.Variable.prototype.writeTo = function(write){
write(this.name);
};
AST.This = function(){
};
AST.This.prototype = new AST.Expression();
AST.This.prototype.writeTo = function(write){
write('this');
};

21
node_modules/art/lib/sheet.js/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2010 Thomas Aylott (SubtleGradient.com)
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.

59
node_modules/art/lib/sheet.js/README.md generated vendored Normal file
View File

@@ -0,0 +1,59 @@
Sheet.js by Thomas Aylott of MooTools
**STATE: well tested and stable**
This project uses semver.org standard version numbering.
Sheet.js
========
Parse CSS in JavaScript
* Test-first Development
* UniversalJS
* Zero dependencies
* DOM-less (no document necessary)
* CommonJS Modules 1.0+ with global fallback
* Browser support
* Implements W3C `document.styleSheets` API
* Implements WebKit CSS Animation API
Flexible Parsing
----------------
* Supports WebKit CSS Animation syntax
* Supports custom selectors, @rules, properties and values
* Supports nested rules
* Supports HTML style attribute values
i.e. CSS rules without the selectors and brackets
### Coming Soon…
* Support for custom CSS-like languages like the Sass 3.0 SCSS (Sassy CSS) and Less CSS
Basic Usage
-----------
ClientSide / Browser Usage
var myStyleSheet = new Sheet("#selector { color:blue }");
myStyleSheet.cssRules[0].style.color; // blue
// etc…
ServerSide / CommonJS Usage
require.paths.push('path/to/Sheet.js/Source'); // You might not need this
var Sheet = require('Sheet').Sheet;
var myStyleSheet = new Sheet("#selector { color:blue }");
myStyleSheet.cssRules[0].style.color; // blue
// etc…
Advanced ClientSide Namespacing
-------------------------------
If you need to move Sheet.js to its own custom namespace simply define a global `exports` object before loading Sheet.js. Sheet.js will see that object, assume that it's in a CommonJS environment and then attach itself onto that object instead of including itself globally.
You really shouldn't need to do that.
But isn't it great to know you could?

65
node_modules/art/lib/sheet.js/Source/Sheet.DOM.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
/*
---
name : Sheet.DOM
description : Sheet.DOM adds some handy stuff for working with the browser's native CSS capabilities.
authors : Thomas Aylott
copyright : © 2010 Thomas Aylott
license : MIT
provides : Sheet.DOM
...
*/
;(function(document,styleSheets){
if (typeof Sheet == 'undefined') Sheet = {}
if (Sheet.DOM == null) Sheet.DOM = {}
Sheet.DOM.createSheetNode = function(raw){
var sheet = Sheet.DOM.createSheet(raw)
var node = sheet.ownerNode
node.parentNode.removeChild(node)
return node
}
var UID = 0
Sheet.DOM.createSheet = createStyleSheetWithCSS
function createStyleSheetWithCSS(css){
var styleElement = document.createElement("style")
styleElement.appendChild(document.createTextNode(css))
styleElement.setAttribute('name', styleElement.id = "SheetRuler-" + +new Date)
document.getElementsByTagName('head')[0].appendChild(styleElement)
return styleElement.sheet || styleElement.styleSheet
}
Sheet.DOM.createStyle = function(raw){
var div = document.createElement('div')
div.innerHTML = '<p style="' + String_escapeHTML.call(raw) + '"></p>'
return div.firstChild.style
}
Sheet.DOM.createSheetStyle = function(raw){
var className = 'Sheet' + +new Date
var sheet = Sheet.DOM.createSheet("." + className + "{" + raw + "}")
return (sheet.rules || sheet.cssRules)[0].style
}
Sheet.DOM.createRule = function(selector,style){
var rule = selector + "{" + style + "}"
var sheet = Sheet.DOM.createSheet(rule)
var rules = sheet.rules || sheet.cssRules
return rules[rules.length - 1]
}
Sheet.DOM.createStyleWrapped = function(raw){
return {style:Sheet.DOM.createStyle(raw)}
}
function String_escapeHTML(){
return ('' + this).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/"/g,'&quot;')
}
}(document, document.styleSheets));

80
node_modules/art/lib/sheet.js/Source/Sheet.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
/*
---
name : Sheet
authors : Thomas Aylott
copyright : © 2010 Thomas Aylott
license : MIT
provides : Sheet
requires : SheetParser.CSS
...
*/
;(function(exports){
/*<depend>*/
var UNDEF = {undefined:1}
/*<CommonJS>*/
var SheetParser = UNDEF[typeof require]
? exports.SheetParser
: require('./SheetParser.CSS').SheetParser
exports.Sheet = Sheet
/*</CommonJS>*/
/*<debug>*/;if (!(!UNDEF[typeof SheetParser] && SheetParser.CSS)) throw new Error('Missing required function: "SheetParser.CSS"');/*</debug>*/
/*</depend>*/
Sheet.version = '1.0.2 dev'
function Sheet(cssText){
if (this instanceof Sheet) this.initialize(cssText)
else return Sheet.from(cssText)
}
Sheet.from = function(cssText){
return new Sheet(cssText)
}
Sheet.prototype = {
parser: SheetParser.CSS,
initialize: function(cssText){
this.cssText = cssText || ''
this.style = this.rules = this.cssRules = this.parser.parse(this.cssText)
var self = this
},
update: function(){
var cssText = '',
i = -1,
rule,
rules = this.style || this.rules || this.cssRules
while ((rule = rules[++i])){
if (typeof rule == 'object'){
// cssRule
if (this.update) rule.cssText = this.update.call(rule)
cssText += rule.cssText = rule.selectorText + '{' + rule.cssText + '}'
} else {
// style key/value
cssText += rule + ':'
cssText += rules[rule] + ';'
}
}
if (rules.selectorText)
return rules.cssText = rules.selectorText + '{' + cssText + '}'
return rules.cssText = cssText
}
}
Sheet.prototype.toString = Sheet.prototype.update
}(typeof exports != 'undefined' ? exports : this));

194
node_modules/art/lib/sheet.js/Source/SheetParser.CSS.js generated vendored Normal file
View File

@@ -0,0 +1,194 @@
/*
---
name : SheetParser.CSS
authors : Thomas Aylott
copyright : © 2010 Thomas Aylott
license : MIT
provides : SheetParser.CSS
requires : combineRegExp
...
*/
;(function(exports){
/*<depend>*/
var UNDEF = {undefined:1}
if (!exports.SheetParser) exports.SheetParser = {}
/*<CommonJS>*/
var combineRegExp = UNDEF[typeof require]
? exports.combineRegExp
: require('./sg-regex-tools').combineRegExp
var SheetParser = exports.SheetParser
/*</CommonJS>*/
/*<debug>*/;if (UNDEF[typeof combineRegExp]) throw new Error('Missing required function: "combineRegExp"');/*</debug>*/
/*</depend>*/
var CSS = SheetParser.CSS = {version: '1.0.2 dev'}
CSS.trim = trim
function trim(str){
// http://blog.stevenlevithan.com/archives/faster-trim-javascript
var str = (''+str).replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
CSS.camelCase = function(string){
return ('' + string).replace(camelCaseSearch, camelCaseReplace)
}
var camelCaseSearch = /-\D/g
function camelCaseReplace(match){
return match.charAt(1).toUpperCase()
}
CSS.parse = function(cssText){
var found
, rule
, rules = {length:0}
, keyIndex = -1
, regex = this.parser
, names = CSS.parser.names
, i,r,l
, ruleCount
rules.cssText = cssText = trim(cssText)
// strip comments
cssText = cssText.replace(CSS.comment, '');
regex.lastIndex = 0
while ((found = regex.exec(cssText))){
// avoid an infinite loop on zero-length keys
if (regex.lastIndex == found.index) ++ regex.lastIndex
// key:value
if (found[names._key]){
rules[rules.length ++] = found[names._key]
rules[found[names._key]] = found[names._value]
rules[CSS.camelCase(found[names._key])] = found[names._value]
continue
}
rules[rules.length++] = rule = {}
for (i = 0, l = names.length; i < l; ++i){
if (!(names[i-1] && found[i])) continue
rule[names[i-1]] = trim(found[i])
}
}
var atKey, atRule, atList, atI
for (i = 0, l = rules.length; i < l; ++i){
if (!rules[i]) continue
if (rules[i]._style_cssText){
rules[i].style = CSS.parse(rules[i]._style_cssText)
delete rules[i]._style_cssText
}
// _atKey/_atValue
if (atKey = rules[i]._atKey){
atKey = CSS.camelCase(atKey)
atRule = {length:0}
rules[i][atKey] = atRule
atRule["_source"] =
atRule[atKey + "Text"] = rules[i]._atValue
atList = ('' + rules[i]._atValue).split(/,\s*/)
for (atI = 0; atI < atList.length; ++atI){
atRule[atRule.length ++] = atList[atI]
}
rules[i].length = 1
rules[i][0] = atKey
delete rules[i]._atKey
delete rules[i]._atValue
}
if (rules[i].style)
for (ruleCount = -1, r = -1, rule; rule = rules[i].style[++r];){
if (typeof rule == 'string') continue
rules[i][r] = (rules[i].cssRules || (rules[i].cssRules = {}))[++ ruleCount] = rule
rules[i].cssRules.length = ruleCount + 1
rules[i].rules = rules[i].cssRules
}
}
return rules
}
var x = combineRegExp
var OR = '|'
;(CSS.at = x(/\s*@([-a-zA-Z0-9]+)\s+(([\w-]+)?[^;{]*)/))
.names=[ '_atKey', '_atValue', 'name']
CSS.atRule = x([CSS.at, ';'])
;(CSS.keyValue_key = x(/([-a-zA-Z0-9]+)/))
.names=[ '_key']
;(CSS.keyValue_value_end = x(/(?:;|(?=\})|$)/))
;(CSS.notString = x(/[^"']+/))
;(CSS.stringSingle = x(/"(?:[^"]|\\")*"/))
;(CSS.stringDouble = x(/'(?:[^']|\\')*'/))
;(CSS.string = x(['(?:',CSS.stringSingle ,OR, CSS.stringDouble,')']))
;(CSS.propertyValue = x([/[^;}]+/, CSS.keyValue_value_end]))
var rRound = "(?:[^()]|\\((?:[^()]|\\((?:[^()]|\\((?:[^()]|\\([^()]*\\))*\\))*\\))*\\))"
;(CSS.keyValue_value = x(
[
x(['((?:'
, CSS.stringSingle
, OR
, CSS.stringDouble
, OR
, "\\("+rRound+"*\\)"
, OR
, /[^;}()]/ // not a keyValue_value terminator
, ')*)'
])
, CSS.keyValue_value_end
])).names = ['_value']
;(CSS.keyValue = x([CSS.keyValue_key ,/\s*:\s*/, CSS.keyValue_value]))
;(CSS.comment = x(/\/\*\s*((?:[^*]|\*(?!\/))*)\s*\*\//))
.names=[ 'comment']
;(CSS.selector = x(['(',/\s*(\d+%)\s*/,OR,'(?:',/[^{}'"()]|\([^)]*\)|\[[^\]]*\]/,')+',')']))
.names=[ 'selectorText','keyText']
var rCurly = "(?:[^{}]|\\{(?:[^{}]|\\{(?:[^{}]|\\{(?:[^{}]|\\{[^{}]*\\})*\\})*\\})*\\})"
var rCurlyRound = "(?:[^{}()]+|\\{(?:[^{}()]+|\\{(?:[^{}()]+|\\{(?:[^{}()]+|\\{[^{}()]*\\})*\\})*\\})*\\})"
;(CSS.block = x("\\{\\s*((?:"+"\\("+rRound+"*\\)|"+rCurly+")*)\\s*\\}"))
.names=[ '_style_cssText']
CSS.selectorBlock = x([CSS.selector, CSS.block])
CSS.atBlock = x([CSS.at, CSS.block])
CSS.parser = x
(
[ x(CSS.comment)
, OR
, x(CSS.atBlock)
, OR
, x(CSS.atRule)
, OR
, x(CSS.selectorBlock)
, OR
, x(CSS.keyValue)
]
, 'cssText'
)
})(typeof exports != 'undefined' ? exports : this);

42
node_modules/art/lib/sheet.js/Source/sg-regex-tools.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
/*
---
name : sg-regex-tools
description : A few super-handy tools for messing around with RegExp
authors : Thomas Aylott
copyright : © 2010 Thomas Aylott
license : MIT
provides : [combineRegExp]
...
*/
;(function(exports){
exports.combineRegExp = function(regex, group){
if (regex.source) regex = [regex]
var names = [], i, source = '', this_source
for (i = 0; i < regex.length; ++i){ if (!regex[i]) continue
this_source = regex[i].source || ''+regex[i]
if (this_source == '|') source += '|'
else {
source += (group?'(':'') + this_source.replace(/\s/g,'') + (group?')':'')
if (group) names.push(group)
}
if (regex[i].names) names = names.concat(regex[i].names)
}
try {
regex = new RegExp(source,'gm')
}
catch (e){
throw new SyntaxError('Invalid Syntax: ' + source +'; '+ e)
}
// [key] → 1
for (i = -1; i < names.length; ++i) names[names[i]] = i + 1
// [1] → key
regex.names = names
return regex
}
}(typeof exports != 'undefined' ? exports : this))

55
node_modules/art/lib/sheet.js/package.json generated vendored Normal file
View File

@@ -0,0 +1,55 @@
{
"name": "Sheet",
"version": "1.0.2 dev",
"description": "100% DOM-less JavaScript implementation of the styleSheets, cssRule & style APIs \nSupports custom and browser-incompatible CSS syntax like nested rules",
"keywords": [
"CSS",
"CSSOM",
"styleSheet",
"cssRule",
"style",
"parse"
],
"authors": ["Thomas Aylott"],
"contributors": [
{
"name": "Thomas Aylott",
"email": "thomas@subtlegradient.com",
"web": "http://subtlegradient.com"
}
],
"copyright": "© 2010 Thomas Aylott",
"license": "MIT License",
"licenses": [
{
"type": "MIT",
"url": "http://creativecommons.org/licenses/MIT/"
}
],
"repositories": [{
"type": "git",
"url": "http://github.com/subtleGradient/Sheet.js/"
}],
"bugs": {
"web": "http://github.com/subtleGradient/Sheet.js/issues"
},
"directories": {
"src": "./Source",
"lib": "./Source",
"test": "./Test"
},
"sources": [
"Source/Sheet.js",
"Source/SheetParser.CSS.js"
],
"main":"./Source/Sheet"
}

6
node_modules/art/lib/slick/.gitmodules generated vendored Normal file
View File

@@ -0,0 +1,6 @@
[submodule "SlickSpec/Runner"]
path = SlickSpec/Runner
url = git://github.com/mootools/mootools-runner.git
[submodule "speed/benchmarkjs"]
path = speed/benchmarkjs
url = https://github.com/mathiasbynens/Benchmark.js.git

19
node_modules/art/lib/slick/Makefile generated vendored Normal file
View File

@@ -0,0 +1,19 @@
MODULES = 'Source/Slick.Parser.js' \
'Source/Slick.Finder.js'
FILE = 'slick.js'
test: setup kill_servers
@python -m SimpleHTTPServer 7777 &> /dev/null &
@open http://localhost:7777/SlickSpec/Runner/runner.html
kill_servers:
@ps aux | grep "SimpleHTTPServer 7777" | grep -v grep | awk '{ print $$2 }' | xargs kill -9 &> /dev/null
setup:
@git submodule update --init --recursive
build:
@cat ${MODULES} > ${FILE}

127
node_modules/art/lib/slick/README.md generated vendored Normal file
View File

@@ -0,0 +1,127 @@
(Slick is an official [MooTools](http://mootools.net) project)
Slick
=====
A new standalone selector engine that is totally slick!
-------------------------------------------------------
### Create your own custom pseudo-classes!
Ever want to make your own `:my-widget(rocks)` pseudoclass? Now you can!
### Use your own custom getAttribute code!
EG: Use MooTool's Element.get method or jQuery's $.attr
### Use your own parser!
Want to support XPATH selectors? JSONPath selectors? Pre-cached JS Object selctors? Just swap out the default parser and make your own.
### Use the parser by itself!
Want to integrate a CSS3 Selector parser into your own app somehow? Use the slick selector CSS3 parser by itself and get a JS Object representation of your selector.
---
Slick Selector Engine
=====================
Usage
-----
### `search` context for selector
Search this context for any nodes that match this selector.
Expects:
* context: document or node or array of documents or nodes
* selector: String or SelectorObject
* (**optional**) append: Array or Object with a push method
Returns: append argument or Array of 0 or more nodes
Slick.search(document, "#foo > bar.baz") → [<bar>, <bar>, <bar>]
Slick.search([<ol>, <ul>], "li > a") → [<a>, <a>, <a>]
Slick.search(document, "#foo > bar.baz", { push:function(){} }) → { push:function(){}, 0:<bar>, 1:<bar>, 2:<bar> }
### `find` first in context with selector or null
Find the first node in document that matches selector or null if none are found.
Expects:
* context: document or node or array of documents or nodes
* selector: String or SelectorObject
Returns: Element or null
Slick.find(document, "#foo > bar.baz") → <bar>
Slick.find(node, "#does-not-exist") → null
### node `match` selector?
Does this node match this selector?
Expects:
* node
* node, String or SelectorObject
Returns: true or false
Slick.match(<div class=rocks>, "div.rocks") → true
Slick.match(<div class=lame>, "div.rocks") → false
Slick.match(<div class=lame>, <div class=rocks>) → false
### context `contains` node?
Does this context contain this node? Is the context a parent of this node?
Expects:
* context: document or node
* node: node
Returns: true or false
Slick.contains(<ul>, <li>) → true
Slick.contains(<body>, <html>) → false
---
Slick CSS Selector Parser
=========================
Parse a CSS selector string into a JavaScript object
----------------------------------------------------
Usage
-----
### `parse` selector into object
Parse a CSS Selector String into a Selector Object.
Expects: String
Returns: SelectorObject
Slick.parse("#foo > bar.baz") → SelectorObject
SelectorObject format
---------------------
### `#foo > bar.baz`
{
"raw":"#foo > bar.baz",
"expressions": [[
{ "combinator":" ", "tag":"*", "id":"foo" },
{ "combinator":">", "tag":"bar", "classList": ["baz"], "classes": [{"value":"baz", "regexp":RegExp }]}
]]
}
### `h1, h2, ul > li, .things`
{
"raw": "h1, h2, ul > li, .things",
"expressions": [
[{ "combinator":" ", "tag": "h1" }],
[{ "combinator":" ", "tag": "h2" }],
[{ "combinator":" ", "tag": "ul" }, { "combinator": ">", "tag": "li" }],
[{ "combinator":" ", "tag": "*", "classList": ["things"], "classes": [{"value": "things", "regexp":RegExp }] }]
]
}

1010
node_modules/art/lib/slick/Source/Slick.Finder.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

230
node_modules/art/lib/slick/Source/Slick.Parser.js generated vendored Normal file
View File

@@ -0,0 +1,230 @@
/*
---
name: Slick.Parser
description: Standalone CSS3 Selector parser
provides: Slick.Parser
...
*/
;(function(){
var parsed,
separatorIndex,
combinatorIndex,
reversed,
cache = {},
reverseCache = {},
reUnescape = /\\/g;
var parse = function(expression, isReversed){
if (expression == null) return null;
if (expression.Slick === true) return expression;
expression = ('' + expression).replace(/^\s+|\s+$/g, '');
reversed = !!isReversed;
var currentCache = (reversed) ? reverseCache : cache;
if (currentCache[expression]) return currentCache[expression];
parsed = {
Slick: true,
expressions: [],
raw: expression,
reverse: function(){
return parse(this.raw, true);
}
};
separatorIndex = -1;
while (expression != (expression = expression.replace(regexp, parser)));
parsed.length = parsed.expressions.length;
return currentCache[parsed.raw] = (reversed) ? reverse(parsed) : parsed;
};
var reverseCombinator = function(combinator){
if (combinator === '!') return ' ';
else if (combinator === ' ') return '!';
else if ((/^!/).test(combinator)) return combinator.replace(/^!/, '');
else return '!' + combinator;
};
var reverse = function(expression){
var expressions = expression.expressions;
for (var i = 0; i < expressions.length; i++){
var exp = expressions[i];
var last = {parts: [], tag: '*', combinator: reverseCombinator(exp[0].combinator)};
for (var j = 0; j < exp.length; j++){
var cexp = exp[j];
if (!cexp.reverseCombinator) cexp.reverseCombinator = ' ';
cexp.combinator = cexp.reverseCombinator;
delete cexp.reverseCombinator;
}
exp.reverse().push(last);
}
return expression;
};
var escapeRegExp = (function(){
// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License
var from = /(?=[\-\[\]{}()*+?.\\\^$|,#\s])/g, to = '\\';
return function(string){ return string.replace(from, to) }
}())
var regexp = new RegExp(
/*
#!/usr/bin/env ruby
puts "\t\t" + DATA.read.gsub(/\(\?x\)|\s+#.*$|\s+|\\$|\\n/,'')
__END__
"(?x)^(?:\
\\s* ( , ) \\s* # Separator \n\
| \\s* ( <combinator>+ ) \\s* # Combinator \n\
| ( \\s+ ) # CombinatorChildren \n\
| ( <unicode>+ | \\* ) # Tag \n\
| \\# ( <unicode>+ ) # ID \n\
| \\. ( <unicode>+ ) # ClassName \n\
| # Attribute \n\
\\[ \
\\s* (<unicode1>+) (?: \
\\s* ([*^$!~|]?=) (?: \
\\s* (?:\
([\"']?)(.*?)\\9 \
)\
) \
)? \\s* \
\\](?!\\]) \n\
| :+ ( <unicode>+ )(?:\
\\( (?:\
(?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+)\
) \\)\
)?\
)"
*/
"^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)"
.replace(/<combinator>/, '[' + escapeRegExp(">+~`!@$%^&={}\\;</") + ']')
.replace(/<unicode>/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
.replace(/<unicode1>/g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
);
function parser(
rawMatch,
separator,
combinator,
combinatorChildren,
tagName,
id,
className,
attributeKey,
attributeOperator,
attributeQuote,
attributeValue,
pseudoMarker,
pseudoClass,
pseudoQuote,
pseudoClassQuotedValue,
pseudoClassValue
){
if (separator || separatorIndex === -1){
parsed.expressions[++separatorIndex] = [];
combinatorIndex = -1;
if (separator) return '';
}
if (combinator || combinatorChildren || combinatorIndex === -1){
combinator = combinator || ' ';
var currentSeparator = parsed.expressions[separatorIndex];
if (reversed && currentSeparator[combinatorIndex])
currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator);
currentSeparator[++combinatorIndex] = {combinator: combinator, tag: '*'};
}
var currentParsed = parsed.expressions[separatorIndex][combinatorIndex];
if (tagName){
currentParsed.tag = tagName.replace(reUnescape, '');
} else if (id){
currentParsed.id = id.replace(reUnescape, '');
} else if (className){
className = className.replace(reUnescape, '');
if (!currentParsed.classList) currentParsed.classList = [];
if (!currentParsed.classes) currentParsed.classes = [];
currentParsed.classList.push(className);
currentParsed.classes.push({
value: className,
regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)')
});
} else if (pseudoClass){
pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue;
pseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null;
if (!currentParsed.pseudos) currentParsed.pseudos = [];
currentParsed.pseudos.push({
key: pseudoClass.replace(reUnescape, ''),
value: pseudoClassValue,
type: pseudoMarker.length == 1 ? 'class' : 'element'
});
} else if (attributeKey){
attributeKey = attributeKey.replace(reUnescape, '');
attributeValue = (attributeValue || '').replace(reUnescape, '');
var test, regexp;
switch (attributeOperator){
case '^=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) ); break;
case '$=' : regexp = new RegExp( escapeRegExp(attributeValue) +'$' ); break;
case '~=' : regexp = new RegExp( '(^|\\s)'+ escapeRegExp(attributeValue) +'(\\s|$)' ); break;
case '|=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) +'(-|$)' ); break;
case '=' : test = function(value){
return attributeValue == value;
}; break;
case '*=' : test = function(value){
return value && value.indexOf(attributeValue) > -1;
}; break;
case '!=' : test = function(value){
return attributeValue != value;
}; break;
default : test = function(value){
return !!value;
};
}
if (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function(){
return false;
};
if (!test) test = function(value){
return value && regexp.test(value);
};
if (!currentParsed.attributes) currentParsed.attributes = [];
currentParsed.attributes.push({
key: attributeKey,
operator: attributeOperator,
value: attributeValue,
test: test
});
}
return '';
};
// Slick NS
var Slick = (this.Slick || {});
Slick.parse = function(expression){
return parse(expression);
};
Slick.escapeRegExp = escapeRegExp;
if (!this.Slick) this.Slick = Slick;
}).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);

12
node_modules/art/lib/slick/package.json generated vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"name" : "slick",
"description" : "Standalone CSS Selector Parser and Engine.",
"url" : "http://mootools.github.com/slick",
"keywords" : ["util", "dom", "css", "selector", "parser", "mootools"],
"author" : "Thomas Aylott",
"contributors" : ["Fabio Miranda Costa", "Valerio Proietti", "Jan Kassens"],
"dependencies" : [],
"lib" : "Source",
"main" : "./Source/slick.js",
"version" : "1.0.0"
}

19
node_modules/art/lib/slick/package.yml generated vendored Normal file
View File

@@ -0,0 +1,19 @@
name: "Slick"
web: "[mootools.net](http://mootools.net)"
description: "Slick, the most awesome CSS Parser and Finder"
license: "[MIT License](http://mootools.net/license.txt)"
copyright: "&copy; [MooTools](http://mootools.net)"
authors:
- Thomas Aylott
- Valerio Proietti
- Fabio M Costa
- Jan Kassens
sources:
- "Source/Slick.Parser.js"
- "Source/Slick.Finder.js"

23
node_modules/art/license.txt generated vendored Normal file
View File

@@ -0,0 +1,23 @@
The MIT License
Copyright (c) 2006-2009 Valerio Proietti, <http://mad4milk.net/>
Copyright (c) 2010-2011 Calyptus Life AB <http://calyptus.eu/>
Copyright (c) 2012-2013 Sebastian Markbåge
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.

50
node_modules/art/metrics/path.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
var Class = require('../core/class');
var Path = require('../core/path');
var Transform = require('../core/transform');
module.exports = Class(Path, {
onReset: function(){
this.points = [];
this.left = this.top = Infinity;
this.right = this.bottom = -Infinity;
this.width = this.height = 0;
this.length = 0;
},
onMove: function(sx, sy, ex, ey){
this.points.push(this.length, ex, ey);
},
onLine: function(sx, sy, ex, ey){
var x = ex - sx, y = ey - sy;
this.points.push((this.length += Math.sqrt(x * x + y * y)), ex, ey);
this.left = Math.min(this.left, sx, x);
this.right = Math.max(this.right, sx, x);
this.top = Math.min(this.top, sy, y);
this.bottom = Math.max(this.bottom, sy, y);
this.width = this.right - this.left;
this.height = this.bottom - this.top;
},
point: function(lengthToPoint){
// TODO: Binary search, store last distance-and-index to make second look ups faster
var points = this.points, last = points.length - 3, next;
if (last < 3) return null;
for (var i = 3; i < last; i+=3)
if (points[i] >= lengthToPoint)
break;
var l = points[i],
x = points[i+1], y = points[i+2],
dl = l - points[i-3],
dx = x - points[i-2], dy = y - points[i-1];
var offset = (l - lengthToPoint) / dl,
cos = dx / dl, sin = dy / dl;
x -= dx * offset; y -= dy * offset;
return new Transform(cos, sin, -sin, cos, x, y);
}
});

6
node_modules/art/modes/canvas.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
exports.Surface = require('./canvas/surface');
exports.Path = require('./canvas/path');
exports.Shape = require('./canvas/shape');
exports.Group = require('./canvas/group');
exports.ClippingRectangle = require('./canvas/clippingrectangle');
exports.Text = require('./canvas/text');

21
node_modules/art/modes/canvas/_image.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
var Class = require('../../core/class');
var Base = require('./base');
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(src, width, height){
this.base_initialize();
if (arguments.length == 3) this.draw.apply(this, arguments);
},
draw: function(src, width, height){
this.width = width;
this.height = height;
return this.invalidate();
},
renderTo: function(){ }
});

186
node_modules/art/modes/canvas/base.js generated vendored Normal file
View File

@@ -0,0 +1,186 @@
var Class = require('../../core/class');
var Color = require('../../core/color');
var Transform = require('../../core/transform');
var Node = require('./node');
var genericCanvas = typeof document !== 'undefined' && document.createElement('canvas'),
genericContext = genericCanvas && genericCanvas.getContext && genericCanvas.getContext('2d');
function recolorImage(img, color1, color2){
// TODO: Fix this experimental implementation
color1 = Color.detach(color1);
color2 = Color.detach(color2);
var canvas = document.createElement('canvas'),
context = canvas.getContext('2d');
canvas.width = img.width;
canvas.height = img.height;
context.fillStyle = color2[0];
context.fillRect(0, 0, img.width, img.height);
context.globalCompositeOperation = 'lighter';
context.drawImage(img, 0, 0);
return canvas;
}
var Base = Class(Node, {
initialize: function(){
this._fill = null;
this._pendingFill = null;
this._fillTransform = null;
this._stroke = null;
this._strokeCap = null;
this._strokeDash = null;
this._strokeJoin = null;
this._strokeWidth = null;
},
/* styles */
_addColors: function(gradient, stops){
// Enumerate stops, assumes offsets are enumerated in order
// TODO: Sort. Chrome doesn't always enumerate in expected order but requires stops to be specified in order.
if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++)
gradient.addColorStop(i / l, new Color(stops[i]).toString());
else for (var offset in stops)
gradient.addColorStop(offset, new Color(stops[offset]).toString());
return gradient;
},
fill: function(color){
if (arguments.length > 1) return this.fillLinear(arguments);
if (this._pendingFill) this._pendingFill();
this._fill = color ? new Color(color).toString() : null;
return this.invalidate();
},
fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
if (radiusX == null) radiusX = (this.width || 0) * 0.5;
if (centerX == null) centerX = focusX;
if (centerY == null) centerY = focusY;
centerX += centerX - focusX;
centerY += centerY - focusY;
if (radiusX === 0 || radiusX === '0') return this.fillLinear(stops);
var ys = radiusY / radiusX;
if (this._pendingFill) this._pendingFill();
var gradient = genericContext.createRadialGradient(focusX, focusY / ys, 0, centerX, centerY / ys, radiusX * 2);
// Double fill radius to simulate repeating gradient
if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++){
gradient.addColorStop(i / l / 2, new Color(stops[i]).toString());
gradient.addColorStop(1 - i / l / 2, new Color(stops[i]).toString());
} else for (var offset in stops){
gradient.addColorStop(offset / 2, new Color(stops[offset]).toString());
gradient.addColorStop(1- offset / 2, new Color(stops[offset]).toString());
}
this._fill = gradient;
this._fillTransform = new Transform(1, 0, 0, ys);
return this.invalidate();
},
fillLinear: function(stops, x1, y1, x2, y2){
if (arguments.length < 5){
var angle = ((x1 == null) ? 270 : x1) * Math.PI / 180;
var x = Math.cos(angle), y = -Math.sin(angle),
l = (Math.abs(x) + Math.abs(y)) / 2,
w = this.width || 1, h = this.height || 1;
x *= l; y *= l;
x1 = 0.5 - x;
x2 = 0.5 + x;
y1 = 0.5 - y;
y2 = 0.5 + y;
this._fillTransform = new Transform(w, 0, 0, h);
} else {
this._fillTransform = null;
}
if (this._pendingFill) this._pendingFill();
var gradient = genericContext.createLinearGradient(x1, y1, x2, y2);
this._addColors(gradient, stops);
this._fill = gradient;
return this.invalidate();
},
fillImage: function(url, width, height, left, top, color1, color2){
if (this._pendingFill) this._pendingFill();
var img = url;
if (!(img instanceof Image)){
img = new Image();
img.src = url;
}
if (img.width && img.height){
return this._fillImage(img, width, height, left || 0, top || 0, color1, color2);
}
// Not yet loaded
this._fill = null;
var self = this,
callback = function(){
cancel();
self._fillImage(img, width, height, left || 0, top || 0, color1, color2);
},
cancel = function(){
img.removeEventListener('load', callback, false);
self._pendingFill = null;
};
this._pendingFill = cancel;
img.addEventListener('load', callback, false);
return this;
},
_fillImage: function(img, width, height, left, top, color1, color2){
var w = width ? width / img.width : 1,
h = height ? height / img.height : 1;
if (color1 != null) img = recolorImage(img, color1, color2);
this._fill = genericContext.createPattern(img, 'repeat');
this._fillTransform = new Transform(w, 0, 0, h, left || 0, top || 0);
return this.invalidate();
},
stroke: function(color, width, cap, join, dash){
this._stroke = color ? new Color(color).toString() : null;
this._strokeWidth = (width != null) ? width : 1;
this._strokeCap = (cap != null) ? cap : 'round';
this._strokeJoin = (join != null) ? join : 'round';
this._strokeDash = dash;
return this.invalidate();
},
// Rendering
element_renderTo: Node.prototype.renderTo,
renderTo: function(context, xx, yx, xy, yy, x, y){
var opacity = this._opacity;
if (opacity == null || opacity >= 1){
return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
}
if (this._fill && this._stroke){
return this.element_renderTo(context, xx, yx, xy, yy, x, y);
}
context.globalAlpha = opacity;
var r = this.renderLayerTo(context, xx, yx, xy, yy, x, y);
context.globalAlpha = 1;
return r;
},
renderLayerTo: function(context, xx, yx, xy, yy, x, y){
context.setTransform(xx, yx, xy, yy, x, y);
this.renderShapeTo(context);
}
});
Base._genericContext = genericContext;
module.exports = Base;

37
node_modules/art/modes/canvas/clippingrectangle.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Node = require('./node');
module.exports = Class(Node, Container, {
initialize: function(width, height){
this.width = width;
this.height = height;
},
localHitTest: function(x, y) {
var node = this.lastChild;
while (node){
var hit = node.hitTest(x, y);
if (hit) return hit;
node = node.previousSibling;
}
return null;
},
renderLayerTo: function(context, xx, yx, xy, yy, x, y) {
context.setTransform(xx, yx, xy, yy, x, y);
context.save();
// Need beginPath to fix Firefox bug. See 3354054.
context.beginPath();
context.rect(this.x, this.y, this.width, this.height);
context.clip();
var node = this.firstChild;
while(node) {
node.renderTo(context, xx, yx, xy, yy, x, y);
node = node.nextSibling;
}
context.restore();
}
});

42
node_modules/art/modes/canvas/group.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Node = require('./node');
module.exports = Class(Node, Container, {
initialize: function(width, height){
this.width = width;
this.height = height;
},
localHitTest: function(x, y){
var node = this.lastChild;
while (node){
var hit = node.hitTest(x, y);
if (hit) return hit;
node = node.previousSibling;
}
return null;
},
renderLayerTo: function(context, xx, yx, xy, yy, x, y){
if (this._invisible) return;
x = xx * this.x + xy * this.y + x;
y = yx * this.x + yy * this.y + y;
var t = xx;
xx = t * this.xx + xy * this.yx;
xy = t * this.xy + xy * this.yy;
t = yx;
yx = t * this.xx + yy * this.yx;
yy = t * this.xy + yy * this.yy;
var node = this.firstChild;
while (node){
node.renderTo(context, xx, yx, xy, yy, x, y);
node = node.nextSibling;
}
}
});

115
node_modules/art/modes/canvas/node.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
var Class = require('../../core/class');
var Transform = require('../../core/transform');
var Element = require('../../dom/dummy');
var CanvasNode = Class(Transform, Element, {
invalidate: function(){
if (this.parentNode) this.parentNode.invalidate();
if (this._layer) this._layerCache = null;
return this;
},
_place: function(){
this.invalidate();
},
_transform: function(){
this.invalidate();
},
blend: function(opacity){
if (opacity >= 1 && this._layer) this._layer = null;
this._opacity = opacity;
if (this.parentNode) this.parentNode.invalidate();
return this;
},
// visibility
hide: function(){
this._invisible = true;
if (this.parentNode) this.parentNode.invalidate();
return this;
},
show: function(){
this._invisible = false;
if (this.parentNode) this.parentNode.invalidate();
return this;
},
// interaction
indicate: function(cursor, tooltip){
this._cursor = cursor;
this._tooltip = tooltip;
return this.invalidate();
},
hitTest: function(x, y){
if (this._invisible) return null;
var point = this.inversePoint(x, y);
if (!point) return null;
return this.localHitTest(point.x, point.y);
},
// rendering
renderTo: function(context, xx, yx, xy, yy, x, y){
var opacity = this._opacity;
if (opacity == null || opacity >= 1){
return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
}
// Render to a compositing layer and cache it
var layer = this._layer, canvas, isDirty = true,
w = context.canvas.width, h = context.canvas.height;
if (layer){
layer.setTransform(1, 0, 0, 1, 0, 0);
canvas = layer.canvas;
if (canvas.width < w || canvas.height < h){
canvas.width = w;
canvas.height = h;
} else {
var c = this._layerCache;
if (c && c.xx === xx && c.yx === yx && c.xy === xy
&& c.yy === yy && c.x === x && c.y === y){
isDirty = false;
} else {
layer.clearRect(0, 0, w, h);
}
}
} else {
canvas = document.createElement('canvas');
canvas.width = w;
canvas.height = h;
this._layer = layer = canvas.getContext('2d');
}
if (isDirty){
this.renderLayerTo(layer, xx, yx, xy, yy, x, y);
this._layerCache = {
xx: xx,
yx: yx,
xy: xy,
yy: yy,
x: x,
y: y
};
}
context.globalAlpha = opacity;
context.setTransform(1, 0, 0, 1, 0, 0);
context.drawImage(
canvas,
0, 0, w, h,
0, 0, w, h
);
context.globalAlpha = 1;
}
});
module.exports = CanvasNode;

61
node_modules/art/modes/canvas/path.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
var Class = require('../../core/class');
var Path = require('../../core/path');
var CanvasPath = Class(Path, {
initialize: function(path){
this.reset();
if (path instanceof CanvasPath){
this.path = path.path.slice(0);
} else if (path){
if (path.applyToPath)
path.applyToPath(this);
else
this.push(path);
}
},
onReset: function(){
this.path = [];
},
onMove: function(sx, sy, x, y){
this.path.push(function(context){
context.moveTo(x, y);
});
},
onLine: function(sx, sy, x, y){
this.path.push(function(context){
context.lineTo(x, y);
});
},
onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
this.path.push(function(context){
context.bezierCurveTo(p1x, p1y, p2x, p2y, x, y);
});
},
_arcToBezier: Path.prototype.onArc,
onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
this.path.push(function(context){
context.arc(cx, cy, rx, sa, ea, ccw);
});
},
onClose: function(){
this.path.push(function(context){
context.closePath();
});
},
toCommands: function(){
return this.path.slice(0);
}
});
module.exports = CanvasPath;

94
node_modules/art/modes/canvas/shape.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
var Class = require('../../core/class');
var Base = require('./base');
var Path = require('./path');
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(path, width, height){
this.base_initialize();
this.width = width;
this.height = height;
if (path != null) this.draw(path);
},
draw: function(path, width, height){
if (!(path instanceof Path)) path = new Path(path);
this.path = path;
this._commands = path.toCommands();
if (width != null) this.width = width;
if (height != null) this.height = height;
return this.invalidate();
},
localHitTest: function(x, y){
if (!this._fill) return null;
if (this.width == null || this.height == null){
var context = Base._genericContext, commands = this._commands;
if (!commands) return null;
context.beginPath();
for (var i = 0, l = commands.length; i < l; i++)
commands[i](context);
return context.isPointInPath(x, y) ? this : null;
}
if (x > 0 && y > 0 && x < this.width && y < this.height){
return this;
}
return null;
},
renderShapeTo: function(context){
if (this._invisible || !this._commands || (!this._fill && !this._stroke)) {
return null;
}
context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
var commands = this._commands,
fill = this._fill,
stroke = this._stroke,
dash = this._strokeDash;
context.beginPath();
if (dash) {
if (context.setLineDash) {
context.setLineDash(dash);
} else {
// TODO: Remove when FF supports setLineDash.
context.mozDash = dash;
}
// TODO: Create fallback to other browsers.
} else {
if (context.setLineDash) {
context.setLineDash([]);
} else {
context.mozDash = null;
}
}
for (var i = 0, l = commands.length; i < l; i++)
commands[i](context);
if (fill){
var m = this._fillTransform;
if (m){
context.save(); // TODO: Optimize away this by restoring the transform before stroking
context.transform(m.xx, m.yx, m.xy, m.yy, m.x, m.y);
context.fillStyle = fill;
context.fill();
context.restore();
} else {
context.fillStyle = fill;
context.fill();
}
}
if (stroke){
context.strokeStyle = stroke;
context.lineWidth = this._strokeWidth;
context.lineCap = this._strokeCap;
context.lineJoin = this._strokeJoin;
context.stroke();
}
}
});

142
node_modules/art/modes/canvas/surface.js generated vendored Normal file
View File

@@ -0,0 +1,142 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Element = require('../../dom/native');
var fps = 1000 / 60, invalids = [], renderTimer, renderInvalids = function(){
clearTimeout(renderTimer);
renderTimer = null;
var canvases = invalids;
invalids = [];
for (var i = 0, l = canvases.length; i < l; i++){
var c = canvases[i];
c._valid = true;
c.render();
}
};
var resolution = typeof window !== 'undefined' && window.devicePixelRatio || 1;
var previousHit = null, previousHitSurface = null;
var CanvasSurface = Class(Element, Container, {
initialize: function(width, height, existingElement){
var element = this.element = existingElement || document.createElement('canvas');
var context = this.context = element.getContext('2d');
this._valid = true;
if (width != null && height != null) this.resize(width, height);
element.addEventListener('mousemove', this, false);
element.addEventListener('mouseout', this, false);
element.addEventListener('mouseover', this, false);
element.addEventListener('mouseup', this, false);
element.addEventListener('mousedown', this, false);
element.addEventListener('click', this, false);
},
handleEvent: function(event){
if (event.clientX == null) return;
var element = this.element,
rect = element.getBoundingClientRect(),
x = event.clientX - rect.left - element.clientLeft,
y = event.clientY - rect.top - element.clientTop,
hit = this.hitTest(x, y);
if (hit !== previousHit){
if (previousHit){
previousHit.dispatch({
type: 'mouseout',
target: previousHit,
relatedTarget: hit,
sourceEvent: event
});
}
if (hit){
hit.dispatch({
type: 'mouseover',
target: hit,
relatedTarget: previousHit,
sourceEvent: event
});
}
previousHit = hit;
previousHitSurface = this;
this.refreshCursor();
}
if (hit) hit.dispatch(event);
},
refreshCursor: function(){
if (previousHitSurface !== this) return;
var hit = previousHit, hitCursor = '', hitTooltip = '';
while (hit){
if (!hitCursor && hit._cursor){
hitCursor = hit._cursor;
if (hitTooltip) break;
}
if (!hitTooltip && hit._tooltip){
hitTooltip = hit._tooltip;
if (hitCursor) break;
}
hit = hit.parentNode;
}
// TODO: No way to set cursor/title on the surface
this.element.style.cursor = hitCursor;
this.element.title = hitTooltip;
},
resize: function(width, height){
var element = this.element;
element.setAttribute('width', width * resolution);
element.setAttribute('height', height * resolution);
element.style.width = width + 'px';
element.style.height = height + 'px';
this.width = width;
this.height = height;
return this;
},
invalidate: function(left, top, width, height){
if (this._valid){
this._valid = false;
invalids.push(this);
if (!renderTimer){
if (window.mozRequestAnimationFrame){
renderTimer = true;
window.mozRequestAnimationFrame(renderInvalids);
} else {
renderTimer = setTimeout(renderInvalids, fps);
}
}
}
return this;
},
hitTest: function(x, y){
if (x < 0 || y < 0 || x > this.width || y > this.height) return null;
var node = this.lastChild;
while (node){
var hit = node.hitTest(x, y);
if (hit) return hit;
node = node.previousSibling;
}
return null;
},
render: function(){
var node = this.firstChild, context = this.context;
context.setTransform(resolution, 0, 0, resolution, 0, 0);
context.clearRect(0, 0, this.width, this.height);
while (node){
node.renderTo(context, resolution, 0, 0, resolution, 0, 0);
node = node.nextSibling;
}
this.refreshCursor();
}
});
CanvasSurface.tagName = 'canvas';
module.exports = CanvasSurface;

116
node_modules/art/modes/canvas/text.js generated vendored Normal file
View File

@@ -0,0 +1,116 @@
var Class = require('../../core/class');
var Base = require('./base');
var fontAnchors = { middle: 'center' };
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(text, font, alignment, path){
this.base_initialize();
this.draw.apply(this, arguments);
},
draw: function(text, font, alignment, path){
var em;
if (typeof font == 'string'){
em = Number(/(\d+)/.exec(font)[0]);
} else if (font){
em = parseFloat(font.fontSize || font['font-size'] || '12');
font = (font.fontStyle || font['font-style'] || '') + ' ' +
(font.fontVariant || font['font-variant'] || '') + ' ' +
(font.fontWeight || font['font-weight'] || '') + ' ' +
em + 'px ' +
(font.fontFamily || font['font-family'] || 'Arial');
} else {
font = this._font;
}
var lines = text && text.split(/\r?\n/);
this._font = font;
this._fontSize = em;
this._text = lines;
this._alignment = fontAnchors[alignment] || alignment || 'left';
var context = Base._genericContext;
context.font = this._font;
context.textAlign = this._alignment;
context.textBaseline = 'middle';
lines = this._text;
var l = lines.length, width = 0;
for (var i = 0; i < l; i++){
var w = context.measureText(lines[i]).width;
if (w > width) width = w;
}
this.width = width;
this.height = l ? l * 1.1 * em : 0;
return this.invalidate();
},
// Interaction
localHitTest: function(x, y){
if (!this._fill) return null;
if (x > 0 && y > 0 && x < this.width && y < this.height){
return this;
}
return null;
},
// Rendering
renderShapeTo: function(context){
if (this._invisible || !this._text || (!this._fill && !this._stroke)) {
return null;
}
context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
var fill = this._fill,
stroke = this._stroke,
text = this._text,
dash = this._strokeDash;
context.font = this._font;
context.textAlign = this._alignment;
context.textBaseline = 'middle';
var em = this._fontSize,
y = em / 2,
lineHeight = 1.1 * em,
lines = text,
l = lines.length;
if (fill){
context.fillStyle = fill;
for (var i = 0; i < l; i++)
context.fillText(lines[i], 0, y + i * lineHeight);
}
if (stroke){
if (dash) {
if (context.setLineDash) {
context.setLineDash(dash);
} else {
// TODO: Remove when FF supports setLineDash.
context.mozDash = dash;
}
// TODO: Create fallback to other browsers.
} else {
if (context.setLineDash) {
context.setLineDash([]);
} else {
context.mozDash = null;
}
}
context.strokeStyle = stroke;
context.lineWidth = this._strokeWidth;
context.lineCap = this._strokeCap;
context.lineJoin = this._strokeJoin;
for (i = 0; i < l; i++)
context.strokeText(lines[i], 0, y + i * lineHeight);
}
}
});

16
node_modules/art/modes/current.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
function warning(){
throw new Error('You must require a mode before requiring anything else.');
}
exports.Surface = warning;
exports.Path = warning;
exports.Shape = warning;
exports.Group = warning;
exports.ClippingRectangle = warning;
exports.Text = warning;
exports.setCurrent = function(mode){
for (var key in mode){
exports[key] = mode[key];
}
};

26
node_modules/art/modes/dom.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var SVG = require('./svg');
var VML = require('./vml');
var hasSVG = function(){
var implementation = typeof document !== 'undefined' && document.implementation;
return (implementation && implementation.hasFeature && implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
};
var hasVML = function(){
return typeof document !== 'undefined' && document.namespaces;
};
var MODE = hasSVG() ? SVG : hasVML() ? VML : {};
exports.Surface = MODE.Surface;
exports.Path = MODE.Path;
exports.Shape = MODE.Shape;
exports.Group = MODE.Group;
exports.ClippingRectangle = MODE.ClippingRectangle;
exports.Text = MODE.Text;
require('./current').setCurrent(exports);

25
node_modules/art/modes/fast-noSideEffects.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var hasCanvas = function(){
var canvas = typeof window !== 'undefined' && window.document && window.document.createElement && document.createElement('canvas');
return canvas && !!canvas.getContext;
};
if (hasCanvas()) {
exports.Surface = require('./canvas/surface');
exports.Path = require('./canvas/path');
exports.Shape = require('./canvas/shape');
exports.Group = require('./canvas/group');
exports.ClippingRectangle = require('./canvas/clippingrectangle');
exports.Text = require('./canvas/text');
} else {
exports.Surface = require('./vml/surface');
exports.Path = require('./vml/path');
exports.Shape = require('./vml/shape');
exports.Group = require('./vml/group');
exports.ClippingRectangle = require('./vml/clippingrectangle');
exports.Text = require('./vml/text');
var DOM = require('./vml/dom');
if (typeof document !== 'undefined') DOM.init(document);
}

29
node_modules/art/modes/fast.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var VML = require('./vml');
var Canvas = require('./canvas');
var Base = require('./canvas/base');
//var Flash = require('./flash');
/*
var hasFlash = function(){
var flash = navigator.plugins && navigator.plugins['Shockwave Flash'];
try {
flash = flash ? flash.description :
new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
.GetVariable('$version');
} catch (x){ }
return flash && flash.match(/\d+/) >= 9;
};
*/
var MODE = Base._genericContext ? Canvas : /*hasFlash() ? Flash :*/ VML;
exports.Surface = MODE.Surface;
exports.Path = MODE.Path;
exports.Shape = MODE.Shape;
exports.Group = MODE.Group;
exports.ClippingRectangle = MODE.ClippingRectangle;
exports.Text = MODE.Text;
require('./current').setCurrent(exports);

7
node_modules/art/modes/script.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
exports.Surface = require('./script/surface');
exports.Path = require('./script/path');
exports.Shape = require('./script/shape');
exports.Group = require('./script/group');
exports.Text = require('./script/text');
exports.Font = require('./script/font');
require('./current').setCurrent(exports);

26
node_modules/art/modes/script/_image.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var Class = require('../../core/class');
var Base = require('./base');
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(src, width, height){
this.base_initialize();
if (src != null) this.draw.apply(this, arguments);
},
draw: function(){
this.args = Array.prototype.slice.call(arguments);
return this;
},
base_toExpression: Base.prototype.toExpression,
toExpression: function(expr){
var artImage = this.artVar.property('Image');
if (!expr) expr = artImage.construct.apply(artImage, this.args);
return this.base_toExpression(expr);
}
});

24
node_modules/art/modes/script/base.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
var Class = require('../../core/class');
var Color = require('../../core/color');
var Node = require('./node');
Color.prototype.toExpression = Color.prototype.toHEX;
module.exports = Class(Node, {
/* styles */
fill: function(color){ return this._addCall('fill', arguments); },
fillRadial: function(stops, focusX, focusY, radius, centerX, centerY){ return this._addCall('fillRadial', arguments); },
fillLinear: function(stops, angle){
if (angle == null) return this._addCall('fill', stops);
return this._addCall('fillLinear', arguments);
},
fillImage: function(){ return this._addCall('fillImage', arguments); },
stroke: function(color, width, cap, join){ return this._addCall('stroke', arguments); }
});

76
node_modules/art/modes/script/font.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
var Class = require('../../core/class');
var Base = require('./base');
var Modulizer = require('./modulizer');
var fonts = {}, fontsInUse = null;
var artVar = Base.prototype.artVar, artFont = artVar.property('Font');
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 = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(text, font, alignment){
this.base_initialize();
if (text != null && font != null) this.draw(text, font, alignment);
},
draw: function(text, fontArg, alignment){
var font = (typeof fontArg == 'string') ? parseFontString(fontArg) : fontArg;
if (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);
this.font = font.glyphs ? null : weight + style + family;
}
this.args = Array.prototype.slice.call(arguments);
return this;
},
base_toExpression: Base.prototype.toExpression,
toExpression: function(expr){
if (this.font && fontsInUse) fontsInUse[this.font] = fonts[this.font];
if (!expr) expr = this.args ? artFont.construct.apply(artFont, this.args) : artFont.construct();
return this.base_toExpression(expr);
}
});
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;
};
var _toModuleStatements = Modulizer._toModuleStatements;
Modulizer._toModuleStatements = function(){
fontsInUse = {};
var statements = _toModuleStatements.call(this);
for (var font in fontsInUse){
var registerStatement = artFont.property('register').call(fontsInUse[font]);
statements.push(registerStatement);
}
statements.push(statements[1]);
statements.splice(1, 1);
fontsInUse = null;
return statements;
};
module.exports = Font;

26
node_modules/art/modes/script/group.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Node = require('./node');
module.exports = Class(Node, Container, {
element_initialize: Node.prototype.initialize,
initialize: function(){
this.element_initialize();
},
element_toExpression: Node.prototype.toExpression,
toExpression: function(){
var artGroup = this.artVar.property('Group'),
grab = artGroup.construct().property('grab');
var children = [], node = this.firstChild;
while (node){
children.push(node.toExpression());
node = node.nextSibling;
}
return this.element_toExpression(grab.call.apply(grab, children));
}
});

32
node_modules/art/modes/script/modulizer.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
var AST = require('../../lib/ast-js/ast');
var artVar = new AST.Variable('ART'),
moduleVar = new AST.Variable('module'),
exportsProp = moduleVar.property('exports'),
requireVar = new AST.Variable('require'),
requireART = requireVar.call('art'),
requireStatement = artVar.assign(requireART);
var Modulizer = {
artVar: artVar,
toExpression: function(){
throw new Error('You need to implement toExpression on this class.');
},
_toModuleStatements: function(){
var fn = new AST.Function(null, null, [ new AST.Return(this.toExpression()) ]);
return [requireStatement, exportsProp.assign(fn)];
},
toModule: function(){
return new AST.Block(
// Make this overridable even when mixed in
Modulizer._toModuleStatements.call(this)
);
}
};
module.exports = Modulizer;

60
node_modules/art/modes/script/node.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
var Class = require('../../core/class');
var Transform = require('../../core/transform');
var Modulizer = require('./modulizer');
var Element = require('../../dom/dummy');
module.exports = Class(Modulizer, Transform, Element, {
initialize: function(){
this._calls = [];
},
_addCall: function(property, args){
this._calls.push({ prop: property, args: Array.prototype.slice.call(args) });
return this;
},
toExpression: function(expr){
var calls = this._calls, propExpr;
for (var i = 0, l = calls.length; i < l; i++){
var call = calls[i];
propExpr = expr.property(call.prop);
expr = propExpr.call.apply(propExpr, call.args);
}
if (this.xx != 1 || this.xy != 0 || this.yx != 0 || this.yy != 1){
propExpr = expr.property('transform');
expr = propExpr.call.apply(propExpr, (this.x != 0 || this.y != 0) ? [
this.xx, this.xy,
this.yx, this.yy,
this.x, this.y
] : [
this.xx, this.xy,
this.yx, this.yy
]);
} else if (this.x != 0 || this.y != 0){
expr = expr.property('move').call(this.x, this.y);
}
return expr;
},
// transforms
blend: function(opacity){ return this._addCall('blend', arguments); },
// visibility
hide: function(){ return this._addCall('hide', arguments); },
show: function(){ return this._addCall('show', arguments); },
// interaction
indicate: function(){ return this._addCall('indicate', arguments); },
// ignore
subscribe: function(){
return this;
}
});

1
node_modules/art/modes/script/path.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../svg/path');

28
node_modules/art/modes/script/shape.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
var Class = require('../../core/class');
var Base = require('./base');
var Path = require('./path');
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(path){
this.base_initialize();
if (path != null) this.draw(path);
},
draw: function(path, width, height){
path = ((path instanceof Path) ? path : new Path(path)).toString();
this.args = arguments.length < 3 ? [ path ] : [ path, width, height ];
return this;
},
base_toExpression: Base.prototype.toExpression,
toExpression: function(expr){
var artShape = this.artVar.property('Shape');
if (!expr) expr = artShape.construct.apply(artShape, this.args);
return this.base_toExpression(expr);
}
});

35
node_modules/art/modes/script/surface.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Modulizer = require('./modulizer');
module.exports = Class(Container, Modulizer, {
initialize: function(width, height){
this.resize(width, height);
},
resize: function(width, height){
this.width = width;
this.height = height;
return this;
},
toExpression: function(){
var expr = this.artVar.property('Surface').construct(this.width, this.height);
if (!this.firstChild) return expr;
var children = [], node = this.firstChild;
while (node){
children.push(node);
node = node.nextSibling;
}
var grab = expr.property('grab');
return grab.call.apply(grab, children);
},
// ignore
subscribe: function(){
return this;
}
});

26
node_modules/art/modes/script/text.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var Class = require('../../core/class');
var Base = require('./base');
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(text){
this.base_initialize();
if (text != null) this.draw.apply(this, arguments);
},
draw: function(){
this.args = Array.prototype.slice.call(arguments);
return this;
},
base_toExpression: Base.prototype.toExpression,
toExpression: function(expr){
var artText = this.artVar.property('Text');
if (!expr) expr = artText.construct.apply(artText, this.args);
return this.base_toExpression(expr);
}
});

8
node_modules/art/modes/svg.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
exports.Surface = require('./svg/surface');
exports.Path = require('./svg/path');
exports.Shape = require('./svg/shape');
exports.Group = require('./svg/group');
exports.ClippingRectangle = require('./svg/group');
exports.Text = require('./svg/text');
require('./current').setCurrent(exports);

24
node_modules/art/modes/svg/_image.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
var Class = require('../../core/class');
var Base = require('./base');
var DOM = require('./dom');
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(src, width, height){
this.base_initialize('image');
if (arguments.length == 3) this.draw.apply(this, arguments);
},
draw: function(src, width, height){
var element = this.element;
DOM.link(element, src);
element.setAttribute('width', width);
element.setAttribute('height', height);
this.width = width;
this.height = height;
return this;
}
});

231
node_modules/art/modes/svg/base.js generated vendored Normal file
View File

@@ -0,0 +1,231 @@
var Class = require('../../core/class');
var Color = require('../../core/color');
var Node = require('./node');
var DOM = require('./dom');
var createElement = DOM.createElement;
module.exports = Class(Node, {
element_initialize: Node.prototype.initialize,
initialize: function(tag){
this.element_initialize(tag);
this.brushes = {};
this.fill();
this.stroke();
},
_place: function(){
if (this.parentNode){
this._injectBrush('fill');
this._injectBrush('stroke');
} else {
this._ejectBrush('fill');
this._ejectBrush('stroke');
}
return this;
},
_injectBrush: function(type){
if (!this.parentNode) return;
var brush = type == 'fill' ? this.fillBrush : this.strokeBrush;
if (brush) this.parentNode.defs.appendChild(brush);
},
_ejectBrush: function(type){
var brush = this[type + 'Brush'];
if (brush && brush.parentNode) brush.parentNode.removeChild(brush);
},
/* styles */
_createBrush: function(type, tag){
this._ejectBrush(type);
var brush = createElement(tag);
if (type == 'fill')
this.fillBrush = brush;
else
this.strokeBrush = brush;
var id = type + '-brush-e' + DOM.uniqueID();
brush.setAttribute('id', id);
this._injectBrush(type);
this.element.setAttribute(type, 'url(#' + id + ')');
return brush;
},
_createGradient: function(type, style, stops){
var gradient = this._createBrush(type, style);
var addColor = function(offset, color){
color = Color.detach(color);
var stop = createElement('stop');
stop.setAttribute('offset', offset);
stop.setAttribute('stop-color', color[0]);
stop.setAttribute('stop-opacity', color[1]);
gradient.appendChild(stop);
};
// Enumerate stops, assumes offsets are enumerated in order
// TODO: Sort. Chrome doesn't always enumerate in expected order but requires stops to be specified in order.
if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++) addColor(i / l, stops[i]);
else for (var offset in stops) addColor(offset, stops[offset]);
gradient.setAttribute('spreadMethod', 'reflect'); // Closer to the VML gradient
this.element.removeAttribute('fill-opacity');
return gradient;
},
_setColor: function(type, color){
this._ejectBrush(type);
this[type + 'Brush'] = null;
var element = this.element;
if (color == null){
element.setAttribute(type, 'none');
element.removeAttribute(type + '-opacity');
} else {
color = Color.detach(color);
element.setAttribute(type, color[0]);
element.setAttribute(type + '-opacity', color[1]);
}
},
fill: function(color){
if (arguments.length > 1) this.fillLinear(arguments);
else this._setColor('fill', color);
return this;
},
fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
var gradient = this._createGradient('fill', 'radialGradient', stops);
gradient.setAttribute('gradientUnits', 'userSpaceOnUse');
if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
if (radiusX == null) radiusX = (this.width || 0) * 0.5;
if (centerX == null) centerX = focusX;
if (centerY == null) centerY = focusY;
var ys = radiusY / radiusX;
gradient.setAttribute('fx', focusX);
gradient.setAttribute('fy', focusY / ys);
gradient.setAttribute('r', radiusX);
if (ys != 1) gradient.setAttribute('gradientTransform', 'scale(1,' + ys + ')');
gradient.setAttribute('cx', centerX);
gradient.setAttribute('cy', centerY / ys);
return this;
},
fillLinear: function(stops, x1, y1, x2, y2){
var gradient = this._createGradient('fill', 'linearGradient', stops);
if (arguments.length == 5){
gradient.setAttribute('gradientUnits', 'userSpaceOnUse');
} else {
var angle = ((x1 == null) ? 270 : x1) * Math.PI / 180;
var x = Math.cos(angle), y = -Math.sin(angle),
l = (Math.abs(x) + Math.abs(y)) / 2;
x *= l; y *= l;
x1 = 0.5 - x;
x2 = 0.5 + x;
y1 = 0.5 - y;
y2 = 0.5 + y;
}
gradient.setAttribute('x1', x1);
gradient.setAttribute('y1', y1);
gradient.setAttribute('x2', x2);
gradient.setAttribute('y2', y2);
return this;
},
fillImage: function(url, width, height, left, top, color1, color2){
var pattern = this._createBrush('fill', 'pattern');
var image = createElement('image');
DOM.link(image, url);
image.setAttribute('width', width);
image.setAttribute('height', height);
image.setAttribute('preserveAspectRatio', 'none'); // none, xMidYMid slice, xMidYMid meet
if (color1 != null){
color1 = new Color(color1);
if (color2 == null){
color2 = new Color(color1);
color2.alpha = 0;
} else {
color2 = new Color(color2);
}
var r = (color1.red - color2.red) / (255 * 3),
g = (color1.green - color2.green) / (255 * 3),
b = (color1.blue - color2.blue) / (255 * 3),
a = (color1.alpha - color2.alpha) / 3;
var matrix = [
r, r, r, 0, color2.red / 255,
g, g, g, 0, color2.green / 255,
b, b, b, 0, color2.blue / 255,
a, a, a, 0, color2.alpha
];
var filter = createElement('filter');
filter.setAttribute('id', 'testfilter' + this.uid);
var cm = createElement('feColorMatrix');
cm.setAttribute('type', 'matrix');
cm.setAttribute('values', matrix.join(' '));
image.setAttribute('fill', '#000');
image.setAttribute('filter', 'url(#testfilter' + this.uid + ')');
filter.appendChild(cm);
pattern.appendChild(filter);
}
pattern.appendChild(image);
pattern.setAttribute('patternUnits', 'userSpaceOnUse');
pattern.setAttribute('patternContentsUnits', 'userSpaceOnUse');
pattern.setAttribute('x', left || 0);
pattern.setAttribute('y', top || 0);
pattern.setAttribute('width', width);
pattern.setAttribute('height', height);
//pattern.setAttribute('viewBox', '0 0 75 50');
//pattern.setAttribute('preserveAspectRatio', 'xMidYMid slice');
return this;
},
stroke: function(color, width, cap, join, dash){
var element = this.element;
element.setAttribute('stroke-width', (width != null) ? width : 1);
element.setAttribute('stroke-linecap', (cap != null) ? cap : 'round');
element.setAttribute('stroke-linejoin', (join != null) ? join : 'round');
if (dash) {
element.setAttribute('stroke-dasharray', dash.join(','));
}
this._setColor('stroke', color);
return this;
}
});

27
node_modules/art/modes/svg/dom.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
var UID = +new Date();
exports.uniqueID = function(){
return (UID++).toString(36);
};
var NS = 'http://www.w3.org/2000/svg',
XLINK = 'http://www.w3.org/1999/xlink',
XML = 'http://www.w3.org/XML/1998/namespace';
exports.NS = NS;
exports.createElement = function(tag){
return document.createElementNS(NS, tag);
};
exports.link = function(element, url){
element.setAttributeNS(XLINK, 'href', url);
};
exports.preserveSpace = function(element){
element.setAttributeNS(XML, 'space', 'preserve');
};
exports.createTextNode = function(text){
return document.createTextNode(text);
}

18
node_modules/art/modes/svg/group.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Node = require('./node');
var DOM = require('./dom');
module.exports = Class(Node, Container, {
element_initialize: Node.prototype.initialize,
initialize: function(width, height){
this.element_initialize('g');
this.width = width;
this.height = height;
this.defs = DOM.createElement('defs');
this.element.appendChild(this.defs);
}
});

56
node_modules/art/modes/svg/node.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
var Class = require('../../core/class');
var Transform = require('../../core/transform');
var Element = require('../../dom/shadow');
var DOM = require('./dom');
module.exports = Class(Element, Transform, {
initialize: function(tag){
this.uid = DOM.uniqueID();
var element = this.element = DOM.createElement(tag);
element.setAttribute('id', 'e' + this.uid);
},
// transforms
_transform: function(){
var m = this;
this.element.setAttribute('transform', 'matrix(' + [m.xx, m.yx, m.xy, m.yy, m.x, m.y] + ')');
},
blend: function(opacity){
this.element.setAttribute('opacity', opacity);
return this;
},
// visibility
hide: function(){
this.element.setAttribute('display', 'none');
return this;
},
show: function(){
this.element.setAttribute('display', '');
return this;
},
// interaction
indicate: function(cursor, tooltip){
var element = this.element;
if (cursor) this.element.style.cursor = cursor;
if (tooltip){
var title = this.titleElement;
if (title){
title.firstChild.nodeValue = tooltip;
} else {
this.titleElement = title = DOM.createElement('title');
title.appendChild(DOM.createTextNode(tooltip));
element.insertBefore(title, element.firstChild);
}
}
return this;
}
});

76
node_modules/art/modes/svg/path.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
var Class = require('../../core/class');
// Utility command factories
var point = function(c){
return function(x, y){
return this.push(c, x, y);
};
};
var arc = function(c, cc){
return function(x, y, rx, ry, outer){
return this.push(c, Math.abs(rx || x), Math.abs(ry || rx || y), 0, outer ? 1 : 0, cc, x, y);
};
};
var curve = function(t, s, q, c){
return function(c1x, c1y, c2x, c2y, ex, ey){
var l = arguments.length, k = l < 4 ? t : l < 6 ? q : c;
return this.push(k, c1x, c1y, c2x, c2y, ex, ey);
};
};
// SVG Path Class
var SVGPath = Class({
initialize: function(path){
if (path instanceof SVGPath){
this.path = [Array.prototype.join.call(path.path, ' ')];
} else {
if (path && path.applyToPath)
path.applyToPath(this);
else
this.path = [path || 'm0 0'];
}
},
push: function(){
this.path.push(Array.prototype.join.call(arguments, ' '));
return this;
},
reset: function(){
this.path = [];
return this;
},
move: point('m'),
moveTo: point('M'),
line: point('l'),
lineTo: point('L'),
curve: curve('t', 's', 'q', 'c'),
curveTo: curve('T', 'S', 'Q', 'C'),
arc: arc('a', 1),
arcTo: arc('A', 1),
counterArc: arc('a', 0),
counterArcTo: arc('A', 0),
close: function(){
return this.push('z');
},
toSVG: function(){
return this.path.join(' ');
}
});
SVGPath.prototype.toString = SVGPath.prototype.toSVG;
module.exports = SVGPath;

25
node_modules/art/modes/svg/shape.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var Class = require('../../core/class');
var Path = require('./path');
var Base = require('./base');
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(path, width, height){
this.base_initialize('path');
this.element.setAttribute('fill-rule', 'evenodd');
this.width = width;
this.height = height;
if (path != null) this.draw(path);
},
draw: function(path, width, height){
if (!(path instanceof Path)) path = new Path(path);
this.element.setAttribute('d', path.toSVG());
if (width != null) this.width = width;
if (height != null) this.height = height;
return this;
}
});

30
node_modules/art/modes/svg/surface.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Element = require('../../dom/native');
var DOM = require('./dom');
var SVGSurface = Class(Element, Container, {
initialize: function SVGSurface(width, height, existingElement){
var element = this.element = existingElement || DOM.createElement('svg');
element.setAttribute('xmlns', DOM.NS);
element.setAttribute('version', 1.1);
var defs = this.defs = DOM.createElement('defs');
element.appendChild(defs);
if (width != null && height != null) this.resize(width, height);
},
resize: function(width, height){
var element = this.element;
element.setAttribute('width', width);
element.setAttribute('height', height);
this.width = width;
this.height = height;
return this;
}
});
SVGSurface.tagName = 'svg';
module.exports = SVGSurface;

201
node_modules/art/modes/svg/text.js generated vendored Normal file
View File

@@ -0,0 +1,201 @@
var Class = require('../../core/class');
var Path = require('./path');
var Base = require('./base');
var Surface = require('./surface');
var DOM = require('./dom');
var createElement = DOM.createElement;
var ua = typeof navigator !== 'undefined' && navigator && navigator.userAgent,
hasBaseline = !(/opera|safari|ie/i).test(ua) || (/chrome/i).test(ua);
var fontAnchors = { left: 'start', center: 'middle', right: 'end' },
fontAnchorOffsets = { middle: '50%', end: '100%' };
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(text, font, alignment, path){
this.base_initialize('text');
this.draw.apply(this, arguments);
},
draw: function(text, font, alignment, path){
var element = this.element;
if (font){
if (typeof font == 'string'){
element.style.font = font;
} else {
for (var key in font){
var ckey = key.camelCase ? key.camelCase() : key;
// NOT UNIVERSALLY SUPPORTED OPTIONS
// if (ckey == 'kerning') element.setAttribute('kerning', font[key] ? 'auto' : '0');
// else if (ckey == 'letterSpacing') element.setAttribute('letter-spacing', Number(font[key]) + 'ex');
// else if (ckey == 'rotateGlyphs') element.setAttribute('glyph-orientation-horizontal', font[key] ? '270deg' : '');
// else
element.style[ckey] = font[key];
}
element.style.lineHeight = '0.5em';
}
}
if (alignment) element.setAttribute('text-anchor', this.textAnchor = (fontAnchors[alignment] || alignment));
if (path && typeof path != 'number'){
this._createPaths(new Path(path));
} else if (path === false){
this._ejectPaths();
this.pathElements = null;
}
var paths = this.pathElements, child;
while ((child = element.firstChild)){
element.removeChild(child);
}
// Note: Gecko will (incorrectly) align gradients for each row, while others applies one for the entire element
var lines = String(text).split(/\r?\n/), l = lines.length,
baseline = 'central';
if (paths && l > paths.length) l = paths.length;
if (hasBaseline) element.setAttribute('dominant-baseline', baseline);
DOM.preserveSpace(element);
for (var i = 0; i < l; i++){
var line = lines[i], row, content;
if (paths){
row = createElement('textPath');
DOM.link(row, '#' + paths[i].getAttribute('id'));
row.setAttribute('startOffset', fontAnchorOffsets[this.textAnchor] || 0);
} else {
row = createElement('tspan');
row.setAttribute('x', 0);
row.setAttribute('y', (i * 1.1 + 0.5) + 'em');
}
if (hasBaseline){
row.setAttribute('dominant-baseline', baseline);
content = row;
} else if (paths){
content = createElement('tspan');
content.setAttribute('dy', '0.35em');
row.appendChild(content);
} else {
content = row;
row.setAttribute('y', (i * 1.1 + 0.85) + 'em');
}
DOM.preserveSpace(content);
content.appendChild(DOM.createTextNode(line));
element.appendChild(row);
}
// Measure
// TODO: Move to lazy ES5 left/top/width/height/bottom/right property getters
var bb;
try { bb = element.getBBox(); } catch (x){ }
if (!bb || !bb.width) bb = this._whileInDocument(element.getBBox, element);
this.left = bb.x;
this.top = bb.y;
this.width = bb.width;
this.height = bb.height;
this.right = bb.x + bb.width;
this.bottom = bb.y + bb.height;
return this;
},
// TODO: Unify path injection with gradients and imagefills
base_place: Base.prototype._place,
_place: function(){
if (this.parentNode){
this._injectPaths();
} else {
this._ejectPaths();
}
return this.base_place();
},
_injectPaths: function(){
var paths = this.pathElements;
if (!this.parentNode || !paths) return;
var defs = this.parentNode.defs;
for (var i = 0, l = paths.length; i < l; i++)
defs.appendChild(paths[i]);
},
_ejectPaths: function(){
var paths = this.pathElements;
if (!paths) return;
for (var i = 0, l = paths; i < l; i++){
var path = paths[i];
if (path.parentNode)
path.parentNode.removeChild(paths[i]);
}
},
_createPaths: function(path){
this._ejectPaths();
var id = 'p' + DOM.uniqueID() + '-';
//splitPaths = []; splitPath = ['M', 0, 0];
//path.visit(splitLine, splitCurve, null, splitMove);
//splitPaths.push(splitPath);
var splitPaths = [path.path];
var result = [];
for (var i = 0, l = splitPaths.length; i < l; i++){
var p = createElement('path');
p.setAttribute('d', splitPaths[i].join(' '));
p.setAttribute('id', id + i);
result.push(p);
}
this.pathElements = result;
this._injectPaths();
},
_whileInDocument: function(fn, bind){
// Temporarily inject into the document
var element = this.element,
container = this.parentNode,
parent = element.parentNode,
sibling = element.nextSibling,
body = element.ownerDocument.body,
canvas = new Surface(1, 1).inject(body);
this.inject(canvas);
var result = fn.call(bind);
canvas.eject();
if (container) this.inject(container);
if (parent) parent.insertBefore(element, sibling);
return result;
}
});
/* split each continuous line into individual paths */
/*
var pathSplitter = new CorePath();
pathSplitter.splitPaths = [];
var PathPerRow = Class(CorePath, {
function splitMove(sx, sy, x, y){
if (splitPath.length > 3) splitPaths.push(splitPath);
splitPath = ['M', x, y];
};
function splitLine(sx, sy, x, y){
splitPath.push('L', x, y);
};
function splitCurve(sx, sy, p1x, p1y, p2x, p2y, x, y){
splitPath.push('C', p1x, p1y, p2x, p2y, x, y);
};
});*/

11
node_modules/art/modes/vml.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
exports.Surface = require('./vml/surface');
exports.Path = require('./vml/path');
exports.Shape = require('./vml/shape');
exports.Group = require('./vml/group');
exports.ClippingRectangle = require('./vml/clippingrectangle');
exports.Text = require('./vml/text');
var DOM = require('./vml/dom');
if (typeof document !== 'undefined') DOM.init(document);
require('./current').setCurrent(exports);

316
node_modules/art/modes/vml/base.js generated vendored Normal file
View File

@@ -0,0 +1,316 @@
var Class = require('../../core/class');
var Transform = require('../../core/transform');
var Color = require('../../core/color');
var Node = require('./node');
var DOM = require('./dom');
var precision = 100;
var defaultBox = { left: 0, top: 0, width: 500, height: 500 };
module.exports = Class(Node, {
element_initialize: Node.prototype.initialize,
initialize: function(tag){
this.element_initialize(tag);
var element = this.element;
var skew = this.skewElement = DOM.createElement('skew');
skew.on = true;
element.appendChild(skew);
var fill = this.fillElement = DOM.createElement('fill');
fill.on = false;
element.appendChild(fill);
var stroke = this.strokeElement = DOM.createElement('stroke');
stroke.on = false;
element.appendChild(stroke);
},
/* transform */
_transform: function(){
var container = this.parentNode;
// Active Transformation Matrix
var m = container ? new Transform(container._activeTransform).transform(this) : this;
// Box in shape user space
var box = this._boxCoords || this._size || defaultBox;
var originX = box.left || 0,
originY = box.top || 0,
width = box.width || 1,
height = box.height || 1;
// Flipped
var flip = m.yx / m.xx > m.yy / m.xy;
if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = !flip;
flip = flip ? -1 : 1;
m = new Transform().scale(flip, 1).transform(m);
// Rotation is approximated based on the transform
var rotation = Math.atan2(-m.xy, m.yy) * 180 / Math.PI;
// Reverse the rotation, leaving the final transform in box space
var rad = rotation * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
var transform = new Transform(
(m.xx * cos - m.xy * sin),
(m.yx * cos - m.yy * sin) * flip,
(m.xy * cos + m.xx * sin) * flip,
(m.yy * cos + m.yx * sin)
);
var rotationTransform = new Transform().rotate(rotation, 0, 0);
var shapeToBox = new Transform().rotate(-rotation, 0, 0).transform(m).moveTo(0,0);
// Scale box after reversing rotation
width *= Math.abs(shapeToBox.xx);
height *= Math.abs(shapeToBox.yy);
// Place box
var left = m.x, top = m.y;
// Compensate for offset by center origin rotation
var vx = -width / 2, vy = -height / 2;
var point = rotationTransform.point(vx, vy);
left -= point.x - vx;
top -= point.y - vy;
// Adjust box position based on offset
var rsm = new Transform(m).moveTo(0,0);
point = rsm.point(originX, originY);
left += point.x;
top += point.y;
if (flip < 0) left = -left - width;
// Place transformation origin
var point0 = rsm.point(-originX, -originY);
var point1 = rotationTransform.point(width, height);
var point2 = rotationTransform.point(width, 0);
var point3 = rotationTransform.point(0, height);
var minX = Math.min(0, point1.x, point2.x, point3.x),
maxX = Math.max(0, point1.x, point2.x, point3.x),
minY = Math.min(0, point1.y, point2.y, point3.y),
maxY = Math.max(0, point1.y, point2.y, point3.y);
var transformOriginX = (point0.x - point1.x / 2) / (maxX - minX) * flip,
transformOriginY = (point0.y - point1.y / 2) / (maxY - minY);
// Adjust the origin
point = shapeToBox.point(originX, originY);
originX = point.x;
originY = point.y;
// Scale stroke
var strokeWidth = this._strokeWidth;
if (strokeWidth){
// Scale is the hypothenus between the two vectors
// TODO: Use area calculation instead
var vx = m.xx + m.xy, vy = m.yy + m.yx;
strokeWidth *= Math.sqrt(vx * vx + vy * vy) / Math.sqrt(2);
}
// convert to multiplied precision space
originX *= precision;
originY *= precision;
left *= precision;
top *= precision;
width *= precision;
height *= precision;
// Set box
var element = this.element;
element.coordorigin = originX + ',' + originY;
element.coordsize = width + ',' + height;
element.style.left = left + 'px';
element.style.top = top + 'px';
element.style.width = width;
element.style.height = height;
element.style.rotation = rotation.toFixed(8);
element.style.flip = flip < 0 ? 'x' : '';
// Set transform
var skew = this.skewElement;
skew.matrix = [transform.xx.toFixed(4), transform.xy.toFixed(4), transform.yx.toFixed(4), transform.yy.toFixed(4), 0, 0];
skew.origin = transformOriginX + ',' + transformOriginY;
// Set stroke
this.strokeElement.weight = strokeWidth + 'px';
},
/* styles */
_createGradient: function(style, stops){
var fill = this.fillElement;
// Temporarily eject the fill from the DOM
this.element.removeChild(fill);
fill.type = style;
fill.method = 'none';
fill.rotate = true;
var colors = [], color1, color2;
var addColor = function(offset, color){
color = Color.detach(color);
if (color1 == null) color1 = color2 = color;
else color2 = color;
colors.push(offset + ' ' + color[0]);
};
// Enumerate stops, assumes offsets are enumerated in order
if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++) addColor(i / l, stops[i]);
else for (var offset in stops) addColor(offset, stops[offset]);
fill.color = color1[0];
fill.color2 = color2[0];
//if (fill.colors) fill.colors.value = colors; else
fill.colors = colors;
// Opacity order gets flipped when color stops are specified
fill.opacity = color2[1];
fill['ao:opacity2'] = color1[1];
fill.on = true;
this.element.appendChild(fill);
return fill;
},
_setColor: function(type, color){
var element = type == 'fill' ? this.fillElement : this.strokeElement;
if (color == null){
element.on = false;
} else {
color = Color.detach(color);
element.color = color[0];
element.opacity = color[1];
element.on = true;
}
},
fill: function(color){
if (arguments.length > 1){
this.fillLinear(arguments);
} else {
this._boxCoords = defaultBox;
var fill = this.fillElement;
fill.type = 'solid';
fill.color2 = '';
fill['ao:opacity2'] = '';
if (fill.colors) fill.colors.value = '';
this._setColor('fill', color);
}
return this;
},
fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
var fill = this._createGradient('gradientradial', stops);
if (focusX == null) focusX = this.left + this.width * 0.5;
if (focusY == null) focusY = this.top + this.height * 0.5;
if (radiusY == null) radiusY = radiusX || (this.height * 0.5);
if (radiusX == null) radiusX = this.width * 0.5;
if (centerX == null) centerX = focusX;
if (centerY == null) centerY = focusY;
centerX += centerX - focusX;
centerY += centerY - focusY;
var box = this._boxCoords = {
left: centerX - radiusX * 2,
top: centerY - radiusY * 2,
width: radiusX * 4,
height: radiusY * 4
};
focusX -= box.left;
focusY -= box.top;
focusX /= box.width;
focusY /= box.height;
fill.focussize = '0 0';
fill.focusposition = focusX + ',' + focusY;
fill.focus = '50%';
this._transform();
return this;
},
fillLinear: function(stops, x1, y1, x2, y2){
var fill = this._createGradient('gradient', stops);
fill.focus = '100%';
if (arguments.length == 5){
var w = Math.abs(x2 - x1), h = Math.abs(y2 - y1);
this._boxCoords = {
left: Math.min(x1, x2),
top: Math.min(y1, y2),
width: w < 1 ? h : w,
height: h < 1 ? w : h
};
fill.angle = (360 + Math.atan2((x2 - x1) / h, (y2 - y1) / w) * 180 / Math.PI) % 360;
} else {
this._boxCoords = null;
fill.angle = (x1 == null) ? 0 : (90 + x1) % 360;
}
this._transform();
return this;
},
fillImage: function(url, width, height, left, top, color1, color2){
var fill = this.fillElement;
if (color1 != null){
color1 = Color.detach(color1);
if (color2 != null) color2 = Color.detach(color2);
fill.type = 'pattern';
fill.color = color1[0];
fill.color2 = color2 == null ? color1[0] : color2[0];
fill.opacity = color2 == null ? 0 : color2[1];
fill['ao:opacity2'] = color1[1];
} else {
fill.type = 'tile';
fill.color = '';
fill.color2 = '';
fill.opacity = 1;
fill['ao:opacity2'] = 1;
}
if (fill.colors) fill.colors.value = '';
fill.rotate = true;
fill.src = url;
fill.size = '1,1';
fill.position = '0,0';
fill.origin = '0,0';
fill.aspect = 'ignore'; // ignore, atleast, atmost
fill.on = true;
if (!left) left = 0;
if (!top) top = 0;
this._boxCoords = width ? { left: left + 0.5, top: top + 0.5, width: width, height: height } : null;
this._transform();
return this;
},
/* stroke */
stroke: function(color, width, cap, join){
var stroke = this.strokeElement;
this._strokeWidth = (width != null) ? width : 1;
stroke.weight = (width != null) ? width + 'px' : 1;
stroke.endcap = (cap != null) ? ((cap == 'butt') ? 'flat' : cap) : 'round';
stroke.joinstyle = (join != null) ? join : 'round';
this._setColor('stroke', color);
return this;
}
});

41
node_modules/art/modes/vml/clippingrectangle.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
var Class = require('../../core/class');
var Transform = require('../../core/transform');
var Container = require('../../dom/container');
var Node = require('./node');
module.exports = Class(Node, Container, {
element_initialize: Node.prototype.initialize,
initialize: function(width, height){
this.element_initialize('clippingrectangle');
this.width = width;
this.height = height;
},
_transform: function(){
var element = this.element;
element.clip = true;
element.coordorigin = -this.x + ',' + (-1 * this.y);
element.coordsize = this.width + ',' + this.height;
// IE8 doesn't like clipBottom. Don't ask me why.
// element.style.clipBottom = this.height + this.y;
element.style.clipLeft = this.x;
element.style.clipRight = this.width + this.x;
element.style.clipTop = this.y;
element.style.left = -this.x;
element.style.top = -this.y;
element.style.width = this.width + this.x;
element.style.height = this.height + this.y;
element.style.rotation = 0;
var container = this.parentNode;
this._activeTransform = container ? new Transform(container._activeTransform).transform(this) : this;
var node = this.firstChild;
while (node){
node._transform();
node = node.nextSibling;
}
}
});

37
node_modules/art/modes/vml/dom.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var VMLCSS = 'behavior:url(#default#VML);display:inline-block;position:absolute;left:0px;top:0px;';
var styleSheet, styledTags = {}, styleTag = function(tag){
if (styleSheet) styledTags[tag] = styleSheet.addRule('av\\:' + tag, VMLCSS);
};
exports.init = function(document){
var namespaces;
try { // IE9 workaround: sometimes it throws here
namespaces = document.namespaces;
} catch (e) {
}
if (!namespaces) return false;
namespaces.add('av', 'urn:schemas-microsoft-com:vml');
namespaces.add('ao', 'urn:schemas-microsoft-com:office:office');
styleSheet = document.createStyleSheet();
styleSheet.addRule('vml', 'display:inline-block;position:relative;overflow:hidden;');
/* styleTag('skew');
styleTag('fill');
styleTag('stroke');
styleTag('path');
styleTag('textpath');
styleTag('group');*/
styleTag('vml');
return true;
};
exports.createElement = function(tag){
if (!(tag in styledTags)) styleTag(tag);
return document.createElement('av:' + tag);
};

35
node_modules/art/modes/vml/group.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var Class = require('../../core/class');
var Transform = require('../../core/transform');
var Container = require('../../dom/container');
var Node = require('./node');
module.exports = Class(Node, Container, {
element_initialize: Node.prototype.initialize,
initialize: function(width, height){
this.element_initialize('group');
this.width = width;
this.height = height;
},
_transform: function(){
var element = this.element;
element.coordorigin = '0,0';
element.coordsize = '1000,1000';
element.style.left = 0;
element.style.top = 0;
element.style.width = 1000;
element.style.height = 1000;
element.style.rotation = 0;
var container = this.parentNode;
this._activeTransform = container ? new Transform(container._activeTransform).transform(this) : this;
var node = this.firstChild;
while (node){
node._transform();
node = node.nextSibling;
}
}
});

40
node_modules/art/modes/vml/node.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
var Class = require('../../core/class');
var Transform = require('../../core/transform');
var Element = require('../../dom/shadow');
var DOM = require('./dom');
module.exports = Class(Element, Transform, {
initialize: function(tag){
//this.uid = uniqueID();
var element = this.element = DOM.createElement(tag);
//element.setAttribute('id', 'e' + this.uid);
},
_place: function(){
if (this.parentNode){
this._transform();
}
},
// visibility
hide: function(){
this.element.style.display = 'none';
return this;
},
show: function(){
this.element.style.display = '';
return this;
},
// interaction
indicate: function(cursor, tooltip){
if (cursor) this.element.style.cursor = cursor;
if (tooltip) this.element.title = tooltip;
return this;
}
});

69
node_modules/art/modes/vml/path.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
var Class = require('../../core/class');
var Path = require('../../core/path');
var precision = 100;
var round = Math.round;
var VMLPath = Class(Path, {
initialize: function(path){
this.reset();
if (path instanceof VMLPath){
this.path = [Array.prototype.join.call(path.path, ' ')];
} else if (path){
if (path.applyToPath)
path.applyToPath(this);
else
this.push(path);
}
},
onReset: function(){
this.path = [];
},
onMove: function(sx, sy, x, y){
this.path.push('m', round(x * precision), round(y * precision));
},
onLine: function(sx, sy, x, y){
this.path.push('l', round(x * precision), round(y * precision));
},
onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
this.path.push('c',
round(p1x * precision), round(p1y * precision),
round(p2x * precision), round(p2y * precision),
round(x * precision), round(y * precision)
);
},
_arcToBezier: Path.prototype.onArc,
onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
cx *= precision;
cy *= precision;
rx *= precision;
this.path.push(ccw ? 'at' : 'wa',
round(cx - rx), round(cy - rx),
round(cx + rx), round(cy + rx),
round(sx * precision), round(sy * precision),
round(ex * precision), round(ey * precision)
);
},
onClose: function(){
this.path.push('x');
},
toVML: function(){
return this.path.join(' ');
}
});
VMLPath.prototype.toString = VMLPath.prototype.toVML;
module.exports = VMLPath;

102
node_modules/art/modes/vml/shape.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
var Class = require('../../core/class');
var Base = require('./base');
var Path = require('./path');
var DOM = require('./dom');
var precision = 100;
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(path, width, height){
this.base_initialize('shape');
var p = this.pathElement = DOM.createElement('path');
p.gradientshapeok = true;
this.element.appendChild(p);
this.width = width;
this.height = height;
if (path != null) this.draw(path);
},
// SVG to VML
draw: function(path, width, height){
if (!(path instanceof Path)) path = new Path(path);
this._vml = path.toVML();
//this._size = path.measure();
if (width != null) this.width = width;
if (height != null) this.height = height;
if (!this._boxCoords) this._transform();
this._redraw(this._prefix, this._suffix);
return this;
},
// radial gradient workaround
_redraw: function(prefix, suffix){
var vml = this._vml || '';
this._prefix = prefix;
this._suffix = suffix
if (prefix){
vml = [
prefix, vml, suffix,
// Don't stroke the path with the extra ellipse, redraw the stroked path separately
'ns e', vml, 'nf'
].join(' ');
}
this.element.path = vml + 'e';
},
fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
var fill = this._createGradient('gradientradial', stops);
if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
if (radiusX == null) radiusX = (this.width || 0) * 0.5;
if (centerX == null) centerX = focusX;
if (centerY == null) centerY = focusY;
centerX += centerX - focusX;
centerY += centerY - focusY;
var cx = Math.round(centerX * precision),
cy = Math.round(centerY * precision),
rx = Math.round(radiusX * 2 * precision),
ry = Math.round(radiusY * 2 * precision),
arc = ['wa', cx - rx, cy - ry, cx + rx, cy + ry].join(' ');
this._redraw(
// Resolve rendering bug
['m', cx, cy - ry, 'l', cx, cy - ry].join(' '),
// Draw an ellipse around the path to force an elliptical gradient on any shape
[
'm', cx, cy - ry,
arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry,
arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry
].join(' ')
);
this._boxCoords = { left: focusX - 2, top: focusY - 2, width: 4, height: 4 };
fill.focusposition = '0.5,0.5';
fill.focussize = '0 0';
fill.focus = '50%';
this._transform();
return this;
}
});

41
node_modules/art/modes/vml/surface.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Element = require('../../dom/native');
var DOM = require('./dom');
var precision = 100;
var VMLSurface = Class(Element, Container, {
initialize: function VMLSurface(width, height, existingElement){
this.element = existingElement || document.createElement('vml');
this.containerElement = DOM.createElement('group');
this.element.appendChild(this.containerElement);
if (width != null && height != null) this.resize(width, height);
},
resize: function(width, height){
this.width = width;
this.height = height;
var style = this.element.style;
style.pixelWidth = width;
style.pixelHeight = height;
style = this.containerElement.style;
style.width = width;
style.height = height;
var halfPixel = (0.5 * precision);
this.containerElement.coordorigin = halfPixel + ',' + halfPixel;
this.containerElement.coordsize = (width * precision) + ',' + (height * precision);
return this;
}
});
VMLSurface.tagName = 'av:vml';
module.exports = VMLSurface;

108
node_modules/art/modes/vml/text.js generated vendored Normal file
View File

@@ -0,0 +1,108 @@
var Class = require('../../core/class');
var Base = require('./base');
var Path = require('./path');
var Surface = require('./surface');
var Group = require('./group');
var DOM = require('./dom');
var fontAnchors = { start: 'left', middle: 'center', end: 'right' };
module.exports = Class(Base, {
base_initialize: Base.prototype.initialize,
initialize: function(text, font, alignment, path){
this.base_initialize('shape');
var p = this.pathElement = DOM.createElement('path');
p.textpathok = true;
this.element.appendChild(p);
p = this.textPathElement = DOM.createElement("textpath");
p.on = true;
p.style['v-text-align'] = 'left';
this.element.appendChild(p);
this.draw.apply(this, arguments);
},
draw: function(text, font, alignment, path){
var element = this.element,
textPath = this.textPathElement,
style = textPath.style;
textPath.string = text;
if (font){
if (typeof font == 'string'){
style.font = font;
} else {
for (var key in font){
var ckey = key.camelCase ? key.camelCase() : key;
if (ckey == 'fontFamily') style[ckey] = "'" + font[key] + "'";
// NOT UNIVERSALLY SUPPORTED OPTIONS
// else if (ckey == 'kerning') style['v-text-kern'] = !!font[key];
// else if (ckey == 'rotateGlyphs') style['v-rotate-letters'] = !!font[key];
// else if (ckey == 'letterSpacing') style['v-text-spacing'] = Number(font[key]) + '';
else style[ckey] = font[key];
}
}
}
if (alignment) style['v-text-align'] = fontAnchors[alignment] || alignment;
if (path){
this.currentPath = path = new Path(path);
this.element.path = path.toVML();
} else if (!this.currentPath){
var i = -1, offsetRows = '\n';
while ((i = text.indexOf('\n', i + 1)) > -1) offsetRows += '\n';
textPath.string = offsetRows + textPath.string;
this.element.path = 'm0,0l1,0';
}
// Measuring the bounding box is currently necessary for gradients etc.
// Clone element because the element is dead once it has been in the DOM
element = element.cloneNode(true);
style = element.style;
// Reset coordinates while measuring
element.coordorigin = '0,0';
element.coordsize = '10000,10000';
style.left = '0px';
style.top = '0px';
style.width = '10000px';
style.height = '10000px';
style.rotation = 0;
element.removeChild(element.firstChild); // Remove skew
// Inject the clone into the document
var canvas = new Surface(1, 1),
group = new Group(), // Wrapping it in a group seems to alleviate some client rect weirdness
body = element.ownerDocument.body;
canvas.inject(body);
group.element.appendChild(element);
group.inject(canvas);
var ebb = element.getBoundingClientRect(),
cbb = canvas.toElement().getBoundingClientRect();
canvas.eject();
this.left = ebb.left - cbb.left;
this.top = ebb.top - cbb.top;
this.width = ebb.right - ebb.left;
this.height = ebb.bottom - ebb.top;
this.right = ebb.right - cbb.left;
this.bottom = ebb.bottom - cbb.top;
this._transform();
//this._size = { left: this.left, top: this.top, width: this.width, height: this.height};
return this;
}
});

152
node_modules/art/morph/path.js generated vendored Normal file
View File

@@ -0,0 +1,152 @@
var Class = require('../core/class');
var Path = require('../core/path');
var MOVE = 0, CURVE = 1;
var MorphablePath = Class(Path, {
initialize: function(path){
this.reset();
if (path instanceof MorphablePath){
this.path = path.path.slice(0);
} else if (path){
this.push(path);
}
},
onReset: function(){
this.path = [];
},
onMove: function(sx, sy, x, y){
this.path.push(MOVE, x, y);
},
onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
this.path.push(CURVE, p1x, p1y, p2x, p2y, x, y);
}
});
var Tween = Class({
initialize: function(from, to){
if (!(from instanceof MorphablePath)) from = new MorphablePath(from);
if (!(to instanceof MorphablePath)) to = new MorphablePath(to);
this.from = from.path;
this.to = to.path;
this.delta = 0;
},
tween: function(delta){
this.delta = delta;
},
applyToPath: function(path){
var f = this.from, t = this.to, r = path,
fi = 0, ti = 0, x, y, delta = this.delta;
r.reset();
// Unrolled and inlined for performance
while (fi < f.length || ti < t.length){
if (fi >= f.length){
// FROM is over limit but TO is not
x = f[fi - 2];
y = f[fi - 1];
if (t[ti] === MOVE){
r.moveTo(
(t[ti + 1] - x) * delta + x,
(t[ti + 2] - y) * delta + y
);
ti += 3;
} else {
r.curveTo(
(t[ti + 1] - x) * delta + x,
(t[ti + 2] - y) * delta + y,
(t[ti + 3] - x) * delta + x,
(t[ti + 4] - y) * delta + y,
(t[ti + 5] - x) * delta + x,
(t[ti + 6] - y) * delta + y
);
ti += 7;
}
} else if (ti >= t.length){
// TO is over limit but FROM is not
x = t[ti - 2];
y = t[ti - 1];
if (f[fi] === MOVE){
r.moveTo(
(x - f[fi + 1]) * delta + f[fi + 1],
(y - f[fi + 2]) * delta + f[fi + 2]
);
fi += 3;
} else {
r.curveTo(
(x - f[fi + 1]) * delta + f[fi + 1],
(y - f[fi + 2]) * delta + f[fi + 2],
(x - f[fi + 3]) * delta + f[fi + 3],
(y - f[fi + 4]) * delta + f[fi + 4],
(x - f[fi + 5]) * delta + f[fi + 5],
(y - f[fi + 6]) * delta + f[fi + 6]
);
fi += 7;
}
} else if (f[fi] === MOVE){
if (t[ti] === MOVE){
// Both are moving
r.moveTo(
(t[ti + 1] - f[fi + 1]) * delta + f[fi + 1],
(t[ti + 2] - f[fi + 2]) * delta + f[fi + 2]
);
fi += 3;
ti += 3;
} else {
// FROM is moving but TO has a curve
x = f[fi - 2];
y = f[fi - 1];
r.curveTo(
(t[ti + 1] - x) * delta + x,
(t[ti + 2] - y) * delta + y,
(t[ti + 3] - x) * delta + x,
(t[ti + 4] - y) * delta + y,
(t[ti + 5] - x) * delta + x,
(t[ti + 6] - y) * delta + y
);
ti += 7;
}
} else {
if (t[ti] === MOVE){
// TO is moving but FROM has a curve
x = t[ti - 2];
y = t[ti - 1];
r.curveTo(
(x - f[fi + 1]) * delta + f[fi + 1],
(y - f[fi + 2]) * delta + f[fi + 2],
(x - f[fi + 3]) * delta + f[fi + 3],
(y - f[fi + 4]) * delta + f[fi + 4],
(x - f[fi + 5]) * delta + f[fi + 5],
(y - f[fi + 6]) * delta + f[fi + 6]
);
fi += 7;
} else {
// Both have a curve
r.curveTo(
(t[ti + 1] - f[fi + 1]) * delta + f[fi + 1],
(t[ti + 2] - f[fi + 2]) * delta + f[fi + 2],
(t[ti + 3] - f[fi + 3]) * delta + f[fi + 3],
(t[ti + 4] - f[fi + 4]) * delta + f[fi + 4],
(t[ti + 5] - f[fi + 5]) * delta + f[fi + 5],
(t[ti + 6] - f[fi + 6]) * delta + f[fi + 6]
);
fi += 7;
ti += 7;
}
}
}
}
});
exports.Path = MorphablePath;
exports.Tween = Tween;

93
node_modules/art/package.json generated vendored Normal file
View File

@@ -0,0 +1,93 @@
{
"_args": [
[
"art@^0.10.0",
"/home/bernhard/freifunk-app/node_modules/react-native"
]
],
"_from": "art@>=0.10.0 <0.11.0",
"_id": "art@0.10.3",
"_inCache": true,
"_installable": true,
"_location": "/art",
"_nodeVersion": "8.7.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/art_0.10.3_1531414591878_0.8484544410253327"
},
"_npmUser": {
"email": "sebastian@calyptus.eu",
"name": "sebmarkbage"
},
"_npmVersion": "5.5.1",
"_phantomChildren": {},
"_requested": {
"name": "art",
"raw": "art@^0.10.0",
"rawSpec": "^0.10.0",
"scope": null,
"spec": ">=0.10.0 <0.11.0",
"type": "range"
},
"_requiredBy": [
"/react-native"
],
"_resolved": "https://registry.npmjs.org/art/-/art-0.10.3.tgz",
"_shasum": "b01d84a968ccce6208df55a733838c96caeeaea2",
"_shrinkwrap": null,
"_spec": "art@^0.10.0",
"_where": "/home/bernhard/freifunk-app/node_modules/react-native",
"author": {
"name": "Sebastian Markbage"
},
"bugs": {
"url": "https://github.com/sebmarkbage/art/issues"
},
"dependencies": {},
"description": "Cross-browser Vector Graphics",
"devDependencies": {},
"directories": {},
"dist": {
"fileCount": 111,
"integrity": "sha512-HXwbdofRTiJT6qZX/FnchtldzJjS3vkLJxQilc3Xj+ma2MXjY4UAyQ0ls1XZYVnDvVIBiFZbC6QsvtW86TD6tQ==",
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbR4hACRA9TVsSAnZWagAAoOYP/R5LEkBj1Ab+Rf8zw6R9\ngAWMjHMEgLdgjl/Wo2u0hiJ+xOCIRvSGG1t/r37r8ScqhbwjuzgBawSruMy6\nMqlp6jgyzRJXpCFkdMNNUHDZtWr/49b5dzpR+GXmX+Oz5XbGWBmWxzyqSeiR\nUpWhJA4uYuQiZmfaCcMYrtps14vW0J2K5QbgpD55oFH/2PF6hJGcR/KewRn+\nxhNUw98FVZen+PDcfBtv/Ry7SN+6Y+fnG9g+D8ryyXnVR3R/xoRlQiT5Hy/2\nGjSkNKcXCfcVSt6uK1FkJSt5Xrl0l3P6PI3+6ovj2PgfJo5lkEG9FdPEw9SW\nsaqg3FmrOae0fYpROZ1Ka8uuTAzW9N/nOeI9RL10/g2FooFXE3EwoFlh/lK4\nG/+hXMe3rEh9Y4mkYrwYf2rGsTe2tOIb+QKpsAjUTQxjCibV4/AJ7KYASib/\nIOMzYIKIJNVxLWe6Nxfbf/6SMpSEGPJe7Diof4jFiHJJsBuZ7njQp9YBIUVF\nKh4bcgEQBHE6Tm7bKbLMn85+TBtbKvkw+UnOTnkIP0ad4Sr7EE9XAS4a96YJ\nDytglN9gJaHZjJKGHqH3b7YPueq0StTowaw46ky+SjInOkVWxCmKmWa4F1na\ncm1P1hhSaxqG/5SKmiORBUv6Mvcm3Irl2hOgSAxBozfh7+6F4+vVDF+p5dvr\nQe5E\r\n=OF+Z\r\n-----END PGP SIGNATURE-----\r\n",
"shasum": "b01d84a968ccce6208df55a733838c96caeeaea2",
"tarball": "https://registry.npmjs.org/art/-/art-0.10.3.tgz",
"unpackedSize": 230059
},
"engines": {
"node": "*"
},
"gitHead": "20b1462e35c330b60c746112feb6640edc1f18b3",
"homepage": "http://sebmarkbage.github.io/art",
"keywords": [
"art",
"canvas",
"svg",
"vml"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "kamicane",
"email": "kamicane@gmail.com"
},
{
"name": "sebmarkbage",
"email": "sebastian@calyptus.eu"
},
{
"name": "zpao",
"email": "paul@oshannessy.com"
}
],
"name": "art",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/sebmarkbage/art.git"
},
"version": "0.10.3"
}

10
node_modules/art/parsers/svg.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
var core = require('./svg/core');
require('./svg/externals');
require('./svg/colors');
require('./svg/fonts');
require('./svg/markers');
require('./svg/paints');
require('./svg/shapes');
require('./svg/styles');
require('./svg/text');
module.exports = core;

158
node_modules/art/parsers/svg/colors.js generated vendored Normal file
View File

@@ -0,0 +1,158 @@
var SVGParser = require('./core');
var parseColor = SVGParser.prototype.parseColor,
namedColors = {
// Colors already in the Color class are commented out
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',
darkgreen: '#006400',
darkgrey: '#a9a9a9',
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',
// green: '#008000',
greenyellow: '#adff2f',
grey: '#808080',
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',
lightgreen: '#90ee90',
lightgrey: '#d3d3d3',
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: '#9370db',
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: '#db7093',
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'
};
SVGParser.prototype.parseColor = function(value, opacity, styles){
if (value == 'currentColor') value = styles.color;
return parseColor.call(this, namedColors[value] || value, opacity, styles);
};

417
node_modules/art/parsers/svg/core.js generated vendored Normal file
View File

@@ -0,0 +1,417 @@
var Class = require('../../core/class');
var Color = require('../../core/color');
var Mode = require('../../modes/current');
var Rectangle = require('../../shapes/rectangle');
// Regular Expressions
var matchURL = /^\s*url\(["'\s]*([^\)]*?)["'\s]*\)/,
requiredNumber = '(?:\\s+|\\s*,\\s*)([^\\s,\\)]+)';
number = '(?:' + requiredNumber + ')?',
matchViewBox = new RegExp('^\\s*([^\\s,]+)' + requiredNumber + requiredNumber + requiredNumber),
matchUnit = /^\s*([\+\-\d\.]+(?:e\d+)?)(|px|em|ex|in|pt|pc|mm|cm|%)\s*$/i;
// Environment Settings
var dpi = 72, emToEx = 0.5;
var styleSheet = function(){},
defaultStyles = {
'viewportWidth': 500,
'viewportHeight': 500,
'font-family': 'Arial',
'font-size': 12,
'color': 'black',
'fill': 'black'
},
nonInheritedStyles = {
'stop-color': 'black',
'stop-opacity': 1,
'clip-path': null,
'filter': null,
'mask': null,
'opacity': 1,
'cursor': null
};
// Visitor
var SVGParser = Class({
initialize: function(mode){
this.MODE = mode;
},
// TODO Fix this silly API
parseAsSurface: function(element, styles){
return this.parse(element, styles, true);
},
parse: function(element, styles, asSurface){
if (typeof element == 'string') element = this.parseXML(element);
if (!styles)
styles = this.findStyles(element);
else
for (var style in defaultStyles)
if (!(style in styles))
styles[style] = defaultStyles[style];
if (element.documentElement || asSurface){
element = element.documentElement || element;
var canvas = new this.MODE.Surface(
this.parseLength(element.getAttribute('width') || '100%', styles, 'x'),
this.parseLength(element.getAttribute('height') || '100%', styles, 'y')
);
if (element.getAttribute('viewBox'))
canvas.grab(this.parse(element, styles));
else
this.container(element, this.parseStyles(element, styles), canvas);
return canvas;
}
if (element.nodeType != 1 || element.getAttribute('requiredExtensions') || element.getAttribute('systemLanguage') != null) return null;
styles = this.parseStyles(element, styles);
var parseFunction = this[element.nodeName + 'Element'];
return parseFunction ? parseFunction.call(this, element, styles) : null;
},
parseXML: window.DOMParser ? function(text){
return new DOMParser().parseFromString(text, 'text/xml');
} : function(text){
try {
var xml;
try { xml = new ActiveXObject('MSXML2.DOMDocument'); }
catch (e){ xml = new ActiveXObject('Microsoft.XMLDOM'); }
xml.resolveExternals = false;
xml.validateOnParse = false;
xml.async = false;
xml.preserveWhiteSpace = true;
xml.loadXML(text);
return xml;
} catch (e){
return null;
}
},
parseStyles: function(element, styles){
styleSheet.prototype = styles;
var newSheet = new styleSheet();
for (var key in nonInheritedStyles) newSheet[key] = nonInheritedStyles[key];
this.applyStyles(element, newSheet);
if (newSheet.hasOwnProperty('font-size')){
var newFontSize = this.parseLength(newSheet['font-size'], styles, 'font');
if (newFontSize != null) newSheet['font-size'] = newFontSize;
}
if (newSheet.hasOwnProperty('text-decoration')){
newSheet['text-decoration-color'] = newSheet.color;
}
return newSheet;
},
findStyles: function(element){
if (!element || element.nodeType != 1) return defaultStyles;
var styles = this.findStyles(element.parentNode);
return this.parseStyles(element, styles);
},
applyStyles: function(element, target){
var attributes = element.attributes;
for (var i = 0, l = attributes.length; i < l; i++){
var attribute = attributes[i],
name = attribute.nodeName,
value = attribute.nodeValue;
if (value != 'inherit'){
target[name] = value;
if (name == 'fill') target['fill_document'] = element.ownerDocument;
}
}
return target;
},
findById: function(document, id){
// if (document.getElementById) return document.getElementById(id); Not reliable
if (this.cacheDocument != document){
this.ids = {};
this.lastSweep = null;
this.cacheDocument = document;
}
var ids = this.ids;
if (ids[id] != null) return ids[id];
var root = document.documentElement, node = this.lastSweep || root;
treewalker: while (node){
if (node.nodeType == 1){
var newID = node.getAttribute('id') || node.getAttribute('xml:id');
if (newID && ids[newID] == null) ids[newID] = node;
if (newID == id){
this.lastSweep = node;
return node;
}
}
if (node.firstChild){
node = node.firstChild;
} else {
while (!node.nextSibling){
node = node.parentNode;
if (!node || node == root) break treewalker;
}
node = node.nextSibling;
}
}
return null;
},
findByURL: function(document, url, callback){
callback.call(this, url && url[0] == '#' ? this.findById(document, url.substr(1)) : null);
},
resolveURL: function(url){
return url;
},
parseLength: function(value, styles, dimension){
var match = matchUnit.exec(value);
if (!match) return null;
var result = parseFloat(match[1]);
switch(match[2]){
case '': case 'px': return result;
case 'em': return result * styles['font-size'];
case 'ex': return result * styles['font-size'] * emToEx;
case 'in': return result * dpi;
case 'pt': return result * dpi / 72;
case 'pc': return result * dpi / 6;
case 'mm': return result * dpi / 25.4;
case 'cm': return result * dpi / 2.54;
case '%':
var w = styles.viewportWidth, h = styles.viewportHeight;
if (dimension == 'font') return result * styles['font-size'] / 100;
if (dimension == 'x') return result * w / 100;
if (dimension == 'y') return result * h / 100;
return result * Math.sqrt(w * w + h * h) / Math.sqrt(2) / 100;
}
},
parseColor: function(value, opacity, styles){
if (value == 'currentColor') value = styles.color;
try {
var color = new Color(value);
} catch (x){
// Ignore unparsable colors, TODO: log
return null;
}
color.alpha = opacity == null ? 1 : +opacity;
return color;
},
getLengthAttribute: function(element, styles, attr, dimension){
return this.parseLength(element.getAttribute(attr) || 0, styles, dimension);
},
container: function(element, styles, container){
if (container.width != null) styles.viewportWidth = container.width;
if (container.height != null) styles.viewportHeight = container.height;
this.filter(styles, container);
this.describe(element, styles, container);
var node = element.firstChild;
while (node){
var art = this.parse(node, styles);
if (art) container.grab(art);
node = node.nextSibling;
}
return container;
},
shape: function(element, styles, target, x, y){
this.transform(element, target);
target.transform(1, 0, 0, 1, x, y);
this.fill(styles, target, x, y);
this.stroke(styles, target);
this.filter(styles, target);
if (styles.visibility == 'hidden') target.hide();
this.describe(element, styles, target);
return target;
},
fill: function(styles, target, x, y){
if (!styles.fill || styles.fill == 'none') return;
var match;
if (match = matchURL.exec(styles.fill)){
this.findByURL(styles.fill_document, match[1], function(fill){
var fillFunction = fill && this[fill.nodeName + 'Fill'];
if (fillFunction) fillFunction.call(this, fill, this.findStyles(fill), target, x, y);
});
} else {
target.fill(this.parseColor(styles.fill, styles['fill-opacity'], styles));
}
},
stroke: function(styles, target){
if (!styles.stroke || styles.stroke == 'none' || matchURL.test(styles.stroke)) return; // Advanced stroke colors are not supported, TODO: log
var color = this.parseColor(styles.stroke, styles['stroke-opacity'], styles),
width = this.parseLength(styles['stroke-width'], styles),
cap = styles['stroke-linecap'] || 'butt',
join = styles['stroke-linejoin'] || 'miter';
target.stroke(color, width == null ? 1 : width, cap, join);
},
filter: function(styles, target){
if (styles.opacity != 1 && target.blend) target.blend(styles.opacity);
if (styles.display == 'none') target.hide();
},
describe: function(element, styles, target){
var node = element.firstChild, title = '';
if (element.nodeName != 'svg')
while (node){
if (node.nodeName == 'title') title += node.firstChild && node.firstChild.nodeValue;
node = node.nextSibling;
}
if (styles.cursor || title) target.indicate(styles.cursor, title);
},
transform: function(element, target){
var transform = element.getAttribute('transform'), match;
var matchTransform = new RegExp('([a-z]+)\\s*\\(\\s*([^\\s,\\)]+)' + number + number + number + number + number + '\\s*\\)', 'gi');
while(match = transform && matchTransform.exec(transform)){
switch(match[1]){
case 'matrix':
target.transform(match[2], match[3], match[4], match[5], match[6], match[7]);
break;
case 'translate':
target.transform(1, 0, 0, 1, match[2], match[3]);
break;
case 'scale':
target.transform(match[2], 0, 0, match[3] || match[2]);
break;
case 'rotate':
var rad = match[2] * Math.PI / 180, cos = Math.cos(rad), sin = Math.sin(rad);
target.transform(1, 0, 0, 1, match[3], match[4])
.transform(cos, sin, -sin, cos)
.transform(1, 0, 0, 1, -match[3], -match[4]);
break;
case 'skewX':
target.transform(1, 0, Math.tan(match[2] * Math.PI / 180), 1);
break;
case 'skewY':
target.transform(1, Math.tan(match[2] * Math.PI / 180), 0, 1);
break;
}
}
},
svgElement: function(element, styles){
var viewbox = element.getAttribute('viewBox'),
match = matchViewBox.exec(viewbox),
x = this.getLengthAttribute(element, styles, 'x', 'x'),
y = this.getLengthAttribute(element, styles, 'y', 'y'),
width = this.getLengthAttribute(element, styles, 'width', 'x'),
height = this.getLengthAttribute(element, styles, 'height', 'y'),
group = match ? new this.MODE.Group(+match[3], +match[4]) : new this.MODE.Group(width || null, height || null);
if (width && height) group.resizeTo(width, height); // TODO: Aspect ratio
if (match) group.transform(1, 0, 0, 1, -match[1], -match[2]);
this.container(element, styles, group);
group.move(x, y);
return group;
},
gElement: function(element, styles){
var group = new this.MODE.Group();
this.transform(element, group);
this.container(element, styles, group);
return group;
},
useElement: function(element, styles){
var placeholder = new this.MODE.Group(),
x = this.getLengthAttribute(element, styles, 'x', 'x'),
y = this.getLengthAttribute(element, styles, 'y', 'y'),
width = this.getLengthAttribute(element, styles, 'width', 'x'),
height = this.getLengthAttribute(element, styles, 'height', 'y');
this.transform(element, placeholder);
placeholder.transform(1, 0, 0, 1, x, y);
this.findByURL(element.ownerDocument, element.getAttribute('xlink:href') || element.getAttribute('href'), function(target){
if (!target || target.nodeType != 1) return;
var parseFunction = target.nodeName == 'symbol' ? this.svgElement : this[target.nodeName + 'Element'];
if (!parseFunction) return;
styles = this.parseStyles(element, this.parseStyles(target, styles));
var symbol = parseFunction.call(this, target, styles);
if (!symbol) return;
if (width && height) symbol.resizeTo(width, height); // TODO: Aspect ratio, maybe resize the placeholder instead
placeholder.grab(symbol);
});
return placeholder;
},
switchElement: function(element, styles){
var node = element.firstChild;
while (node){
var art = this.parse(node, styles);
if (art) return art;
node = node.nextSibling;
}
return null;
},
aElement: function(element, styles){
// For now treat it like a group
return this.gElement(element, styles);
},
pathElement: function(element, styles){
var shape = new this.MODE.Shape(element.getAttribute('d') || null);
this.shape(element, styles, shape);
return shape;
},
imageElement: function(element, styles){
var href = this.resolveURL(element.getAttribute('xlink:href') || element.getAttribute('href')),
width = this.getLengthAttribute(element, styles, 'width', 'x'),
height = this.getLengthAttribute(element, styles, 'height', 'y'),
x = this.getLengthAttribute(element, styles, 'x', 'x'),
y = this.getLengthAttribute(element, styles, 'y', 'y'),
clipPath = element.getAttribute('clip-path'),
image,
match;
if (clipPath && (match = matchURL.exec(clipPath)) && match[1][0] == '#'){
var clip = this.findById(element.ownerDocument, match[1].substr(1));
if (clip){
image = this.switchElement(clip, styles);
if (image){
if (typeof image.fillImage == 'function'){
image.fillImage(href, width, height);
if (image.stroke) image.stroke(0);
} else {
image = null;
}
}
}
}
if (!image){
//image = new Image(href, width, height); TODO
image = new Rectangle(width, height).fillImage(href, width, height);
}
this.filter(styles, image);
if (styles.visibility == 'hidden') target.hide();
this.describe(element, styles, image);
this.transform(element, image);
image.transform(1, 0, 0, 1, x, y);
return image;
}
});
SVGParser.parse = function(element, styles){
return new SVGParser(Mode).parse(element, styles);
};
SVGParser.implement = function(obj){
for (var key in obj)
this.prototype[key] = obj[key];
};
module.exports = SVGParser;

73
node_modules/art/parsers/svg/externals.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
var SVGParser = require('./core');
var Mode = require('../../modes/current');
var urlSuffix = '', baseUrl, urlAliases = {},
urlParts = /^((?:\w+:)?(?:\/\/[^\/?#]*)?)(\.\.?$|(?:[^?#\/]*\/)*)(.*)/,
endSlash = /\/$/;
function resolvePath(path, base){
var parts = String(path).match(urlParts);
if (!parts || parts[1]) return path;
if (!base || path.charAt(0) !== '.') base = '';
base = String(base).match(urlParts);
var directory = parts[2];
if (directory.charAt(0) != '/'){
directory = (base[2] || '') + directory;
var result = [], paths = directory.replace(endSlash, '').split('/');
for (var i = 0, l = paths.length; i < l; i++){
var dir = paths[i];
if (dir === '..' && result.length > 0 && result[result.length - 1] != '..') result.pop();
else if (dir !== '.') result.push(dir);
};
directory = result.join('/') + '/';
}
return base[1] + directory + parts[3];
}
SVGParser.prototype.findByURL = function(document, url, callback){
if (!url){
callback.call(this, null);
return;
}
if (url.charAt(0) == '#'){
callback.call(this, this.findById(document, url.substr(1)));
return;
}
url = this.resolveURL(url);
var self = this, i = url.indexOf('#'), id = i > -1 ? url.substr(i + 1) : null;
if (i > -1) url = url.substr(0, i);
this.pendingRequests = (this.pendingRequests || 0) + 1;
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function(){
if (xhr.readyState == 4){
if (xhr.status == 200){
var resolve = self.resolveURL,
doc = /*xhr.responseXML ||*/ self.parseXML(xhr.responseText);
self.resolveURL = function(newurl){
return resolvePath(newurl, url);
}
callback.call(self, !doc ? null : id ? self.findById(doc, id) : doc.documentElement);
self.resolveURL = resolve;
} else {
callback.call(self, null);
}
if (--self.pendingRequests == 0 && self.oncomplete) self.oncomplete();
}
};
xhr.send(null);
};
SVGParser.prototype.load = function(url, styles, callback){
if (typeof styles == 'function'){ callback = styles; styles = null; }
var parser = this, result = null;
parser.oncomplete = function(){ callback(result); };
parser.findByURL(null, url, function(doc){ result = parser.parse(doc.ownerDocument, styles); });
};
SVGParser.load = function(url, styles, callback){
new SVGParser(Mode).load(url, styles, callback);
};

203
node_modules/art/parsers/svg/fonts.js generated vendored Normal file
View File

@@ -0,0 +1,203 @@
var Class = require('../../core/class');
var Path = require('../../core/path');
var SVGParser = require('./core');
var Font = require('../../shapes/font');
var parse = SVGParser.prototype.parse;
var matchFontURL = /url\(['"\s]*([^\)]*?)['"\s]*\)\s+format\(['"]?svg['"]?\)/i;
var trimFontFamily = /^['"\s]+|['"\s]+$|,.*$/g;
var fillFaceAttributes = function(element, face){
var attributes = element.attributes;
for (var i = 0, l = attributes.length; i < l; i++){
var attribute = attributes[i];
if (!(attribute.nodeName in face)){
face[attribute.nodeName] = attribute.nodeValue;
}
}
};
SVGParser.implement({
parse: function(element, styles){
if (element.documentElement && element != this.fontDocument){
this.fontDocument = element;
this.findFonts(element);
}
return parse.apply(this, arguments);
},
findFonts: function(document){
var fonts = this.fonts || (this.fonts = {});
var root = document.documentElement, node = root;
treewalker: while (node){
if (node.nodeType == 1 && node.nodeName == 'font-face'){
this.fontFace(node);
}
if (node.firstChild){
node = node.firstChild;
} else {
while (!node.nextSibling){
node = node.parentNode;
if (!node || node == root) break treewalker;
}
node = node.nextSibling;
}
}
if (this.findCSS){
var rules = this.findCSS(document).cssRules;
for (var i = 0, l = rules.length; i < l; i++){
var rule = rules[i];
if (rule.fontFace){
var url = matchFontURL.exec(rule.style.src);
if (url) this.fontURL(document, url[1], rule.style);
}
}
}
},
fontFace: function(element){
var face = {};
fillFaceAttributes(element, face);
if (element.parentNode.nodeName == 'font') this.font(element.parentNode, face);
var node = element.firstChild;
while (node){
if (node.nodeName == 'font-face-src'){
node = node.firstChild;
continue;
}
if (node.nodeName == 'font-face-uri'){
var url = node.getAttribute('xlink:href');
this.fontURL(element.ownerDocument, url, face);
}
node = node.nextSibling;
}
},
fontURL: function(document, url, face){
if (!face['font-family']) return;
var pendingFonts = this.pendingFonts || (this.pendingFonts = {});
var family = face['font-family'].replace(trimFontFamily, '');
var callbacks = pendingFonts[family] = [];
this.findByURL(document, url, function(font){
delete pendingFonts[family];
if (font){
var f = this.font(font, face);
for (var i = 0, l = callbacks.length; i < l; i++)
callbacks[i].call(this, f);
}
});
},
findFont: function(styles, callback){
var family = styles['font-family'].replace(trimFontFamily, '');
var callbacks = this.pendingFonts && this.pendingFonts[family];
if (callbacks){
callbacks.push(callback);
} else if (this.fonts){
callback.call(this, this.fonts[family]);
} else {
callback.call(this, null);
}
},
font: function(element, face){
var glyphs = {}, font = { face: face, glyphs: glyphs };
var w = element.getAttribute('horiz-adv-x');
if (w) font.w = parseInt(w, 10);
var node = element.firstChild;
while (node){
switch(node.nodeName){
case 'font-face':
fillFaceAttributes(node, face);
break;
case 'missing-glyph':
case 'glyph':
var glyph = {},
code = node.nodeName == 'missing-glyph' ? 'missing' : node.getAttribute('unicode'),
w = node.getAttribute('horiz-adv-x'),
d = node.getAttribute('d');
if (!code) break;
if (w) glyph.w = parseInt(w, 10);
if (d){
// Flip path
var path = new FlippedVMLPathAtNormalPrecision(d);
glyph.d = path.toVML().substr(1);
}
glyphs[code] = glyph;
break;
// TODO: Kerning
}
node = node.nextSibling;
}
var units = face['units-per-em'];
if (isNaN(units)) face['units-per-em'] = units = 1000;
if (face.ascent == null) face.ascent = face.descent == null ? 0.8 * units : units - face.descent;
if (face.descent == null) face.descent = face.ascent - units;
var family = face['font-family'];
if (!family) return;
face['font-family'] = family = family.replace(trimFontFamily, '');
var fonts = this.fonts || (this.fonts = {});
if (face.ascent) face.ascent = +face.ascent;
if (face.descent) face.descent = +face.descent;
fonts[family] = font;
if (this.MODE.Font)
this.MODE.Font.register(font);
else
Font.register(font);
return font;
}
});
var round = Math.round;
var FlippedVMLPathAtNormalPrecision = Class(Path, {
initialize: function(path){
this.reset();
if (path){
this.push(path);
}
},
onReset: function(){
this.path = [];
},
onMove: function(sx, sy, x, y){
this.path.push('m', round(x), -round(y));
},
onLine: function(sx, sy, x, y){
this.path.push('l', round(x), -round(y));
},
onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
this.path.push('c',
round(p1x), -round(p1y),
round(p2x), -round(p2y),
round(x), -round(y)
);
},
onClose: function(){
this.path.push('x');
},
toVML: function(){
return this.path.join(' ');
}
});

5
node_modules/art/parsers/svg/markers.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
var SVGParser = require('./core');
SVGParser.prototype.markerElement = function(){
// TODO
};

Some files were not shown because too many files have changed in this diff Show More