|
Transform a bitmap using shear |
Monica
Member #14,350
June 2012
|
Hi Allegro forumers! I'm struggling because I cannot find a way to shear bitmaps. What I mean by shear is if you have a square, and move the top two corners either left or right, creating a rhombus. I've attached a picture for clarity. Is there an allegro function that can do this, or will I have to write my own? Best regards
|
J-Gamer
Member #12,491
January 2011
|
AFAIK, there isn't an allegro function for that. Although it might be possible using transformations, but I'm not altogether sure of that. " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
Stas B.
Member #9,615
March 2008
|
The transformation you want looks like this: X' = X + S * Y Or in matrix form: [1 s 0 0] I don't use A5 so I can't give you all the details, but you can probably find the relevant info here: |
J-Gamer
Member #12,491
January 2011
|
The code: ALLEGRO_TRANSFORM trans; al_identity_transform(&trans); trans.m[0][1] = s; There isn't a function that can lead to that matrix, so you'll have to use the underlying float matrix. " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
Ashteth
Member #3,310
March 2003
|
It might be simpler to just draw it as a primitive. Thats how I do it anyways.
|
Stas B.
Member #9,615
March 2008
|
Ashteth said: It might be simpler to just draw it as a primitive. I don't think it really gets any simpler. You can do everything as if you're working with a regular grid, apply the matrix and everything gets automatically skewed. |
Monica
Member #14,350
June 2012
|
Thanks for pointing me in the right direction. I'm going to look into transformations and let you know if I run into problems. Awesome quick reply, cheers!
|
|