Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resize breaking
#6
@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. Wink

TLDR; It's a resize formula to adjust screen width to perfectly match font width.
Reply


Messages In This Thread
Resize breaking - by SMcNeill - 08-01-2022, 07:01 PM
RE: Resize breaking - by Pete - 08-01-2022, 07:19 PM
RE: Resize breaking - by SMcNeill - 08-01-2022, 07:21 PM
RE: Resize breaking - by SMcNeill - 08-01-2022, 07:49 PM
RE: Resize breaking - by TempodiBasic - 08-01-2022, 10:07 PM
RE: Resize breaking - by SMcNeill - 08-01-2022, 10:22 PM
RE: Resize breaking - by TempodiBasic - 08-01-2022, 09:00 PM
RE: Resize breaking - by admin - 08-01-2022, 09:13 PM
RE: Resize breaking - by SMcNeill - 08-01-2022, 09:17 PM
RE: Resize breaking - by Kernelpanic - 08-01-2022, 10:14 PM
RE: Resize breaking - by SMcNeill - 08-01-2022, 10:31 PM
RE: Resize breaking - by TempodiBasic - 08-01-2022, 10:59 PM



Users browsing this thread: 3 Guest(s)