Commit cf76de4f by Dmitry Baranovskiy

Small fix + added ability to get current transformation.

parent 099c4102
...@@ -294,7 +294,12 @@ var Raphael = (function (type) { ...@@ -294,7 +294,12 @@ var Raphael = (function (type) {
if ("fill-opacity" in params || "opacity" in params) { if ("fill-opacity" in params || "opacity" in params) {
fill.opacity = ((params["fill-opacity"] + 1 || 2) - 1) * ((params.opacity + 1 || 2) - 1); fill.opacity = ((params["fill-opacity"] + 1 || 2) - 1) * ((params.opacity + 1 || 2) - 1);
} }
fill.on = (params.fill && params.fill != "none"); if (params.fill) {
fill.on = true;
}
if (params.fill == "none") {
fill.on = false;
}
if (fill.on && params.fill) { if (fill.on && params.fill) {
fill.color = params.fill; fill.color = params.fill;
} }
...@@ -388,6 +393,14 @@ var Raphael = (function (type) { ...@@ -388,6 +393,14 @@ var Raphael = (function (type) {
this.attrs = {}; this.attrs = {};
this.Group = group; this.Group = group;
this.vml = vml; this.vml = vml;
this.rotate = function (deg) {
if (deg == undefined) {
return Rotation;
}
Rotation += deg;
this.Group.style.rotation = Rotation;
return this;
};
}; };
Element.prototype.setBox = function (params) { Element.prototype.setBox = function (params) {
var gs = this.Group.style, var gs = this.Group.style,
...@@ -446,12 +459,10 @@ var Raphael = (function (type) { ...@@ -446,12 +459,10 @@ var Raphael = (function (type) {
this.Group.style.display = "block"; this.Group.style.display = "block";
return this; return this;
}; };
Element.prototype.rotate = function (deg) {
Rotation += deg;
this.Group.style.rotation = Rotation;
return this;
};
Element.prototype.translate = function (x, y) { Element.prototype.translate = function (x, y) {
if (x == undefined && y == undefined) {
return {x: this.X, y: this.Y};
}
this.X += x; this.X += x;
this.Y += y; this.Y += y;
this.Group.style.left = this.X + "px"; this.Group.style.left = this.X + "px";
...@@ -465,6 +476,10 @@ var Raphael = (function (type) { ...@@ -465,6 +476,10 @@ var Raphael = (function (type) {
return this; return this;
}; };
Element.prototype.scale = function (x, y) { Element.prototype.scale = function (x, y) {
if (x == undefined && y == undefined) {
return ;
// TODO
}
y = y || x; y = y || x;
if (x != 0 && !(x == 1 && y == 1)) { if (x != 0 && !(x == 1 && y == 1)) {
var dirx = Math.round(x / Math.abs(x)), var dirx = Math.round(x / Math.abs(x)),
...@@ -1056,16 +1071,10 @@ var Raphael = (function (type) { ...@@ -1056,16 +1071,10 @@ var Raphael = (function (type) {
this[0] = node; this[0] = node;
this.attrs = this.attrs || {}; this.attrs = this.attrs || {};
this.transformations = []; // rotate, translate, scale, matrix this.transformations = []; // rotate, translate, scale, matrix
}; this.rotate = function (deg) {
Element.prototype.hide = function () { if (deg == undefined) {
this[0].style.display = "none"; return Rotation.deg;
return this; }
};
Element.prototype.show = function () {
this[0].style.display = "block";
return this;
};
Element.prototype.rotate = function (deg) {
var bbox = this.getBBox(); var bbox = this.getBBox();
Rotation.deg += deg; Rotation.deg += deg;
if (Rotation.deg) { if (Rotation.deg) {
...@@ -1076,7 +1085,10 @@ var Raphael = (function (type) { ...@@ -1076,7 +1085,10 @@ var Raphael = (function (type) {
this[0].setAttribute("transform", this.transformations.join(" ")); this[0].setAttribute("transform", this.transformations.join(" "));
return this; return this;
}; };
Element.prototype.translate = function (x, y) { this.translate = function (x, y) {
if (x == undefined && y == undefined) {
return {x: X, y: Y};
}
X += x; X += x;
Y += y; Y += y;
if (X && Y) { if (X && Y) {
...@@ -1087,7 +1099,10 @@ var Raphael = (function (type) { ...@@ -1087,7 +1099,10 @@ var Raphael = (function (type) {
this[0].setAttribute("transform", this.transformations.join(" ")); this[0].setAttribute("transform", this.transformations.join(" "));
return this; return this;
}; };
Element.prototype.scale = function (x, y) { this.scale = function (x, y) {
if (x == undefined && y == undefined) {
return {x: ScaleX, y: ScaleY};
}
y = y || x; y = y || x;
if (x != 0 && !(x == 1 && y == 1)) { if (x != 0 && !(x == 1 && y == 1)) {
ScaleX *= x; ScaleX *= x;
...@@ -1104,6 +1119,15 @@ var Raphael = (function (type) { ...@@ -1104,6 +1119,15 @@ var Raphael = (function (type) {
} }
return this; return this;
}; };
};
Element.prototype.hide = function () {
this[0].style.display = "none";
return this;
};
Element.prototype.show = function () {
this[0].style.display = "block";
return this;
};
// depricated // depricated
Element.prototype.matrix = function (xx, xy, yx, yy, dx, dy) { Element.prototype.matrix = function (xx, xy, yx, yy, dx, dy) {
this.transformations[3] = new Matrix(xx, xy, yx, yy, dx, dy); this.transformations[3] = new Matrix(xx, xy, yx, yy, dx, dy);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment