-
-
Save ryanbugden/e13fa4f24428a0f0aebeebe42c3d002c to your computer and use it in GitHub Desktop.
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
| # menuTitle : Add Guideline at Selection | |
| # shortCut : shift+control+g | |
| ''' | |
| If two points are selected, add an angled guideline along them. | |
| If one point is selected, add a horizontal guideline there. | |
| Ryan Bugden | |
| 2020 | |
| ''' | |
| import math | |
| g = CurrentGlyph() | |
| with g.undo("Add guideline at selection"): | |
| if len(g.selectedPoints) > 1: | |
| pts = [] | |
| for pt in g.selectedPoints: | |
| pts.append((pt.x, pt.y)) | |
| if pts[-1][0] == pts[0][0]: | |
| g.appendGuideline((pts[-1][0], pts[-1][1]), angle=90) | |
| else: | |
| y_tri = pts[-1][1] - pts[0][1] | |
| x_tri = pts[-1][0] - pts[0][0] | |
| ang = math.atan(y_tri/x_tri) * (180/math.pi) | |
| g.appendGuideline((pts[0][0], pts[0][1]), angle=ang) | |
| elif len(g.selectedPoints) == 1: | |
| pt = g.selectedPoints[0] | |
| g.appendGuideline((pt.x, pt.y), angle=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment