mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
common: added API to get the transformation matrix of the object
This commit is contained in:
parent
2c37191584
commit
ed7d8b73b9
3 changed files with 27 additions and 1 deletions
13
inc/thorvg.h
13
inc/thorvg.h
|
@ -232,10 +232,21 @@ public:
|
||||||
* @param[in] m The 3x3 augmented matrix.
|
* @param[in] m The 3x3 augmented matrix.
|
||||||
*
|
*
|
||||||
* @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
* @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
Result transform(const Matrix& m) noexcept;
|
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.
|
* @brief Sets the opacity of the object.
|
||||||
*
|
*
|
||||||
|
|
|
@ -281,6 +281,12 @@ Result Paint::transform(const Matrix& m) noexcept
|
||||||
return Result::FailedAllocation;
|
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
|
Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,6 +74,15 @@ namespace tvg
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix* transform()
|
||||||
|
{
|
||||||
|
if (rTransform) {
|
||||||
|
rTransform->update();
|
||||||
|
return &rTransform->m;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool bounds(float* x, float* y, float* w, float* h) const
|
bool bounds(float* x, float* y, float* w, float* h) const
|
||||||
{
|
{
|
||||||
return smethod->bounds(x, y, w, h);
|
return smethod->bounds(x, y, w, h);
|
||||||
|
|
Loading…
Add table
Reference in a new issue