# how do I flip a bezierpath vertically? - Mac Programming

I can't find a nsaffinetransform function to do a vertical flip on a bezier path. Is there one hiding somewhere? Or is there another simple way to flip a path? It is made up of straight lines, all connected, in a closed path, if that makes it easier. Thanks...

1. ## how do I flip a bezierpath vertically?

I can't find a nsaffinetransform function to do a vertical flip on a
bezier path. Is there one hiding somewhere? Or is there another simple
way to flip a path? It is made up of straight lines, all connected, in
a closed path, if that makes it easier.

Thanks
None Guest

2. ## Re: how do I flip a bezierpath vertically?

In article <161120032057328513%com>, None <com>
wrote:

I haven't done it myself, but you build your transform matrix as follows:

Translate so the flip axis gets moved to the X axis, apply the identity
matrix, except use -1 for the Y column, then translate back to the
original position. (Since Y is now flipped, this _might_ be in the
opposite direction from what you'd niavely expect.)
David Guest

3. ## Re: how do I flip a bezierpath vertically?

In article <sf.sbcglobal.net>,
David Phillip Oster <org> wrote:

>
> I haven't done it myself, but you build your transform matrix as follows:
>
> Translate so the flip axis gets moved to the X axis, apply the identity
> matrix, except use -1 for the Y column, then translate back to the
> original position. (Since Y is now flipped, this _might_ be in the
> opposite direction from what you'd niavely expect.)[/ref]

Reflection over line y = k corresponds to the matrix

| 1 0 0 |
| 0 -1 2k |
| 0 0 1 |

(i.e. x' = x, y' = 2k - y)

meeroh

--
If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist>

Miro Guest

4. ## Re: how do I flip a bezierpath vertically?

Thanks to both for the help. For follow up, in case of future seekers,
it also turns out there is a (almost) built-in way to do a flip
NSAffineTransform. As shown in the sample Sketch program from Apple:

if (flippedHorizontally || flippedVertically) {
// If the image needs flipping, we need to play
some games with the transform matrix
NSAffineTransform *transform = [NSAffineTransform
transform];
[transform scaleXBy:([self flippedHorizontally] ?
-1.0 : 1.0) yBy:([self flippedVertically] ? -1.0 : 1.0)];
[transform translateXBy:([self flippedHorizontally]
? -bounds.size.width : 0.0) yBy:([self flippedVertically] ?
-bounds.size.height : 0.0)];
[transform concat];
}
None Guest

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•