love.graphics.apply/replaceTransform can accept x,y,angle,etc. args.

This commit is contained in:
Alex Szpakowski
2022-01-03 11:57:05 -04:00
parent 91cb845f31
commit de89f5a9eb
3 changed files with 16 additions and 13 deletions
+5 -6
View File
@@ -1990,19 +1990,18 @@ void Graphics::origin()
pixelScaleStack.back() = 1;
}
void Graphics::applyTransform(love::math::Transform *transform)
void Graphics::applyTransform(const Matrix4 &m)
{
Matrix4 &m = transformStack.back();
m *= transform->getMatrix();
Matrix4 &current = transformStack.back();
current *= m;
float sx, sy;
m.getApproximateScale(sx, sy);
current.getApproximateScale(sx, sy);
pixelScaleStack.back() = (sx + sy) / 2.0;
}
void Graphics::replaceTransform(love::math::Transform *transform)
void Graphics::replaceTransform(const Matrix4 &m)
{
const Matrix4 &m = transform->getMatrix();
transformStack.back() = m;
float sx, sy;
+2 -2
View File
@@ -826,8 +826,8 @@ public:
void shear(float kx, float ky);
void origin();
void applyTransform(love::math::Transform *transform);
void replaceTransform(love::math::Transform *transform);
void applyTransform(const Matrix4 &m);
void replaceTransform(const Matrix4 &m);
Vector2 transformPoint(Vector2 point);
Vector2 inverseTransformPoint(Vector2 point);
+9 -5
View File
@@ -3441,7 +3441,7 @@ int w_push(lua_State *L)
if (luax_istype(L, 2, math::Transform::type))
{
math::Transform *t = luax_totype<math::Transform>(L, 2);
luax_catchexcept(L, [&]() { instance()->applyTransform(t); });
luax_catchexcept(L, [&]() { instance()->applyTransform(t->getMatrix()); });
}
return 0;
@@ -3492,15 +3492,19 @@ int w_origin(lua_State * /*L*/)
int w_applyTransform(lua_State *L)
{
math::Transform *t = math::luax_checktransform(L, 1);
luax_catchexcept(L, [&]() { instance()->applyTransform(t); });
luax_checkstandardtransform(L, 1, [&](const Matrix4 &m)
{
luax_catchexcept(L, [&]() { instance()->applyTransform(m); });
});
return 0;
}
int w_replaceTransform(lua_State *L)
{
math::Transform *t = math::luax_checktransform(L, 1);
luax_catchexcept(L, [&]() { instance()->replaceTransform(t); });
luax_checkstandardtransform(L, 1, [&](const Matrix4 &m)
{
luax_catchexcept(L, [&]() { instance()->replaceTransform(m); });
});
return 0;
}