[mtl canvas] make diagonal checks inclusive in mtl_side_of_segment()

This commit is contained in:
Martin Fouilleul 2023-04-05 10:19:25 +02:00
parent 53946a5710
commit e999af6bd3
2 changed files with 6 additions and 6 deletions

View File

@ -132,10 +132,10 @@ int main()
mg_set_cap(MG_CAP_NONE);
mg_move_to(200, 200);
mg_line_to(300, 300);
mg_line_to(200, 400);
mg_line_to(100, 300);
mg_move_to(x+200, y+200);
mg_line_to(x+300, y+300);
mg_line_to(x+200, y+400);
mg_line_to(x+100, y+300);
mg_close_path();
mg_set_color_rgba(1, 0, 0, 1);
// mg_set_width(2);

View File

@ -229,8 +229,8 @@ int mtl_side_of_segment(float2 p, const device mg_mtl_segment* seg, mtl_log_cont
float dx = p.x - seg->box.x;
float dy = p.y - seg->box.y;
if( (seg->config == MG_MTL_BR && dy > alpha*dx)
||(seg->config == MG_MTL_TR && dy < ofs - alpha*dx))
if( (seg->config == MG_MTL_BR && dy >= alpha*dx)
||(seg->config == MG_MTL_TR && dy <= ofs - alpha*dx))
{
side = -1;
}