Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG pinch/zoom performance? #513

Closed
philmitchell opened this issue Dec 18, 2018 · 3 comments
Closed

SVG pinch/zoom performance? #513

philmitchell opened this issue Dec 18, 2018 · 3 comments
Assignees
Milestone

Comments

@philmitchell
Copy link

I load an svg file into MacawView and manually update node.place, along with view.bounds. It works very nicely, except performance is a little sluggish. Is there a better way?

Also, it's not hard to get a memory crash if you zoom way in ....

    @objc func didPinch(pinchGestureRecognizer: UIPinchGestureRecognizer) {
        let node = macawView.node
        let scale = pinchGestureRecognizer.scale
        let location = pinchGestureRecognizer.location(in: macawView)
        let dx = Double(location.x * (1 - scale))
        let dy = Double(location.y * (1 - scale))
        node.place = node.place
          .scale(sx: Double(scale), sy: Double(scale))
          .move(dx: dx, dy: dy)
        let transform = CGAffineTransform.identity.scaledBy(x: scale, y: scale)
        macawView.bounds = macawView.bounds.applying(transform)
        pinchGestureRecognizer.scale = 1.0
    }
@ystrot ystrot self-assigned this Dec 18, 2018
@ystrot
Copy link
Member

ystrot commented Dec 18, 2018

Hi Phil,

Did you use some SVG to reproduce it? Would be great if you can attach it. I believe it depends on SVG complexity in your case.

@philmitchell
Copy link
Author

Thanks, Yuri. I see this with any reasonably complex svg, including the tiger.svg in your example app. Attached is another sample. (Note: although sample1.svg throws some parse errors, we see this behavior with files that have no parse issues as well.)
sample1.svg.zip

@ystrot ystrot added this to the 0.9.6 milestone Apr 4, 2019
@ystrot ystrot modified the milestones: 0.9.6, 0.9.7 Apr 10, 2020
@ystrot
Copy link
Member

ystrot commented Jul 28, 2020

There is now MacawView.zoom property with a pretty fast zoom/pinch feature.

@ystrot ystrot closed this as completed Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants