b2dDrawImageQuad

Category: 2D Overlay

Syntax:

b2dDrawImageQuad:Void(image:Int, x1:Int, y1:Int, x2:Int, y2:Int, x3:Int, y3:Int, x4:Int, y4:Int)


Parameters

Returns

Void



Summary

Draws the whole image stretched onto an arbitrary four-cornered shape. The corners go clockwise from the top-left of the image, so the image's top-left lands on (x1,y1), top-right on (x2,y2), bottom-right on (x3,y3) and bottom-left on (x4,y4). Give the corners in a different order and the image comes out mirrored or turned to match.

Returns nothing.

This is the building block for textured 3D drawn with the 2D runtime: project a face's four corners to the screen yourself, then paint an image onto them. One call per face gives a textured cube.

The corners are absolute and final: the image handle, b2dSetScale and b2dSetRotation do not apply. The current colour (b2dSetColor) tints it and b2dSetAlpha fades it, exactly as for b2dDrawImage. The clip rect applies.

The quad is split into two triangles, (1,2,3) and (1,3,4), the same as b2dDrawQuad, and neither winding is culled. The texture is interpolated linearly across each triangle, so a strongly tilted face shows a slight bend along that diagonal; keep faces reasonably small, or split them, if that matters.

It is not depth-tested — like any image it draws in call order — so a convex object needs you to skip the faces pointing away (backface culling). For faces that cross each other, use b2dDrawImageQuadDepth. To show only part of the image, use b2dDrawImageQuadUV.

"Whole image" means the whole texture: an animation sheet from b2dLoadAnimImage is mapped with all of its frames. Palette-cycling (indexed) images are not supported and draw nothing.

View detailed documentation online



Example
crate = b2dLoadImage("Media/crate.png")

; a crate leaning back into the screen - narrower at the top
b2dDrawImageQuad(crate, 340,200, 460,200, 500,380, 300,380)

See examples/Runtime/29 - Image Quads/ImageQuad.bam for a spinning textured cube.


BambooBasic © 2026 Michael Denathorn