You are not logged in.
Pages: 1
Based on my recent topic at the GMC, I put together this script. As it is based on both "draw_rectangle_inverted" and "polygon_area" I borrowed the comments from them, I hope that's OK.
/*
** Usage:
** draw_polygon_inverted(polygon)
**
** Arguments:
** polygon ds_list containing XY coordinate pairs defining
** the shape of a polygon {x0,y0,x1,y1,...,xn,yn}
**
** Returns:
** nothing, inverts the given polygonal area of the screen
**
** Notes:
** Polygons are closed figures, the first point in the polygon
** will also be considered the last point in the polygon.
** Polygons must be simple, which means they can not have
** edges that cross each other.
**
** Resets blending mode to normal.
**
** GMLscripts.com
*/
{
var polygon, i, j, x1, y1;
polygon = argument0;
j = ds_list_size(polygon);
draw_set_blend_mode_ext(bm_inv_dest_color, bm_inv_src_color);
draw_primitive_begin(pr_trianglefan);
for (i = 0; i < j; i += 2)
{
x1 = ds_list_find_value(polygon, i);
y1 = ds_list_find_value(polygon, i + 1)
draw_vertex_color(x1, y1, c_white, 1);
}
draw_primitive_end();
draw_set_blend_mode(bm_normal);
}
Offline
Careful of the alpha there. When drawing to a surface, inverting with an alpha of 1 will flip the alpha channel too, which might not be what you want.
Also, pr_trianglefan only?
Offline
Also, pr_trianglefan only?
Amazingly, that's all you need for this. See the linked topic above or click here.
Abusing forum power since 1986.
Offline
Ah, intriguing idea. I'll need to fiddle with this some more . . . seems like it should mesh with my AA engine pretty well.
Offline
Pages: 1