common: added API to get the transformation matrix of the object

This commit is contained in:
Mira Grudzinska 2021-05-28 03:32:00 +02:00 committed by Hermet Park
parent 2c37191584
commit ed7d8b73b9
3 changed files with 27 additions and 1 deletions

View file

@ -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.
*

View file

@ -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
{

View file

@ -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);