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

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