It would be useful to have a way to control individual points when drawing a line. In the proposed TGI line drawing functions below, the callbacks would be called prior to plotting each point, and if true is returned, the point is plotted, otherwise it isn't. It also provides a means to adjust the color of the point on the fly. Currently, the only way to do this to create your own line drawing function.
void tgi_linewithcallback(int x1, int y1, int x2, int y2, bool *callback(int x, int y, unsigned char *color));
void tgi_linetowithcallback(int x, int y, bool *callback(int x, int y, unsigned char *color));
Uses:
dashed / dotted lines
gradient lines
masking polygons
Sample:
bool fancy_line_callback(int x, int y, unsigned char *color) {
/* Just "even" points for dot-dot-dot pattern */
if (x % 2 || y % 2)
return false;
/* Sixteen color "gradient" */
*color = ((x ^ y) >> 1) & 0xF;
return true;
}
void draw_fancy_x() {
tgi_linewithcallback(20, 20, 110, 110, fancy_line_callback);
tgi_linewithcallback(20, 110, 110, 20, fancy_line_callback);
};
That would be fancy, as you say, but I'm not sure it would be feasible: some of the platforms implementations use ROM calls (at least apple2)
Also, it would be really slow...
It would be useful to have a way to control individual points when drawing a line. In the proposed TGI line drawing functions below, the
callback
s would be called prior to plotting each point, and iftrue
is returned, the point is plotted, otherwise it isn't. It also provides a means to adjust the color of the point on the fly. Currently, the only way to do this to create your own line drawing function.Uses:
Sample: