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! ^_^
[Solved] Shearing Factor?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Shadowraix
- Prole
- Posts: 4
- Joined: Tue Jul 30, 2013 3:59 pm
[Solved] Shearing Factor?
Last edited by Shadowraix on Fri Aug 02, 2013 2:27 pm, edited 1 time in total.
Re: Shearing Factor?
" 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
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
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Shearing Factor?
Shearing! (Using the love.graphics.shear() function.)
Re: Shearing Factor?
Don't be overwhelmed by the many arguments you can put into the drawing
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, r, sx, sy, ox, oy, kx, ky )
Code: Select all
love.graphics.draw( drawable, x, y)
Check out my blog on gamedev
- Shadowraix
- Prole
- Posts: 4
- Joined: Tue Jul 30, 2013 3:59 pm
Re: Shearing Factor?
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)
(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?
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:
(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.
Instead have a variable, that counts time:
Code: Select all
function love.update(dt)
timer = timer + dt
end
Then you can use the timer variable to do something with the shearing factor, for example:
Code: Select all
kx = math.sin(timer)
Code: Select all
kx = timer
The key here is to have a variable that persists over many frames and is changed slightly in each frame.
Check out my blog on gamedev
- Shadowraix
- Prole
- Posts: 4
- Joined: Tue Jul 30, 2013 3:59 pm
Re: Shearing Factor?
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!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:(Don't forget to initialize in the love.load() )Code: Select all
function love.update(dt) timer = timer + dt end
Then you can use the timer variable to do something with the shearing factor, for example:That would give you an oscillating result. OrCode: Select all
kx = math.sin(timer)
For just an increase.Code: Select all
kx = timer
The key here is to have a variable that persists over many frames and is changed slightly in each frame.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest