Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Center content in FSArrays #155

Open
thomasballinger opened this issue Jul 31, 2020 · 2 comments
Open

Center content in FSArrays #155

thomasballinger opened this issue Jul 31, 2020 · 2 comments

Comments

@thomasballinger
Copy link
Member

thomasballinger commented Jul 31, 2020

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?

@merriam
Copy link

merriam commented May 22, 2024

Sorry, I'm confused. Arr.center is just window.width - len(content) // 2? Or is it something more?

@thomasballinger
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants