PanAndZoom | Pan and zoom control for Avalonia
kandi X-RAY | PanAndZoom Summary
kandi X-RAY | PanAndZoom Summary
PanAndZoom control for Avalonia.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PanAndZoom
PanAndZoom Key Features
PanAndZoom Examples and Code Snippets
Community Discussions
Trending Discussions on PanAndZoom
QUESTION
The ask: How do I get the viewing rectangle in the coordinates of a transformed and scaled node?
The code is attached below, it is based upon the code from this answer: JavaFX 8 Dynamic Node scaling
The details:
I have a simple pane, BigGridPane
that contains a collection of squares, all 50x50.
I have it within this PanAndZoomPane
construct that was lifted from the answer referenced above. I can not honestly say I fully understand the PanAndZoomPane
implementation. For example, it's not clear to me why it needs a ScrollPane
at all, but I have not delved in to trying without it.
The PanAndZoomPane
lets me pan and zoom my BigGridPane. This works just dandy.
There are 4 Panes involved in this total construct, in this heirarchy: ScrollPane
contains PanAndZoomPane
which contains Group
which contains BigGridPane
.
ANSWER
Answered 2022-Jan-24 at 01:00Generally, you can get the bounds of node1
in the coordinate system of node2
if both are in the same scene using
QUESTION
Update: I found a solution to my own question. See answer below.
I'm working on a center-and-zoom feature for my canvas. When the user clicks on the screen, the clicked point should be moved to the center and zoomed in.
I have two canvases. The first canvas is rendered on screen and shows a portion of the second canvas. The second canvas is not a true "OffscreenCanvas" but is stored in memory only.
The panning and zooming is done in increments using requestAnimationFrame.
Since it's probably a good idea to let the "offscreen canvas" remain unaltered, I'm attempting to apply all of the changes to the onscreen canvas. Panning is simple enough, but how to combine panning and zooming?
In the current code, zooming is achieved by shrinking the size of the viewport (viewportWidth or Height -= viewportWidth or Height * 0.01). I then compensate for the smaller viewport by panning a bit further than I would have otherwise (+ viewportWidth or Height * 0.01 * 0.5).
[![image explaining my problem with panning and zooming][1]][1]
However, with this solution, the screen centers on a point to the left of where the user clicked. Can you tell me what I'm doing wrong?
Alternatively, if there is a better way to go about this, I would be very happy to hear about it.
This is what I've come up with so far:
...ANSWER
Answered 2022-Jan-14 at 03:47Okay, so I found a solution. Instead of decreasing the size of the viewport for each redraw, I should have increased the size of the scaling.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PanAndZoom
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page