Every attempt I tried at doing this led to things being disproportionate or skewed to an absurd size.
I am mainly interested in this to make things easier to distort for special effects.

Code: Select all
love.graphics.translate(dx, dy)
love.graphics.rotate(1.2)
love.graphics.translate(-dx, -dy)
There is nothing wrong with using graphics.rotate. I am just trying to see if there is a way to simulate graphics.rotate by using graphics.shear and graphics.scale, which would be useful to make the screen trippy and nauseous.What is the problem with using graphics.rotate? Is it that you want to set the center of rotation? If that's the case, you need to first translate the center to the position you wish to be rotated around, rotate, and then translate back:
Code: Select all
shear=function(_,a,b)
if a or b then
c.a=a or c.a
c.b=b or c.b
elseif not (a or b) then
a=math.abs(c.a)
b=math.abs(c.b)
a=(a/(a+45))
b=(b/(b+45))
graphics.scale(1-a,1-b)
graphics.shear(c.a/45,c.b/45)
end
end
Thanks, this might be useful!It is pretty simple since rotate, scale and shear are all linear transformations described by matrices (see source: /love/src//src/common/Matrix.cpp). You just have to multiply them and compare coefficients.
Code: Select all
Rotation Matrix is
cos(r) -sin(r)
sin(r) cos(r)
now when you apply is to an vector
x y
you will get
x*cos(r)-y*sin(r) y*cos(r)+x*sin(r)
Scale Matrix:
S 0
0 S
Shear Matrix is:
1 Sx
Sy 1
Now the Problem is
now when you first apply scale to an vector
x y
you will get
x*S y*S
now Shear Matrix gives
x*S+y*S*Sx y*S+x*S*Sx
Now remember what we wan't
So first we can replace S with cos(r)
So we will get
x*cos(r)+y*cos(r)*Sx y*cos(r)+x*cos(r)*Sx
Now Sx and is a little bit more complicated
it should be
Sx=-sin(r)/cos(r)
Sy=sin(r)/cos(r)
an we get the rotation function as:
x*cos(r)-y*sin(r) y*cos(r)+x*sin(r)
So we should fill
Scale(cos(r),cos())
Shear(-sin(r)/cos(r),sin()/cos(r))
But now there is a problem
When rotation is 90° cos becomes zero
Code: Select all
local kx, ky = -math.tan(angle/2), math.sin(angle)
love.graphics.shear(kx, 0)
love.graphics.shear(0, ky)
love.graphics.shear(kx, 0)
Users browsing this forum: Ahrefs [Bot], cowardlycamper32 and 5 guests