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

FYI PuzzleUnit Path must be flipped vertically for usage #11

Open
sabiland opened this issue May 30, 2024 · 0 comments
Open

FYI PuzzleUnit Path must be flipped vertically for usage #11

sabiland opened this issue May 30, 2024 · 0 comments

Comments

@sabiland
Copy link

This is just informationally. To use puzzleUnit.path, you have to flip the path vertically. Extension UIBezierPath:

func flipIt(vertically: Bool)
{
    let rect = self.bounds
    if vertically
    {
        self.apply(CGAffineTransform(translationX: 0, y: -rect.origin.y))
        self.apply(CGAffineTransform(scaleX: 1, y: -1))
        self.apply(CGAffineTransform(translationX: 0, y: rect.origin.y + rect.height))
    }
    else
    {
        //first, you need to move the view all the way to the left
        //because otherwise, if you mirror it in its current position,
        //the view will be thrown way off screen to the left
        self.apply(CGAffineTransform(translationX: -rect.origin.x, y: 0))
        //then you mirror it
        self.apply(CGAffineTransform(scaleX: -1, y: 1))
        //then, after its mirrored, move it back to its original position
        self.apply(CGAffineTransform(translationX: rect.origin.x + rect.width, y: 0))
    }
}
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

1 participant