Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Snapping Issue For Regular Polygons in React Konva

This is the bounding box of a custom shapeBounding box of regular polygon with 3 sides Here the bounding box of the triangle is not getting attached correctly to the ends of the triangle ,same is the case for all regular polygons.So when we are trying to snap shapes ,shapes are not getting snapped to the ends of regular polygons correctly due to the above mentioned issue. Here is the link:- https://codesandbox.io/s/react-konva-basic-demo-btuum?file=/index.js

like image 631
Athul R Nath Avatar asked Jul 21 '20 14:07

Athul R Nath


1 Answers

Update:

The issue was solved from Konva side. Updated and working demo: https://codesandbox.io/s/react-konva-transformer-on-polygon-kodm7

Old answer:

Konva calculating the bounding box for regular polygon approximately. Konva just rounds that regular polygon into a circle with the same radius.

As the solution just use Konva.Line or Konva.Path for drawing regular polygons.

like image 83
lavrton Avatar answered Sep 27 '22 21:09

lavrton