Created
July 9, 2022 16:33
-
-
Save juanluisrto/8febbd009f1bf4cc9bb811843dc63ae9 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
from math import atan2, degrees, radians, sin, cos | |
def fit_text_as_geometry_between_two_points(text, A, B): | |
mid_coords = ((B[1] + A[1])/2, (B[0] + A[0])/2) | |
angle = atan2(B[1] - A[1], B[0] - A[0]) | |
bbox = LineString([A,B]).bounds | |
h = get_height(bbox) | |
w = get_width(bbox) | |
scale_factor = 100*(abs(h*sin(angle)) + abs(w*cos(angle))) | |
ml = text_as_geometry(text, mid_coords, scale_factor, degrees(angle)) | |
return ml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment