texture_get_uvs

This function returns a 1D array with 4 elements representing the UV coordinates for the given texture pointer on the texture page, filling in the array with the following values:

This value can then be used in other draw functions, particularly in general 3D and some of the 2D primitive functions, as well as the Shader functions. If you need the UVs for a sprite then you can use sprite_get_uvs, for a font font_get_uvs and for a tileset tileset_get_uvs.

 

Syntax:

texture_get_uvs(texid)

ArgumentTypeDescription
texidTextureThe texture pointer to get the UVs for

 

Returns:

Array (4 - 8 elements)

 

Example:

var _tex = surface_get_texture(surf_back);
var _uvs = texture_get_uvs(tex);
var _uvs_left = _uvs[0];
var _uvs_top = _uvs[1];
var _uvs_right = _uvs[2];
var _uvs_bottom = _uvs[3];

The above code first retrieves the texture for the surface stored in surf_back, and then gets the UV coordinates for that texture. It then retrieves the left, top, right and bottom UV coordinates from the returned array and stores them in local variables.