lucid-fox / social-magick

An Open Graph Image generator plugin for Joomla 3 and 4
GNU General Public License v3.0
15 stars 1 forks source link

Do the centering math for the users #23

Closed crystalenka closed 3 years ago

crystalenka commented 3 years ago

As I'm writing the documentation, I'm realizing that doing the math to calculate the "pixels x/y from center" is a pain in the butt, hard to understand for most people, and prone to errors. (Even I messed up putting the default template variables in! The "gravity" concept is not common to either design programs or web development.) Centering text vertically inside an absolutely positioned textbox is a bit easier to understand, as it's more familiar from CSS or even tables in Excel or Word.

So, ideally, we need to do that math on the backend.

If someone selects "Center text vertically", we should still ask them how many pixels from the top the text box should be, and then do the following calculations in the back end (since the image manipulation still wants the distance from center):

And that adjustment is what we pass to the function. Same goes for horizontal positioning.

This also means we will have to change the strings to "Center text vertically in textbox" or something like that, but I think overall it will make it easier to understand (and remove elements of user error).