Circle bug?

General FreeBASIC programming questions.
Post Reply
Anjost
Posts: 4
Joined: Jan 10, 2024 19:39
Location: England

Circle bug?

Post by Anjost »

A circle drawn with the Circle command is slightly squashed left to right in Screen 21 (1280x1024).
I have FreeBasic 1.10.1 on Windows 11.
Should this be reported on SourceForge?

Code: Select all

lang "fb"
'Circle test
'screen 20  '1024 x 768 - works properly
screen 21  '1280 x 1024 - doesn't work
Dim as Integer x, y, radius
x = 400
y = 400
radius = 300
CIRCLE (x, y), radius, 11  'circle is not a circle!
LINE (x - radius, y) - (x + radius, y), 4
LINE (x, y - radius) - (x, y + radius), 4
sleep
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: Circle bug?

Post by UEZ »

This works in Win11:

Code: Select all

#include "fbgfx.bi"
Using FB

Dim As Integer x, y, radius
x = 400
y = 400
radius = 300

'lang "fb"
'Circle test
'Screen 20  '1024 x 768 - works properly
'Screen 21  '1280 x 1024 - doesn't work

'Circle (x, y), radius, 11  'circle is not a circle!
'Line (x - radius, y) - (x + radius, y), 4
'Line (x, y - radius) - (x, y + radius), 4

ScreenRes 1280, 1024, 32

Circle (x, y), radius, &hFFFFFFFF
Line (x - radius, y) - (x + radius, y), &hFFFF0000
Line (x, y - radius) - (x, y + radius), &hFFFF0000
Flip
Sleep
I don't know about Screen 21 mode.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Circle bug?

Post by dodicat »

I have this problem with my pool game.
viewtopic.php?p=220681&hilit=pool#p220681
I asked if anybody could correlate monitor display settings with the aspect in CIRCLE, to automate it to work everywhere giving a proper circle to the eye, but no luck.
I tried myself a few times a while ago, but was put off by continually changing the display resolution to test - in case I blew out my monitor.

I have to use .95 in screen 21 here (although screen 21 is a bit big for this computer).

Code: Select all


#lang "fb"
'Circle test
'My monitor 1440 x 900
'screen 20  '1024 x 768 - works properly
screen 21  '1280 x 1024 - doesn't work
Dim as Integer x, y, radius
x = 400
y = 400
radius = 300
CIRCLE (x, y), radius, 11,,,.95  'circle is not a circle!
LINE (x - radius, y) - (x + radius, y), 4
LINE (x, y - radius) - (x, y + radius), 4
sleep 
Anjost
Posts: 4
Joined: Jan 10, 2024 19:39
Location: England

Re: Circle bug?

Post by Anjost »

Thanks for both replies.
#include "fbgfx.bi" seems to do what I want and it works with ScreenRes 1920, 1080 which is my monitor resolution.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Circle bug?

Post by caseih »

dodicat wrote: Jan 11, 2024 13:32I tried myself a few times a while ago, but was put off by continually changing the display resolution to test - in case I blew out my monitor.
Blow out your monitor?
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Circle bug?

Post by dodicat »

I have had these troubles in the past caseih, although it was a cathode ray model.
Anjost, how do you manage it using "fbgfx.bi"?
Here was my attempt, how is the circle on your monitor?

Code: Select all


#lang "fb"
'Circle test
'My monitor 1440 x 900

dim as long xr,yr
screeninfo xr,yr
var ratio=xr/yr
#define range(f,l) Int(Rnd*(((l)+1)-(f))+(f))

do
var xres=range(400,1400)
var yres=xres/ratio
screenres xres,yres
width xres\8,yres\16
Dim as Integer x, y, radius
x = xres/2
y = yres/2
radius = .45*yres
CIRCLE (x, y), radius, 11
LINE (x - radius, y) - (x + radius, y), 4
LINE (x, y - radius) - (x, y + radius), 4
print "xres","yres"
print int(xres),int(yres)
print "press space or esc"
sleep
cls
loop until inkey=chr(27) 
Anjost
Posts: 4
Joined: Jan 10, 2024 19:39
Location: England

Re: Circle bug?

Post by Anjost »

dodicat, your code draws correct circles at all resolutions for me.
My revised code using #include "fbgfx.bi" also displays correctly.
Screen 21 graphics looks like it has a bug but maybe nobody uses it any more.

Code: Select all

#lang "fb"
#include "fbgfx.bi"
'Circle test 2
ScreenRes 1280, 1024, 32
Dim As Integer x, y, radius
x = 400
y = 400
radius = 300
Circle (x, y), radius, RGB(0,255,255)
Line (x - radius, y) - (x + radius, y), RGB(255,0,0)
Line (x, y - radius) - (x, y + radius), RGB(255,0,0)
Sleep
Anjost
Posts: 4
Joined: Jan 10, 2024 19:39
Location: England

Re: Circle bug?

Post by Anjost »

Actually, I now realise that fbgfx.bi isn't needed. ScreenRes is sufficient by itself.
Post Reply