vector circles are ellipses on some computers

Just starting out? Need help? Post your questions and find answers here.
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

vector circles are ellipses on some computers

Post by Mesa »

It must be silly but do you have any idea why in few computers, the screen displays an ellipse with the circle function and a circle with the "ellipse" function below ?

All computers have:
OS = Windows
dpiX = 1.0, dpiY=1.0 (96 dpi)
compiled with the option dpi aware or not give the same result.
text zoom = normal = 100%
Resolution: 1024x768 (or any others)

Thanx.

M.

Code: Select all

; OS = Windows
; dpiX=1.0, dpiY=1.0, compiled with the option dpi aware or not.
; zoom 100%
; Resolution: 1024x768

ExamineDesktops()
ResolutionX.d=DesktopWidth(0)
ResolutionY.d=DesktopHeight(0)
Excentricite.d = ResolutionY/ResolutionX
; Excentricite.d = 1.0

If OpenWindow(0, 0, 0, 600, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	CanvasGadget(0, 0, 0, 600, 600)
	
	If StartVectorDrawing(CanvasVectorOutput(0))
		
		
		;cross
		MovePathCursor(300,0)
		AddPathLine(300, 600)
		MovePathCursor(0,300)
		AddPathLine(600, 300)
		StrokePath(1)	
		
		;circle red  -> shown as an ellipse in my screen
		MovePathCursor(300, 300)
		AddPathCircle(300, 300, 200)
		VectorSourceColor(RGBA(255, 0, 0, 255))
		StrokePath(3)
		
		
		;ellipse blue -> shown as a circle !
		MovePathCursor(300, 300)
		AddPathEllipse(300, 300, 300*Excentricite, 300) 
		VectorSourceColor(RGBA(0, 0, 255, 255))
		StrokePath(3)
		
		StopVectorDrawing()
	EndIf
	
	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow
EndIf
Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: vector circles are ellipses on some computers

Post by netmaestro »

Pretty sure that can't happen. It's far more likely that the colors are the culprit here. Colors are probably messed up somehow, maybe endianness. Try some squares on different parts of the screen and see if the colors show right.
BERESHEIT
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: vector circles are ellipses on some computers

Post by Little John »

netmaestro wrote: Fri Sep 16, 2022 5:43 pm Pretty sure that can't happen. It's far more likely that the colors are the culprit here. Colors are probably messed up somehow, maybe endianness. Try some squares on different parts of the screen and see if the colors show right.
Another way to verify this is to execute only the commands for drawing the circle or only those for drawing the ellipse.
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

Re: vector circles are ellipses on some computers

Post by Mesa »

Thank netmaestro, believe me it happens. I tried some squares on different parts of the screen and colors are all alright.
It's not a problem of color but a problem of geometry. Because squares are displayed as rectangles.

Thank Little John, i tried your advice, but it's the same problem.

-> Squares are displayed as rectangles and rectangles (using my excentricity variable, see the code under please) are shown as squares.
-> I've used the parametric equation of circle, see the code under please -> same problem.
-> I've used CanvasVectorOutput() with #PB_Unit_Pixel, #PB_Unit_Point, #PB_Unit_Inch and #PB_Unit_Millimeter -> same problem.
-> I've used the windows api with gDrawing_v0.85b2, here viewtopic.php?t=46987 -> same problem.
-> i've used the Bresenham's algorithm and the Andre's algorithm, here https://www.purebasic.fr/french/viewtop ... =6&t=11172 -> same problem.

So, i guess it's not a purebasic problem.
I guess Windows or the graphic card driver do something during the execution of the .exe...
But it's a problem.

Maybe, pixels are displayed as rectangle and not as a square ?
How can i code this thing to know that ?

Code: Select all

; OS = Windows
; dpiX=1.0, dpiY=1.0, compiled with the option dpi aware or not.
; zoom 100%
; Resolution: 1024x768

ExamineDesktops()
ResolutionX.d=DesktopWidth(0)
ResolutionY.d=DesktopHeight(0)
Excentricity.d = ResolutionY/ResolutionX
; Excentricity.d = 1.0

If OpenWindow(0, 0, 0, 600, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	CanvasGadget(0, 0, 0, 600, 600)
	
	If StartVectorDrawing(CanvasVectorOutput(0))
		
		
		;cross
		MovePathCursor(300,0)
		AddPathLine(300, 600)
		MovePathCursor(0,300)
		AddPathLine(600, 300)
		StrokePath(1)	
		
		;red circle  -> shown as an ellipse in my screen
		MovePathCursor(300, 300)
		AddPathCircle(300, 300, 200)
		VectorSourceColor(RGBA(255, 0, 0, 255))
		StrokePath(3)
		
		
		;blue ellipse -> shown as a circle !
		MovePathCursor(300, 300)
		AddPathEllipse(300, 300, 300*Excentricity, 300) 
		VectorSourceColor(RGBA(0, 0, 255, 255))
		StrokePath(3)
		
		;marroon square shown as a rectangle
		AddPathBox(50, 50, 200, 200)
		VectorSourceColor(RGBA(128, 0, 0, 255))
		StrokePath(3)
		
		;Yellow rectangle shown as a square
		AddPathBox(50, 50, 200*Excentricity, 200)
		VectorSourceColor(RGBA(255, 255, 0, 255))
		StrokePath(3)
		
		StopVectorDrawing()
	EndIf
	
	;green Parametric equations of circle  -> shown as an ellipse
	StartDrawing(CanvasOutput(0))
	i.d=0
	Repeat
		a.d=Radian(i)
		x.d = 300 + 195*Cos(a)
		y.d = 300 + 195*Sin(a)
		Circle(x,y,2,#Green)
		i=i+1
	Until i>360
	
	;magenta Parametric equations of ellipse -> shown as a circle
	i.d=0
	Repeat
		a.d=Radian(i)
		x.d = 300 + 190*Cos(a)*Excentricity
		y.d = 300 + 190*Sin(a)
		Circle(x,y,2,#Magenta)
		i=i+1
	Until i>360
	
	
	StopDrawing()
	
	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow
EndIf
Thanks.

M.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: vector circles are ellipses on some computers

Post by Little John »

That's really strange. :x
Mesa, with which PureBasic version(s) do you encounter this issue?
Does it make a difference, whether in PB 6.00 you use the ASM backend or the new C backend?
(I'm just poking in the fog.)
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: vector circles are ellipses on some computers

Post by Olli »

Could you test this and tell the results ?

Here, I get near 1.75 and 1.75

Code: Select all

Define.d ww,wh,dw,dh,dpiW,dpiH

dw = DesktopWidth(0 & ExamineDesktops() )
dh = DesktopHeight(0)

temp = OpenWindow(#PB_Any, 0,0,1,1,"", #PB_Window_Borderless | #PB_Window_Maximize | #PB_Window_Invisible)

ww = WindowWidth(temp)
wh = WindowHeight(temp)

CloseWindow(temp)

dpiW = dw / ww
dpiH = dh / wh

Debug dpiW
Debug dpiH
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: vector circles are ellipses on some computers

Post by mk-soft »

I haven't had that yet either ...
Or was it a very long time ago? ... Could be a stretching function of the monitor
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: vector circles are ellipses on some computers

Post by netmaestro »

Boot into safe mode and try it.
BERESHEIT
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

Re: vector circles are ellipses on some computers

Post by Mesa »

Could be a stretching function of the monitor
Bingo !

I've changed the monitor and it works now.

Is there a way to prevent that with purebasic, in your opinion ?
Does WMI can get all characteristics of a monitor ?

Thanks for all, i tested all advices of this thread, nothing works.

M.
User avatar
Caronte3D
Addict
Addict
Posts: 1025
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: vector circles are ellipses on some computers

Post by Caronte3D »

In the past some CRT monitors have non-square pixels by construction, maybe thi's the same case.
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

Re: vector circles are ellipses on some computers

Post by Mesa »

@Caronte3D: I've a lcd monitor, not so old but the screen is stretched because the resolution is 1024x768 (4/3) in a 16/9 monitor and full screen, so circles are ellipses.
When i change the resolution to 1920x1080 (16/9) then everything is correct, circles are circles.

But it's a problem when users have a stretched screen and I don't see how to do without user intervention. :cry:

M.
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: vector circles are ellipses on some computers

Post by mk-soft »

Solution:
Hello User ... Buy a new monitor 8)

Or add user parameters for calibrate monitor
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Caronte3D
Addict
Addict
Posts: 1025
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: vector circles are ellipses on some computers

Post by Caronte3D »

mk-soft wrote: Fri Sep 30, 2022 5:19 pm Solution:
Hello User ... Buy a new monitor 8)

Or add user parameters for calibrate monitor
Best solution ever :D
Post Reply