mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +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;
|
pixelScaleStack.back() = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::applyTransform(love::math::Transform *transform)
|
void Graphics::applyTransform(const Matrix4 &m)
|
||||||
{
|
{
|
||||||
Matrix4 &m = transformStack.back();
|
Matrix4 ¤t = transformStack.back();
|
||||||
m *= transform->getMatrix();
|
current *= m;
|
||||||
|
|
||||||
float sx, sy;
|
float sx, sy;
|
||||||
m.getApproximateScale(sx, sy);
|
current.getApproximateScale(sx, sy);
|
||||||
pixelScaleStack.back() = (sx + sy) / 2.0;
|
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;
|
transformStack.back() = m;
|
||||||
|
|
||||||
float sx, sy;
|
float sx, sy;
|
||||||
|
|||||||
@@ -826,8 +826,8 @@ public:
|
|||||||
void shear(float kx, float ky);
|
void shear(float kx, float ky);
|
||||||
void origin();
|
void origin();
|
||||||
|
|
||||||
void applyTransform(love::math::Transform *transform);
|
void applyTransform(const Matrix4 &m);
|
||||||
void replaceTransform(love::math::Transform *transform);
|
void replaceTransform(const Matrix4 &m);
|
||||||
|
|
||||||
Vector2 transformPoint(Vector2 point);
|
Vector2 transformPoint(Vector2 point);
|
||||||
Vector2 inverseTransformPoint(Vector2 point);
|
Vector2 inverseTransformPoint(Vector2 point);
|
||||||
|
|||||||
@@ -3441,7 +3441,7 @@ int w_push(lua_State *L)
|
|||||||
if (luax_istype(L, 2, math::Transform::type))
|
if (luax_istype(L, 2, math::Transform::type))
|
||||||
{
|
{
|
||||||
math::Transform *t = luax_totype<math::Transform>(L, 2);
|
math::Transform *t = luax_totype<math::Transform>(L, 2);
|
||||||
luax_catchexcept(L, [&]() { instance()->applyTransform(t); });
|
luax_catchexcept(L, [&]() { instance()->applyTransform(t->getMatrix()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3492,15 +3492,19 @@ int w_origin(lua_State * /*L*/)
|
|||||||
|
|
||||||
int w_applyTransform(lua_State *L)
|
int w_applyTransform(lua_State *L)
|
||||||
{
|
{
|
||||||
math::Transform *t = math::luax_checktransform(L, 1);
|
luax_checkstandardtransform(L, 1, [&](const Matrix4 &m)
|
||||||
luax_catchexcept(L, [&]() { instance()->applyTransform(t); });
|
{
|
||||||
|
luax_catchexcept(L, [&]() { instance()->applyTransform(m); });
|
||||||
|
});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_replaceTransform(lua_State *L)
|
int w_replaceTransform(lua_State *L)
|
||||||
{
|
{
|
||||||
math::Transform *t = math::luax_checktransform(L, 1);
|
luax_checkstandardtransform(L, 1, [&](const Matrix4 &m)
|
||||||
luax_catchexcept(L, [&]() { instance()->replaceTransform(t); });
|
{
|
||||||
|
luax_catchexcept(L, [&]() { instance()->replaceTransform(m); });
|
||||||
|
});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user