08-01-2022, 09:13 PM
@TempodiBasic Good Question! Let me take a moment to explain:
RW = (RW \ FW) * FH
As you say, it appears as if I'm simply dividing and multiplying the same number here -- yet, if you try it, you get back a different value from the original!
WHY?? Is it an artifact from floating point arithmetic? Is it something else? Just WHY the heck would anyone code something silly like the above??
****************
Keep in mind, we have 2 division operators in QB64 -- / and \.
/ is division.
\ is integer division.
So, in this case, what we're saying is basically:
RW = INT (RW / FW) * FW
The purpose here is easy to understand with a few actual numbers at work...
The user resizes the screen to 1608 pixels wide.
The font is 16 pixels wide.
With the above, we recalculate the width to become:
(RW \ FW) * FW
(1608 \ 16) * 16
100 * 16
1600
We just adjusted the width to 1600 pixels instead of 1608 pixels. We now can print 100 characters on a line, without having 8 pixels on the right that we'd either ignore, or only be able to print half a character on afterwards.
TLDR; It's a resize formula to adjust screen width to perfectly match font width.
RW = (RW \ FW) * FH
As you say, it appears as if I'm simply dividing and multiplying the same number here -- yet, if you try it, you get back a different value from the original!
WHY?? Is it an artifact from floating point arithmetic? Is it something else? Just WHY the heck would anyone code something silly like the above??
****************
Keep in mind, we have 2 division operators in QB64 -- / and \.
/ is division.
\ is integer division.
So, in this case, what we're saying is basically:
RW = INT (RW / FW) * FW
The purpose here is easy to understand with a few actual numbers at work...
The user resizes the screen to 1608 pixels wide.
The font is 16 pixels wide.
With the above, we recalculate the width to become:
(RW \ FW) * FW
(1608 \ 16) * 16
100 * 16
1600
We just adjusted the width to 1600 pixels instead of 1608 pixels. We now can print 100 characters on a line, without having 8 pixels on the right that we'd either ignore, or only be able to print half a character on afterwards.
TLDR; It's a resize formula to adjust screen width to perfectly match font width.