diff --git a/inc/thorvg.h b/inc/thorvg.h index 1d95ee53..3a53d0a3 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -232,10 +232,21 @@ public: * @param[in] m The 3x3 augmented matrix. * * @return Result::Success when succeed, Result::FailedAllocation otherwise. - * */ Result transform(const Matrix& m) noexcept; + /** + * @brief Gets the matrix of the affine transformation of the object. + * + * The values of the matrix can be set by the transform() API, as well by the translate(), + * scale() and rotate(). In case no transformation was applied, the identity matrix is returned. + * + * @retval The augmented transformation matrix. + * + * @BETA_API + */ + Matrix transform() noexcept; + /** * @brief Sets the opacity of the object. * diff --git a/src/lib/tvgPaint.cpp b/src/lib/tvgPaint.cpp index a32ca43f..ef553c1b 100644 --- a/src/lib/tvgPaint.cpp +++ b/src/lib/tvgPaint.cpp @@ -281,6 +281,12 @@ Result Paint::transform(const Matrix& m) noexcept return Result::FailedAllocation; } +Matrix Paint::transform() noexcept +{ + auto pTransform = pImpl->transform(); + if (pTransform) return *pTransform; + return {1, 0, 0, 0, 1, 0, 0, 0, 1}; +} Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept { diff --git a/src/lib/tvgPaint.h b/src/lib/tvgPaint.h index 044c3aa1..f40345f0 100644 --- a/src/lib/tvgPaint.h +++ b/src/lib/tvgPaint.h @@ -74,6 +74,15 @@ namespace tvg return true; } + Matrix* transform() + { + if (rTransform) { + rTransform->update(); + return &rTransform->m; + } + return nullptr; + } + bool bounds(float* x, float* y, float* w, float* h) const { return smethod->bounds(x, y, w, h);