How can I set up a SCR_RECT structure?

Previous Graphics and Display Next

Q: How I can setup properly a SCR_RECT structure? For example, the FillTriangle function requires the parameter of SCR_RECT type. How to put coordinates into it, so that I can change the clipping area for the screen?
A: If all coordinates of clip area are known in advance (for example 5, 5, 90, 70), do this:
FillTriangle (10, 10, 10, 50, 50, 50, &(SCR_RECT){{5, 5, 90, 70}}, A_NORMAL);
or, using "standard" C (i.e. without GNU extensions):

SCR_RECT area = {{5, 5, 90, 70}};  // somewhere in the declaration part
...
FillTriangle (10, 10, 10, 50, 50, 50, &area, A_NORMAL);
Note that double braces are necessary because SCR_RECT is an union.

If coordinates are not known in advance, for examples if they are in integer variables a, b, c and d, you can do this:
SCR_RECT area;
...
area.xy.x0 = a;
area.xy.y0 = b;
area.xy.x1 = c;
area.xy.y1 = d;
FillTriangle (10, 10, 10, 50, 50, 50, &area, A_NORMAL);
or, much simpler, using GNU C extensions:
FillTriangle (10, 10, 10, 50, 50, 50, &(SCR_RECT){{a, b, c, d}}, A_NORMAL);