Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[panel] center panel while scaling? #298117
11/12/09 01:41
11/12/09 01:41
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
how can i keep a panel centered even though i change the scale, i've been playing with center_x and center_y but the panel still isnt the scaling the way i want.. scaling to the lower right, any idea?

Re: [panel] center panel while scaling? [Re: darkinferno] #298168
11/12/09 17:05
11/12/09 17:05
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

I think it's
Code:
// place panel in the center of the screen
function center_panel(PANEL* panel)
{	
  panel.pos_x = (screen_size.x - bmap_width(panel.bmap))/2; 
  panel.pos_y = (screen_size.y - bmap_height(panel.bmap))/2;
}



use after the scaling


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: [panel] center panel while scaling? [Re: Ottawa] #298175
11/12/09 18:30
11/12/09 18:30
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
at first though, i'd say the above would work, but it didnt actually, thats assuming that the size of the panel doesnt change... sadly

Re: [panel] center panel while scaling? [Re: darkinferno] #298178
11/12/09 18:34
11/12/09 18:34
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
dont know if it works but you can try it

panel.pos_x = (screen_size.x - bmap_width(panel.bmap)*panel.scale_x)/2

Last edited by flits; 11/12/09 18:35.

"empty"
Re: [panel] center panel while scaling? [Re: darkinferno] #298179
11/12/09 18:34
11/12/09 18:34
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
you should use panel scale and bitmap_widtth/height together in order to achieve this. Only panel's scale changes, bitmaps width and height is dependant on file, and always remains same even if you scale the panel. ill try somethings and see if it works.

edit:flits was faster.

Last edited by Quadraxas; 11/12/09 18:34.

3333333333
Re: [panel] center panel while scaling? [Re: Quad] #298180
11/12/09 18:41
11/12/09 18:41
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Code:
#include <acknex.h>

BMAP* pmap = "map.bmp";
PANEL* test_panel = {
	bmap = pmap;
	flags = SHOW;
}

void main(){
	while(1){
		test_panel.scale_x += time_step*(key_d-key_a);
		test_panel.scale_y += time_step*(key_w-key_s);
		
		test_panel.scale_x = clamp(test_panel.scale_x,0.1,10);
		test_panel.scale_y = clamp(test_panel.scale_y,0.1,10);
		
		test_panel.pos_x = screen_size.x/2-(bmap_width(test_panel.bmap)*test_panel.scale_x/2);
		test_panel.pos_y = screen_size.y/2-(bmap_height(test_panel.bmap)*test_panel.scale_y/2);
		wait(1);
	}
}



use a random bmap and run.


3333333333
Re: [panel] center panel while scaling? [Re: Quad] #298183
11/12/09 19:07
11/12/09 19:07
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
ok thanks guys, worked like a charm


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1