Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / zooming a window that's already been scaled?

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 12th Sep 2022 11:41 Edited at: 12th Sep 2022 11:44
I have the following code that I use to scale a sprite to a window size for drawing purposes etc (that works)


The problem is I want to be able to use view zoom with the scaling and select a window on screen and do something like



worldtoscreen and screentoworld will not work, at-least not the way I have been trying to use them, so I'm hoping a math Guru may
be able to point me in the direction where i could perhaps use those with an already scaled window. It messes up worse as the scales
get further distant from original
PK
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 12th Sep 2022 13:46 Edited at: 12th Sep 2022 13:49
Will this help?


fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 12th Sep 2022 19:51 Edited at: 13th Sep 2022 05:46
Thanks Steve thats a clever bit of code but not quite the math fix i was after

The below snippet is capable of zooming into anywhere on screen the main issue as I use the scale command ie setspritescale(spr,4,4) already in my code
as i restrict to a smaller size for later conversions. The world view and screen view become quite different, this is noticeable by the mouse pointer
being different than a sprite im holding. which correct positioning can be achieved by my first scale formula until i begin to try to set a view which throws out
the math "dx=locX*canvasSize/windowSize:dy=locY*canvasSize/windowSize" which works until I attempt to change viewoffset. Im thinking the align
world function example in the help files function with some modification may help. Ottherwise my color picking functions fail once zoomed and the
drawing becomes way off view.




Edit..all good i managed a fix that works for my desires thanks again
PK

Login to post a reply

Server time is: 2024-11-21 13:24:15
Your offset time is: 2024-11-21 13:24:15