Skip to content

Instantly share code, notes, and snippets.

@frankrolf
Created October 1, 2021 16:41
Show Gist options
  • Save frankrolf/c4ebc4a65996c0214026a1691d90c684 to your computer and use it in GitHub Desktop.
Save frankrolf/c4ebc4a65996c0214026a1691d90c684 to your computer and use it in GitHub Desktop.
toggle selected off-curve point(s)
'''
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