mirror of
https://github.com/love2d/love.git
synced 2026-08-17 02:58:31 +02:00
love.graphics.apply/replaceTransform can accept x,y,angle,etc. args.
This commit is contained in:
@@ -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 ¤t = 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user