|
Post by johnno56 on Mar 12, 2022 19:59:50 GMT -6
These are a couple of routines that I cobbled together to help align text (any font and size - to a point) on the center of a y-axis line and in the exact center of the screen.
Sub center(slot, txt$, ypos, colour) GetTextSize(slot, txt$, ByRef w, ByRef h) Font(slot): setColor(colour) DrawText(txt$, (xmax - w) / 2, ypos) End Sub
Sub middle(slot, txt$, colour) GetTextSize(slot, txt$, ByRef w, ByRef h) Font(slot): setColor(colour) DrawText(txt$, (xmax - w) / 2, (ymax - h) / 2) End Sub Both routines will 'get' the width and height of the text based on the font-style (slot) used. With the width and height determined, placement on the screen, is simple math.
There is probably an easier method... but these are what I have come up with. As usual, use of these are purely by choice; no credit required. I will not be offended if you choose not to use these... lol Suggested improvements are always welcome... ps: 'w' and 'h' may need initialising... xmax and ymax are the resolution of the display... Don't forget to setup the font...
|
|
|
Post by n00b on Mar 12, 2022 20:52:11 GMT -6
These are some useful functions. Thanks for sharing.
|
|