Created
October 1, 2021 16:41
-
-
Save frankrolf/c4ebc4a65996c0214026a1691d90c684 to your computer and use it in GitHub Desktop.
toggle selected off-curve point(s)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
toggle bcp selection | |
''' | |
def toggle_bcp_selection(bcp): | |
pts = bcp.contour.points | |
p_prev = pts[(bcp.index - 1) % len(pts)] | |
p_prev_2 = pts[(bcp.index - 2) % len(pts)] | |
p_next = pts[(bcp.index + 1) % len(pts)] | |
p_next_2 = pts[(bcp.index + 2) % len(pts)] | |
if p_prev.type == 'curve' and p_prev_2.type == 'offcurve': | |
bcp_opposite = p_prev_2 | |
elif p_next.type == 'curve' and p_next_2.type == 'offcurve': | |
bcp_opposite = p_next_2 | |
else: | |
bcp_opposite = None | |
if bcp_opposite: | |
bcp.selected = False | |
bcp_opposite.selected = True | |
g = CurrentGlyph() | |
for point in g.selectedPoints: | |
if point.type == 'offcurve': | |
toggle_bcp_selection(point) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment