Commit cf76de4f by Dmitry Baranovskiy

Small fix + added ability to get current transformation.

parent 099c4102
......@@ -294,7 +294,12 @@ var Raphael = (function (type) {
if ("fill-opacity" in params || "opacity" in params) {
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) {
fill.color = params.fill;
}
......@@ -388,6 +393,14 @@ var Raphael = (function (type) {
this.attrs = {};
this.Group = group;
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) {
var gs = this.Group.style,
......@@ -446,12 +459,10 @@ var Raphael = (function (type) {
this.Group.style.display = "block";
return this;
};
Element.prototype.rotate = function (deg) {
Rotation += deg;
this.Group.style.rotation = Rotation;
return this;
};
Element.prototype.translate = function (x, y) {
if (x == undefined && y == undefined) {
return {x: this.X, y: this.Y};
}
this.X += x;
this.Y += y;
this.Group.style.left = this.X + "px";
......@@ -465,6 +476,10 @@ var Raphael = (function (type) {
return this;
};
Element.prototype.scale = function (x, y) {
if (x == undefined && y == undefined) {
return ;
// TODO
}
y = y || x;
if (x != 0 && !(x == 1 && y == 1)) {
var dirx = Math.round(x / Math.abs(x)),
......@@ -1056,16 +1071,10 @@ var Raphael = (function (type) {
this[0] = node;
this.attrs = this.attrs || {};
this.transformations = []; // rotate, translate, scale, matrix
};
Element.prototype.hide = function () {
this[0].style.display = "none";
return this;
};
Element.prototype.show = function () {
this[0].style.display = "block";
return this;
};
Element.prototype.rotate = function (deg) {
this.rotate = function (deg) {
if (deg == undefined) {
return Rotation.deg;
}
var bbox = this.getBBox();
Rotation.deg += deg;
if (Rotation.deg) {
......@@ -1076,7 +1085,10 @@ var Raphael = (function (type) {
this[0].setAttribute("transform", this.transformations.join(" "));
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;
Y += y;
if (X && Y) {
......@@ -1087,7 +1099,10 @@ var Raphael = (function (type) {
this[0].setAttribute("transform", this.transformations.join(" "));
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;
if (x != 0 && !(x == 1 && y == 1)) {
ScaleX *= x;
......@@ -1104,6 +1119,15 @@ var Raphael = (function (type) {
}
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
Element.prototype.matrix = function (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