Feature: Compute connection point coordinates for non-rectangular shapes (accessed by 'cxn_pt_idx') #628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains two changes:
The Experimental feature functions _move_begin_to_cxn and _move_end_to_cxn compute connection point locations for a given shape. The existing logic works only in the case of Rectangle.
In order to compute connection point co-ordinates for other shapes, a hard-coded approach is taken, which is similar to what the PowerPoint team itself uses currently.
The idea is to compute the locations of points relative to the shape width and height for each shape type. This idea works surprisingly well in estimating the location. Even if we are off by few (1-4) pixels, the PowerPoint automatically fixes the difference.
Please check this answer for detailed explanation on Stackoverflow to a question asked by me.
The second subtle change is introduction of a new function that contains the common logic which is used by both the function: _move_begin_to_cxn and _move_end_to_cxn. This is to avoid the need to make repeated changes in two different locations.
I have tested this approach on Oval and Parallelogram shapes and it works smoothly for any size of shapes. The same idea can be extended to support more shapes.