Commit b636d54e authored by Viktor Lidholt's avatar Viktor Lidholt

Adds skew property to sprite node

parent e691a63e
......@@ -30,6 +30,9 @@ class Node {
double _scaleX = 1.0;
double _scaleY = 1.0;
double _skewX = 0.0;
double _skewY = 0.0;
/// The visibility of this node and its children.
bool visible = true;
......@@ -116,6 +119,22 @@ class Node {
invalidateTransformMatrix();
}
double get skewX => _skewX;
void set skewX (double skewX) {
assert(skewX != null);
_skewX = skewX;
invalidateTransformMatrix();
}
double get skewY => _skewY;
void set skewY (double skewY) {
assert(skewY != null);
_skewY = skewY;
invalidateTransformMatrix();
}
/// The draw order of this node compared to its parent and its siblings.
///
/// By default nodes are drawn in the order that they have been added to a parent. To override this behavior the
......@@ -295,6 +314,15 @@ class Node {
0.0, 0.0, 1.0, 0.0,
_position.x, _position.y, 0.0, 1.0);
if (_skewX != 0.0 || _skewY != 0.0) {
// Needs skew transform
Matrix4 skew = new Matrix4(1.0, math.tan(radians(_skewX)), 0.0, 0.0,
math.tan(radians(_skewY)), 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
matrix.multiply(skew);
}
return matrix;
}
......
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 to comment