I have been struggling to find the center of an image(rectangle). I have following data with me:
width: w,
height: h,
position: (x,y)
My image is an object on canvas. I am using KonvaJS framework. My concern is not specific to image it's with Rect
, Square
as well but cause images are actually rectangle or squares and I believe that solution will be common for all. What I want to do is I need to find the center of the shape so that I can perform the desired operation. eg. I want to place the connector between a circle and image. End point of the connectors should be at the center like the way I have displayed it in image. Please let me know what should I do to achieve this. I believe it will be done by Math.atan()
and Math.atan2()
but don't know how can I use them. I am new to this bizarre.