Posts: 1,272
Threads: 119
Joined: Apr 2022
Reputation:
100
While working with legacy screens I noticed something odd. Circles are not circles. They need to be forced to an aspect ratio of 1 to become true circles.
I realize these screens were stretched onto CRT monitors with 4:3 aspect ratios. Is that why the default circle is squashed?
Code: (Select All) SCREEN 2
CIRCLE (100, 99), 50 ' not a circle
CIRCLE (300, 99), 50, , , , .418 ' this seems to be the default aspect ratio
CIRCLE (500, 99), 50, , , , 1 ' forced to an aspect ratio of 1:1, now a circle
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Posts: 597
Threads: 110
Joined: Apr 2022
Reputation:
34
04-13-2024, 05:50 PM
(This post was last modified: 04-13-2024, 05:59 PM by CharlieJV.)
(04-13-2024, 03:31 PM)TerryRitchie Wrote: While working with legacy screens I noticed something odd. Circles are not circles. They need to be forced to an aspect ratio of 1 to become true circles.
I realize these screens were stretched onto CRT monitors with 4:3 aspect ratios. Is that why the default circle is squashed?
Code: (Select All) SCREEN 2
CIRCLE (100, 99), 50 ' not a circle
CIRCLE (300, 99), 50, , , , .418 ' this seems to be the default aspect ratio
CIRCLE (500, 99), 50, , , , 1 ' forced to an aspect ratio of 1:1, now a circle
That would be a little bit of legacy from GW-BASIC not implemented in QB64, I think.
Run GW-BASIC at the Internet Archive. (You might find it interesting to try this with BAM too, because it, as per wwwBASIC, has the same CIRCLE behaviour as GW-BASIC for compatibility.)
Enter the following program and run it. Notice how the CIRCLE looks like a semi-decent CIRCLE, but the square does not look like a square at all.
Code: (Select All) 10 screen 2
20 circle (100,100),50
30 line (50,50)-(150,150),,B
Now modify that program and run again. Notice how it is a somewhat decent CIRCLE, and a somewhat decent square.
Code: (Select All) 10 screen 7
20 circle (100,100),50
30 line (50,50)-(150,150),,B
Run both of those programs in QB64.
What you are seeing is QB64 not implementing CIRCLE in the same way as CIRCLE was implemented in GW-BASIC to work with different screen modes.
In GW-BASIC, it does its very best to draw a proportionally correct circle no matter the screen mode. To do that, the CIRCLE implementation adjusts the number of vertical pixels to a number that works (aspect wise) correctly for the number of horizontal pixels.
Screenshots from BAM (which fairly match results from GW-BASIC hosted at the Internet Archive):
Posts: 597
Threads: 110
Joined: Apr 2022
Reputation:
34
04-13-2024, 06:12 PM
(This post was last modified: 04-13-2024, 06:27 PM by CharlieJV.)
Come to think of it, it looks like QB64 is taking the GW-BASIC screen 2 and squishing it vertically, which then gives a proper square but then the squishing turns the circle into an ellipse.
So it looks like QB64 is implementing CIRCLE the same way as GW-BASIC, however the screen 2 mode in QB64 does not match the pixel width to pixel height ratio of the GW-BASIC screen 2 mode.
I'm thinking that any GW-BASIC program using whatever screen mode will never look "right" (I.e. as it looks in GW-BASIC), as-is, in QB64.
In BAM (as per wwwBASIC), screen mode 2: pixels are 2.4 times taller than they are wide. So, to have a "proper" circle, the CIRCLE statement does some pretty special math to maintain proper aspect appearance. For example, if the radius is 24 at the horizontal, the radius must be 10 at the vertical.
Something like that ...
Screenshot of QB64:
|