MCPcopy Create free account
hub / github.com/Tencent/tgfx / MakeRectToRectMatrix

Function MakeRectToRectMatrix

src/core/utils/RectToRectMatrix.cpp:21–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include "core/utils/RectToRectMatrix.h"
20namespace tgfx {
21Matrix 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

Callers 4

fillImageRectMethod · 0.85
flushPendingOpsMethod · 0.85
drawImageRectMethod · 0.85
drawImageRectMethod · 0.85

Calls 3

isEmptyMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected