in Hacks

Inspirational quote Part 3

h) The program doesn’t generate pictures without out-of-bounds problems

Okay. So what do I do? Pretty simple again. I knew I had multiple parameters which I could adjust. I started off with the textwrap length. At first I set it to 30 or so characters. However, if the starting point was too far to the right it easily got into problems. So I wrote a function which computed the text wrap based on the starting position and image size. Problem solved.

i) The text jumps out-of-bounds at the bottom

Yeah, the text was too long. The next step? Scaling the font size. I wrote a simple function which scales the font size (which is randomized) by a factor which decreases when the text size increases. Now I could generate really long texts without an out-of-bounds jump.

j) The text was really small

And a second fix I started to make the minimum sized font size and the problem was solved.

These were my steps for creating the picture generating functions. There were other problems I had to solve but I solved them before so it was quite easy and a bit boring. If you want to see how I solved the problems check out github.

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.