Hi, how can i transform rectangle into trapezoid with ActionScript3
my trapezoid is a floor of 3D room, and i want to texturize it (bitmap tile).
_____________
| | | |
| |_____| |
| / \ |
| / trapez.\ |
|/__________\|
Hi, how can i transform rectangle into trapezoid with ActionScript3
my trapezoid is a floor of 3D room, and i want to texturize it (bitmap tile).
_____________
| | | |
| |_____| |
| / \ |
| / trapez.\ |
|/__________\|
It depends on how the "rectangle" is represented in your program. Few options:
If your rectangle is vector, and you have access to the anchor points:
---> o------o <---
| |
| |
o------o
Becomes:
o--o
/ \
/ \
o------o
Simply translate the two top points and condense them to each other.
If that 'rectangle' is actually a DisplayObject
, you will need to 'stitch' two of the same DisplayObject to create a new one. This page has examples of what you want along with example code.
Another option would be to use Papervision3D - which is using the above rendering method as a base.
This one's a bit tricky, but it's an option. You can use displacement maps as described here. The code is AS2, but it should be fairly simple to "port".
As par this answer, I suggest you use Papervision3D (see 3rd option) to do that, as you might want to move the camera around the "room". It will also take care of the other walls as well.
my rectangle is bitmap tiled and i want to transform it into trapezoid. Or are there any way to tile trapezoid?
If you're targetting FlashPlayer 10 you can do it by rotating the clip's rotation values, see This post form Mike Chambers for details.
Otherwise you're going to need a 3D engine like Papervision. There's no simple way to do non-affine transformations in Flash Player 9.
Good luck.
the idea is to divide it into triangles and then perform an affine transformation (using Matrix) on them ... senocular provided sample code (for AS2) ...
there's also a handful of libs online, but I can't find any right now ...
greetz
back2dos
My trapezoid is a floor of 3D room, and i want to texturize it (bitmap tile).
_____________
| | | |
| |_____| |
| / \ |
| / trapez.\ |
|/__________\|