```
if !sprite_exists(cursprite)
{
exit;
}
draw_set_blend_mode(curblendmode);
///////////////////////////////////////////////////////////////////////
//DRAW_SPRITE_POS():
var offsetx =500;//just to shift this display to the left
draw_set_color(c_blue);
draw_text(10 +offsetx, 10, "Draw_Sprite_pos():");
draw_sprite_pos(cursprite, cursubimage,
topleftX +offsetx, topleftY,
toprightX +offsetx, toprightY,
bottomrightX +offsetx, bottomrightY,
bottomleftX +offsetx, bottomleftY, curalpha);
///////////////////////////////////////////////////////////////////////
draw_set_color(c_blue);
draw_text(10, 10, "Draw_Sprite_posXT():");
//DRAW_SPRITE_POSXT():
if update
{
ds_list_clear(tri_x);
ds_list_clear(tri_y);
ds_list_clear(tri_u);
ds_list_clear(tri_v);
ds_list_clear(tri_col);
ds_list_clear(tri_alpha);
curspritetex =sprite_get_texture(cursprite, cursubimage);
//at first get all corners of the dividing sub-quads:
divhoriz =max(1, divhoriz);
divvert =max(1, divvert);
var deltaxtop =(toprightX -topleftX) *curscaleX /divhoriz;
var deltaxbottom =(bottomrightX -bottomleftX) *curscaleX /divhoriz;
var deltayleft =(bottomleftY -topleftY) *curscaleY /divvert;
var deltayright =(bottomrightY -toprightY) *curscaleY /divvert;
var n, m;
for (m =0; m <=divhoriz; m +=1)
{
var xtmp =topleftX +m *deltaxtop;
var xbottomcur =bottomleftX +m *deltaxbottom;
for (n =0; n <=divvert; n +=1)
{
var xcur =xtmp +((xbottomcur -xtmp) *n)/divvert;
var ycur =topleftY +n *deltayleft;
var yrightcur =toprightY +n *deltayright;
ycur +=((yrightcur -ycur) *m) /divhoriz;
pt_x[m, n] =xcur;
pt_y[m, n] =ycur;
pt_u[m, n] =m /divhoriz;
pt_v[m, n] =n /divvert;
pt_col[m, n] =curcolor;
pt_alpha[m, n] =curalpha;
}
}
//next make 2 triangles for each sub-squad:
for (m =0; m <divhoriz; m +=1)
{
var mm =m +1;
for (n =0; n <divvert; n +=1)
{
var nn =n +1;
//triangle #1:
ds_list_add(tri_x, pt_x[m, n]);
ds_list_add(tri_y, pt_y[m, n]);
ds_list_add(tri_u, pt_u[m, n]);
ds_list_add(tri_v, pt_v[m, n]);
ds_list_add(tri_col, pt_col[m, n]);
ds_list_add(tri_alpha, pt_alpha[m, n]);
ds_list_add(tri_x, pt_x[mm, n]);
ds_list_add(tri_y, pt_y[mm, n]);
ds_list_add(tri_u, pt_u[mm, n]);
ds_list_add(tri_v, pt_v[mm, n]);
ds_list_add(tri_col, pt_col[mm, n]);
ds_list_add(tri_alpha, pt_alpha[mm, n]);
ds_list_add(tri_x, pt_x[mm, nn]);
ds_list_add(tri_y, pt_y[mm, nn]);
ds_list_add(tri_u, pt_u[mm, nn]);
ds_list_add(tri_v, pt_v[mm, nn]);
ds_list_add(tri_col, pt_col[mm, nn]);
ds_list_add(tri_alpha, pt_alpha[mm, nn]);
//triangle #2:
ds_list_add(tri_x, pt_x[m, n]);
ds_list_add(tri_y, pt_y[m, n]);
ds_list_add(tri_u, pt_u[m, n]);
ds_list_add(tri_v, pt_v[m, n]);
ds_list_add(tri_col, pt_col[m, n]);
ds_list_add(tri_alpha, pt_alpha[m, n]);
ds_list_add(tri_x, pt_x[mm, nn]);
ds_list_add(tri_y, pt_y[mm, nn]);
ds_list_add(tri_u, pt_u[mm, nn]);
ds_list_add(tri_v, pt_v[mm, nn]);
ds_list_add(tri_col, pt_col[mm, nn]);
ds_list_add(tri_alpha, pt_alpha[mm, nn]);
ds_list_add(tri_x, pt_x[m, nn]);
ds_list_add(tri_y, pt_y[m, nn]);
ds_list_add(tri_u, pt_u[m, nn]);
ds_list_add(tri_v, pt_v[m, nn]);
ds_list_add(tri_col, pt_col[m, nn]);
ds_list_add(tri_alpha, pt_alpha[m, nn]);
}
}
update =false;
}
var ms_start;
if draw_ms
{
ms_start =current_time;
}
draw_primitive_begin_texture(pr_trianglelist, curspritetex);
var curcount =0;
var i;
for (i =0; i <ds_list_size(tri_x); i +=1)
{
draw_vertex_texture_color(ds_list_find_value(tri_x, i),
ds_list_find_value(tri_y, i),
ds_list_find_value(tri_u, i),
ds_list_find_value(tri_v, i),
ds_list_find_value(tri_col, i),
ds_list_find_value(tri_alpha, i));
curcount +=1;
if (curcount ==999)
{
//draw_primitive_... does not like to draw more
//than 1000 vertices at a time
draw_primitive_end();
draw_primitive_begin_texture(pr_trianglelist, curspritetex);
curcount =0;
}
}
draw_primitive_end();
if draw_ms
{
draw_set_blend_mode(bm_normal);
draw_set_color(draw_ms_color);
draw_text(10, 30, "[ms] needed :" +string(current_time -ms_start));
}
if drawmesh
{
draw_set_color(drawmeshcolor);
draw_set_blend_mode(drawmeshblendmode);
var i;
for (i =0; i <ds_list_size(tri_x); i +=3)
{
draw_circle(ds_list_find_value(tri_x, i),
ds_list_find_value(tri_y, i),
4, false);
draw_circle(ds_list_find_value(tri_x, i +1),
ds_list_find_value(tri_y, i +1),
4, false);
draw_circle(ds_list_find_value(tri_x, i +2),
ds_list_find_value(tri_y, i +2),
4, false);
draw_line(ds_list_find_value(tri_x, i),
ds_list_find_value(tri_y, i),
ds_list_find_value(tri_x, i +1),
ds_list_find_value(tri_y, i +1));
draw_line(ds_list_find_value(tri_x, i +1),
ds_list_find_value(tri_y, i +1),
ds_list_find_value(tri_x, i +2),
ds_list_find_value(tri_y, i +2));
draw_line(ds_list_find_value(tri_x, i +2),
ds_list_find_value(tri_y, i +2),
ds_list_find_value(tri_x, i),
ds_list_find_value(tri_y, i));
}
}
if drawcontour
{
draw_set_color(drawcontourcolor);
draw_line(topleftX, topleftY, toprightX, toprightY);
draw_line(toprightX, toprightY, bottomrightX, bottomrightY);
draw_line(bottomrightX, bottomrightY, bottomleftX, bottomleftY);
draw_line(bottomleftX, bottomleftY, topleftX, topleftY);
}
///////////////////////////////////////////////////////////////////////
```