Center content in FSArrays
thomasballinger opened this issue · comments
Tom Ballinger commented
Spurred by https://twitter.com/TAThorogood/status/1284650865991626754?s=20, some basic bits of a content layout system could be useful.
We could start with methods for centering content in an array, arr.center(content)
I suppose?
Charles Merriam commented
Sorry, I'm confused. Arr.center is just window.width - len(content) // 2
? Or is it something more?
Tom Ballinger commented
Yes roughly, plus on the vertical axis. Like
arr = FSArray(window.height, window.width)
arr.center("hello")
producing something like (if it's side-effecting, I have no idea what I was thinking at the time)
hello
so equivalent to
arr = FSArray(window.height, window.width)
arr[arr.height // 2][arr.width - len(content) // 2 : arr.width + (len(content) + 1) // 2] = content