problem with setgadgetshape()

BlitzPlus Forums/BlitzPlus Programming/problem with setgadgetshape()

Scythy(Posted 2008) [#1]
Hello together,



Testcode:


window = CreateWindow("",0,0,1024,768,0,5)
canvas = CreateCanvas(0,0,1280,1280,window)

SetBuffer CanvasBuffer(canvas)

Oval 50,50,500,500,1

SetGadgetShape canvas,0,0,1024,1024 

While WaitEvent(1)<>$803 And KeyHit(1)=0
Wend
End



Problem:

My display has a resolution of 1280x1024, when i draw the window with my code in 1024x768 everything is fine.

When i change my displays resolution to 1024x768 and draw the window, the oval is an egg :-(

The geometry of the canvas seems to be wrong, when display and window resolution are the same.

Where is my fault, and how can i solve the problem?

Thanx in advance


Andy_A(Posted 2008) [#2]
A display of 1280x1024 has an aspect ration of 5:4 (width =5*256, height=4*256) when you change to 1024*768 your aspect ratio changes to 4:3 (width=4*256, height=3*256) so you end up with an oval instead of a circle.

I'm not sure why this is happening because when you change your resolution the aspect ratio should also change, but in this case it isn't. As a work around you could change the dimensions of the oval to reflect the change in aspect ratio to either 500x375 (4:3 ratio) or 500x400 (5:4 ratio) dependent on screen res.


SebHoll(Posted 2008) [#3]
If you were using MaxGUI with BlitzMax, you could respond to the EVENT_GADGETPAINT command using an event hook so that the canvas is redrawn precisely when needed. I'm pretty sure that this is one of the many new events that weren't available in BlitzPlus.