Hello!
As what the title says.
Does anyone know of a way to make it so that using the renpy.get_mouse_pos() function and the zoom ATL to zoom in and center at the mouse position?
Zoom in and center at cursor position? [Solved!]
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Newbie
- Posts: 15
- Joined: Tue Nov 03, 2020 4:29 pm
- Contact:
Zoom in and center at cursor position? [Solved!]
Last edited by omranpanda on Sat Sep 11, 2021 3:51 pm, edited 1 time in total.
Re: Zoom in and center at cursor position?
Check this recipe - viewtopic.php?f=51&t=62550omranpanda wrote: ↑Fri Sep 03, 2021 3:52 pm Hello!
As what the title says.
Does anyone know of a way to make it so that using the renpy.get_mouse_pos() function and the zoom ATL to zoom in and center at the mouse position?
-
- Newbie
- Posts: 15
- Joined: Tue Nov 03, 2020 4:29 pm
- Contact:
Re: Zoom in and center at cursor position?
Thanks for this, however this is kinda too overkill for what I needed (And I was unable to implement it for my use case ;!;).Alex wrote: ↑Fri Sep 03, 2021 5:51 pmCheck this recipe - viewtopic.php?f=51&t=62550omranpanda wrote: ↑Fri Sep 03, 2021 3:52 pm Hello!
As what the title says.
Does anyone know of a way to make it so that using the renpy.get_mouse_pos() function and the zoom ATL to zoom in and center at the mouse position?
After spending a couple of days I was able to create the equation to solve this problem!
Basically this is what I got and it works perfectly for me. Sorry if my comments are bad ;!;
Code: Select all
python:
curx, cury = renpy.get_mouse_pos() ## Get cursor position and store in x and y variables.
zoom_factor = 4.0 ## Must be a float number. 4.0 zoom factor means that the image would be enlarged by 4 times, numbers smaller than 1.0 such as 0.5 could be
## used to shrink instead of enlarge.
## Adjust for the displacement caused by the zooming and cursor position.
dx = (config.screen_width/2) - int(curx*zoom_factor)
dy = (config.screen_height/2) - int(cury*zoom_factor) ## int function used because pixels can't be in float (You can't have half a pixel :p)
camera:
parallel:
linear 2.0 zoom zoom_factor
parallel:
linear 2.0 pos(dx, dy)
Who is online
Users browsing this forum: No registered users