Created
June 17, 2018 11:23
-
-
Save evanmiltenburg/dfd571f27372477487cb14f2bdf8b35c 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
def get_lengths(num_lines, line_length): | |
"Get n lines, totaling a particular length." | |
lengths = np.random.random(num_lines) | |
lengths *= line_length / np.sum(lengths) | |
return lengths | |
def lines(line_length, page_width): | |
"Get a random number of lines, with n-1 gaps of varying length in between." | |
num_lines = np.random.randint(1,10) | |
lengths = get_lengths(num_lines, line_length) | |
gaps = get_lengths(num_lines - 1, page_width - line_length) | |
return lengths, gaps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment