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 rerendering after applying CGAffineTransform(scaleX: 2.0, y: 2.0) on MacawView #550

Closed
nsandeepa opened this issue Mar 19, 2019 · 4 comments
Assignees
Milestone

Comments

@nsandeepa
Copy link

Hi
I am currently implementing a pinch zoom for Macaw view. I have implemented pinch zooming rotation and panning well using CGAffineTransform. But the problem is i need to re render the SVG that is shown in MacawView after zooming in so that i the SVG is not pixelated after zooming. I tried ContentLayout to scale the SVG but it is hard to sync scale of the MacawView and ContentLayout. And also i tried applying node.place.scale() but it is not working either. Is there a solution for this.
Could you please help me with this?

@ystrot ystrot self-assigned this Mar 22, 2019
@ystrot
Copy link
Member

ystrot commented Mar 22, 2019

Hi Nilupul,

Zooming is a complicated task and we're going to add built-in support in the next release. If you want to implement it yourself for your specific task, here is my recommendations:

  • Don't use CGAffineTransform at all to avoid pixelation.
  • Don't use ContentLayout because it will replace your root scaling.
  • You should have root Group which place will only contain zooming transformations. On pinch/pan/etc. gestures you need to calculate correct affine transformation and update root's place:
view.root.place = transform

@glennposadas
Copy link

Hi, I'd like to help. We just resolved the scrolling + zooming in issue without pixelation.
Take a look at Santosh's comment here in the repo, he uploaded his sample project. And you can start your work from there.

For zooming in without pixelation, all you have to do is scale your svg view. Like so:

public func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
        
        DispatchQueue.main.async {
            print("update")
            self.svgView.contentScaleFactor = scale + 5
            self.svgView.layoutIfNeeded()
        }
    }

Voila! I hope this helps!

@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 feature, so closing this issue.

@ystrot ystrot closed this as completed Jul 28, 2020
@glennposadas
Copy link

glennposadas commented Jul 28, 2020 via email

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

3 participants