case "target":
var pn = node.parentNode;
if (pn.tagName.toLowerCase() != "a") {
- var hl = doc.createElementNS(o.svg.svgns, "a");
+ var hl = doc.createElementNS(o.paper.svgns, "a");
pn.insertBefore(hl, node);
hl.appendChild(node);
pn = hl;
}
- pn.setAttributeNS(o.svg.xlink, att, value);
+ pn.setAttributeNS(o.paper.xlink, att, value);
break;
case "path":
if (o.type == "path") {
break;
case "src":
if (o.type == "image") {
- node.setAttributeNS(o.svg.xlink, "href", value);
+ node.setAttributeNS(o.paper.xlink, "href", value);
}
break;
case "stroke-width":
case "fill":
var isURL = value.match(/^url\(([^\)]+)\)$/i);
if (isURL) {
- var el = doc.createElementNS(o.svg.svgns, "pattern");
- var ig = doc.createElementNS(o.svg.svgns, "image");
+ var el = doc.createElementNS(o.paper.svgns, "pattern");
+ var ig = doc.createElementNS(o.paper.svgns, "image");
el.id = "raphael-pattern-" + R.idGenerator++;
el.setAttribute("x", 0);
el.setAttribute("y", 0);
el.setAttribute("patternUnits", "userSpaceOnUse");
ig.setAttribute("x", 0);
ig.setAttribute("y", 0);
- ig.setAttributeNS(o.svg.xlink, "href", isURL[1]);
+ ig.setAttributeNS(o.paper.xlink, "href", isURL[1]);
el.appendChild(ig);
var img = doc.createElement("img");
};
doc.body.appendChild(img);
img.src = isURL[1];
- o.svg.defs.appendChild(el);
+ o.paper.defs.appendChild(el);
node.style.fill = "url(#" + el.id + ")";
node.setAttribute("fill", "url(#" + el.id + ")");
o.pattern = el;
node.setAttribute(att, R.getRGB(value).hex);
break;
case "gradient":
- addGradientFill(node, value, o.svg);
+ addGradientFill(node, value, o.paper);
break;
case "opacity":
case "fill-opacity":
}
var texts = (params.text + "").split("\n");
for (var i = 0, ii = texts.length; i < ii; i++) {
- var tspan = doc.createElementNS(el.svg.svgns, "tspan");
+ var tspan = doc.createElementNS(el.paper.svgns, "tspan");
i && tspan.setAttribute("dy", fontSize * leading);
i && tspan.setAttribute("x", a.x);
tspan.appendChild(doc.createTextNode(texts[i]));
Y = 0;
this[0] = node;
this.node = node;
- this.svg = svg;
+ this.paper = svg;
this.attrs = this.attrs || {};
this.transformations = []; // rotate, translate, scale
this._ = {
throw new Error("SVG container not found.");
}
paper.canvas = doc.createElementNS(paper.svgns, "svg");
- paper.canvas.setAttribute("width", width || 320);
- paper.width = width || 320;
- paper.canvas.setAttribute("height", height || 200);
- paper.height = height || 200;
+ paper.canvas.setAttribute("width", width || 512);
+ paper.width = width || 512;
+ paper.canvas.setAttribute("height", height || 342);
+ paper.height = height || 342;
if (container == 1) {
doc.body.appendChild(paper.canvas);
paper.canvas.style.position = "absolute";
this.Y = 0;
this.attrs = {};
this.Group = group;
- this.vml = vml;
+ this.paper = vml;
this._ = {
tx: 0,
ty: 0,
this._.rt.cy = cy;
this.setBox(null, cx, cy);
this.Group.style.rotation = this._.rt.deg;
+ // gradient fix for rotation. TODO
+ // var fill = (this.shape || this.node).getElementsByTagName("fill");
+ // fill = fill[0] || {};
+ // var b = ((360 - this._.rt.deg) - 270) % 360;
+ // typeof fill.angle != "undefined" && (fill.angle = b);
return this;
};
Element.prototype.setBox = function (params, cx, cy) {
if (!this.attrs.path) {
x = 0;
y = 0;
- w = this.vml.width;
- h = this.vml.height;
+ w = this.paper.width;
+ h = this.paper.height;
} else {
var dim = pathDimensions(this.attrs.path),
x = dim.x;
default:
x = 0;
y = 0;
- w = this.vml.width;
- h = this.vml.height;
+ w = this.paper.width;
+ h = this.paper.height;
break;
}
cx = (cx == null) ? x + w / 2 : cx;
cy = (cy == null) ? y + h / 2 : cy;
- var left = cx - this.vml.width / 2,
- top = cy - this.vml.height / 2;
+ var left = cx - this.paper.width / 2,
+ top = cy - this.paper.height / 2;
if (this.type == "path" || this.type == "text") {
(gs.left != left + "px") && (gs.left = left + "px");
(gs.top != top + "px") && (gs.top = top + "px");
this.Y = y;
this.W = w;
this.H = h;
- (gs.width != this.vml.width + "px") && (gs.width = this.vml.width + "px");
- (gs.height != this.vml.height + "px") && (gs.height = this.vml.height + "px");
+ (gs.width != this.paper.width + "px") && (gs.width = this.paper.width + "px");
+ (gs.height != this.paper.height + "px") && (gs.height = this.paper.height + "px");
(os.left != x - left + "px") && (os.left = x - left + "px");
(os.top != y - top + "px") && (os.top = y - top + "px");
(os.width != w + "px") && (os.width = w + "px");
cs = c.style, rs = r.style;
paper.width = width;
paper.height = height;
- width = width || "320px";
- height = height || "200px";
+ width = width || "512px";
+ height = height || "342px";
cs.clip = "rect(0 " + width + "px " + height + "px 0)";
cs.top = "-2px";
cs.left = "-2px";
} else {
skip = false;
}
- if (this.svg && p[0].toUpperCase() == "A") {
+ if (R.svg && p[0].toUpperCase() == "A") {
p[path[i].length - 2] *= x / this._.sx;
p[path[i].length - 1] *= y / this._.sy;
p[1] *= x / this._.sx;
R.ninja = function () {
var r = window.Raphael;
- // delete window.Raphael;
if (oldRaphael.was) {
window.Raphael = oldRaphael.is;
+ } else {
+ try {
+ delete window.Raphael;
+ } catch (e) {
+ window.Raphael = void(0);
+ }
}
return r;
};