/// <summary> /// Returns the transform for this group's coordinate system /// </summary> /// <returns>The transform.</returns> protected Matrix2D ComputeTransform() { var mat = Matrix2D.Identity; if (originX != 0 || originY != 0) { mat = Matrix2D.Multiply(mat, Matrix2D.CreateTranslation(-originX, -originY)); } if (rotation != 0) { mat = Matrix2D.Multiply(mat, Matrix2D.CreateRotation(MathHelper.ToRadians(rotation))); } if (scaleX != 1 || scaleY != 1) { mat = Matrix2D.Multiply(mat, Matrix2D.CreateScale(scaleX, scaleY)); } mat = Matrix2D.Multiply(mat, Matrix2D.CreateTranslation(x + originX, y + originY)); // Find the first parent that transforms Group parentGroup = parent; while (parentGroup != null) { if (parentGroup.transform) { break; } parentGroup = parentGroup.parent; } if (parentGroup != null) { mat = Matrix2D.Multiply(mat, parentGroup.ComputeTransform()); } return(mat); }