Add comments about possible optimisations in PathItem#transformContent().

This commit is contained in:
Jürg Lehni 2011-02-14 01:14:03 +00:00
parent 739c5a669f
commit 3af5d549f6

View file

@ -148,11 +148,19 @@ PathItem = Item.extend(new function() {
transformContent: function(matrix, flags) { transformContent: function(matrix, flags) {
for (var i = 0, l = this._segments.length; i < l; i++) { for (var i = 0, l = this._segments.length; i < l; i++) {
var segment = this._segments[i]; var segment = this._segments[i];
// We need to convert handles to absolute coordinates in order
// to transform them.
// TODO: Is transformation even required if they are [0, 0]?
// TODO: Can we optimise this by using the matrix.transform()
// version that takes arrays as in and output values, and just
// modifying points rather than producing new ones? This would
// consume less memory for sure.
var point = segment.point; var point = segment.point;
var handleIn = segment.handleIn.add(point); var handleIn = segment.handleIn.add(point);
var handleOut = segment.handleOut.add(point); var handleOut = segment.handleOut.add(point);
point = matrix.transform(point); point = matrix.transform(point);
segment.point = point; segment.point = point;
// Convert handles back to relative values after transformation
segment.handleIn = matrix.transform(handleIn).subtract(point); segment.handleIn = matrix.transform(handleIn).subtract(point);
segment.handleOut = matrix.transform(handleOut).subtract(point); segment.handleOut = matrix.transform(handleOut).subtract(point);
} }