Skip to content

Instantly share code, notes, and snippets.

@evanmiltenburg
Created June 17, 2018 11:23
Show Gist options
  • Save evanmiltenburg/dfd571f27372477487cb14f2bdf8b35c to your computer and use it in GitHub Desktop.
Save evanmiltenburg/dfd571f27372477487cb14f2bdf8b35c to your computer and use it in GitHub Desktop.
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