| 19 | #include "core/utils/RectToRectMatrix.h" |
| 20 | namespace tgfx { |
| 21 | Matrix MakeRectToRectMatrix(const Rect& srcRect, const Rect& dstRect) { |
| 22 | if (srcRect.isEmpty()) { |
| 23 | return Matrix::I(); |
| 24 | } |
| 25 | if (dstRect.isEmpty()) { |
| 26 | return Matrix::MakeAll(0, 0, 0, 0, 0, 0); |
| 27 | } |
| 28 | float sx = dstRect.width() / srcRect.width(); |
| 29 | float sy = dstRect.height() / srcRect.height(); |
| 30 | float tx = dstRect.left - srcRect.left * sx; |
| 31 | float ty = dstRect.top - srcRect.top * sy; |
| 32 | return Matrix::MakeAll(sx, 0, tx, 0, sy, ty); |
| 33 | } |
| 34 | } // namespace tgfx |
no test coverage detected