This article shows how to center a text in GraphicsWindow using Small Basic programming language.
Following program (TKW252) has a caption "DeepSkyBlue Fish" and the caption is approximately in the center of the gray rectangle. In this program, pixel width of this caption is calculated
Text.GetLength(caption) means the number of characters in the caption. Default font size (height) is 12 pixels and gross average width of the default font (Tahoma) assumed to be 7 pixels in this program. If the window width is gw, centering x position
of the caption will be as follows.
Accurate centering need to measure the text pixel width accurately. Following tool (KTK906-1) can measure text pixel width.
Using this result I rewrote former aquarium program as
I did't complete the advanced sample program. But the idea is as follows.
Nonki Takahashi edited Revision 1. Comment: Created
thanks for sharing.