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

hangs in stroke_to, triggered by large coordinates with some settings. #181

Open
feverzsj opened this issue Jul 29, 2021 · 0 comments
Open

Comments

@feverzsj
Copy link

following code hangs in last stroke_to:

#include <libmypaint/mypaint.h>
#include <libmypaint/mypaint-brush.h>


int draw_dab(MyPaintSurface*, float, float, float, float, float, float, float, float, float,
             float, float, float, float, float, float, float, float)
{
    return TRUE;
}

void get_color(MyPaintSurface*, float, float, float,
               float* color_r, float* color_g, float* color_b, float* color_a,
               float)
{
    *color_r = 0;
    *color_g = 0;
    *color_b = 0;
    *color_a = 0;
}

void stroke_to(MyPaintBrush *brush, MyPaintSurface *surf, float x, float y)
{
    float viewzoom = 1.0, viewrotation = 0.0, barrel_rotation = 0.0;
    float pressure = 1.0, ytilt = 0.0, xtilt = 0.0, dtime = 1.0/10;
    gboolean linear = FALSE;
    mypaint_brush_stroke_to(brush, surf, x, y, pressure, xtilt, ytilt, dtime, viewzoom, viewrotation, barrel_rotation, linear);
}


int main()
{
    MyPaintSurface sf = {.draw_dab = draw_dab, .get_color = get_color};

    MyPaintBrush *brush = mypaint_brush_new();
    mypaint_brush_from_defaults(brush);
    mypaint_brush_set_base_value(brush, MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC, 0.3); // >= 0.35 ok
    mypaint_brush_set_base_value(brush, MYPAINT_BRUSH_SETTING_DABS_PER_ACTUAL_RADIUS, 4.0); // <= 3.9 ok

    stroke_to(brush, &sf, 4194298.5, 4194154.0);
//     stroke_to(brush, &sf, 4194286.5, 4194141.0);
//     stroke_to(brush, &sf, 4194269.5, 4194135.0);
//     stroke_to(brush, &sf, 4194247.5, 4194124.0);
//     stroke_to(brush, &sf, 4194221.5, 4194124.0);
//     stroke_to(brush, &sf, 4194191.5, 4194124.0);
//     stroke_to(brush, &sf, 4194164.5, 4194134.0);
//     stroke_to(brush, &sf, 4194137.5, 4194154.0);
//     stroke_to(brush, &sf, 4194118.5, 4194177.0);
//     stroke_to(brush, &sf, 4194102.5, 4194209.0);
//     stroke_to(brush, &sf, 4194081.5, 4194250.0);
//     stroke_to(brush, &sf, 4194064.5, 4194302.0);
//     stroke_to(brush, &sf, 4194050.5, 4194362.0);
//     stroke_to(brush, &sf, 4194050.5, 4194434.0);
//     stroke_to(brush, &sf, 4194050.5, 4194484.0);
//     stroke_to(brush, &sf, 4194053.5, 4194514.0);
//     stroke_to(brush, &sf, 4194060.5, 4194541.0);
//     stroke_to(brush, &sf, 4194069.5, 4194549.0);
//     stroke_to(brush, &sf, 4194080.5, 4194549.0);
//     stroke_to(brush, &sf, 4194099.5, 4194547.0);
//     stroke_to(brush, &sf, 4194141.5, 4194535.0);
//     stroke_to(brush, &sf, 4194188.5, 4194509.0);
//     stroke_to(brush, &sf, 4194253.5, 4194455.0);
    stroke_to(brush, &sf, 4194316.5, 4194407.0);


    mypaint_brush_unref(brush);
}

I'm implementing infinite canvas using grid index. All pixels are within same coordinate system. And map to tiles in draw_dab/get_color. So the coordinates may be relatively large. What would be a safe range for pixel coordinates?

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

No branches or pull requests

1 participant