Page 1 of 1
[Solved] Shearing Factor?
Posted: Tue Jul 30, 2013 4:13 pm
by Shadowraix
Alright, to start things off, I am completely new to Love2D, but I am decent with the actual Lua programming language. For the next few days i'll be a total narb at Love2D, so I apologize for asking such a simple question that I have yet to understand. I would just like an answer if you can provide one and i'll be on my way.
Back to the problem.
I was looking at the wiki and in the arguments of love.graphics.draw I saw something about the shearing factor on the X and Y axis. I have no clue what the shearing factor even is or what it is used for. I did a quick google search and had some slight trouble understanding what was being explained. A detailed explanation I would appreciate. An example of how it can be used would be appreciated as well.
Thanks in advance for anyone that can provide an answer! ^_^
Re: Shearing Factor?
Posted: Tue Jul 30, 2013 6:57 pm
by veethree
" Shear is the translation along an axis (say, X axis) by an amount that increases linearly with another axis (Y). It produces shape distortions as if objects were composed of layers that are caused to slide over each other [].
Shear transformations are very useful in creating italic letters and slanted letters from regular letters. " - Best explanation i could find on google.
Source:
http://cs.fit.edu/~wds/classes/cse5255/ ... shear.html
Re: Shearing Factor?
Posted: Tue Jul 30, 2013 11:50 pm
by Jasoco
Shearing! (Using the love.graphics.shear() function.)
Re: Shearing Factor?
Posted: Wed Jul 31, 2013 5:50 am
by micha
Don't be overwhelmed by the many arguments you can put into the drawing
Code: Select all
love.graphics.draw( drawable, x, y, r, sx, sy, ox, oy, kx, ky )
The parameters have default values, so if you don't know what shearing is or don't want to use it, you can just pass fewer arguments. So if you want to draw an unrotated, unscaled object it is enough to write
Code: Select all
love.graphics.draw( drawable, x, y)
Re: Shearing Factor?
Posted: Fri Aug 02, 2013 10:25 am
by Shadowraix
Sorry for not replying quickly. Alright, I can see what shearing does thanks to the example. I'm assuming to get any results like in the example you would have to use something like a for loop so that you can smoothly transition it and such correct?
(To prevent from me having to make a new thread I would appreciate it if anyone can help me out on this. When using a while or repeat loop Love crashes. I tried using love.timer.sleep, but the program still stops responding. I was just experimenting with the keypressed function with repeat loops to see if I could get the same effect as putting key events inside love.update)
Re: Shearing Factor?
Posted: Fri Aug 02, 2013 11:30 am
by micha
A for-loop (and while- and repeat- loops) would completely run within one frame. To get smooth transitions you have to change the parameters gradually over many frames. So a for-loop is not the right approach here.
Instead have a variable, that counts time:
Code: Select all
function love.update(dt)
timer = timer + dt
end
(Don't forget to initialize in the love.load() )
Then you can use the timer variable to do something with the shearing factor, for example:
That would give you an oscillating result. Or
For just an increase.
The key here is to have a variable that persists over many frames and is changed slightly in each frame.
Re: Shearing Factor?
Posted: Fri Aug 02, 2013 2:26 pm
by Shadowraix
micha wrote:A for-loop (and while- and repeat- loops) would completely run within one frame. To get smooth transitions you have to change the parameters gradually over many frames. So a for-loop is not the right approach here.
Instead have a variable, that counts time:
Code: Select all
function love.update(dt)
timer = timer + dt
end
(Don't forget to initialize in the love.load() )
Then you can use the timer variable to do something with the shearing factor, for example:
That would give you an oscillating result. Or
For just an increase.
The key here is to have a variable that persists over many frames and is changed slightly in each frame.
I see! Now I understand the use of shearing factor. I can use it to get some neat effects and such. Thanks for your help!