Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Adding line with callback functions to TGI #2373

Open
rharper-trailcon opened this issue Jan 19, 2024 · 1 comment
Open

Suggestion: Adding line with callback functions to TGI #2373

rharper-trailcon opened this issue Jan 19, 2024 · 1 comment

Comments

@rharper-trailcon
Copy link

rharper-trailcon commented Jan 19, 2024

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);
};
@colinleroy
Copy link
Contributor

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants