Retrieving transformed points of BezierPath
Retrieving transformed points of BezierPath
- Subject: Retrieving transformed points of BezierPath
- From: Youngjin Kim <email@hidden>
- Date: Sun, 3 Jun 2001 10:29:27 +0900
How can I retrieve transformed points of NSBezierPath?
My bezier path was constructed with moveToPoint()/lineToPoint() methods
and transformed using transformUsingAffineTransform() and my custom view
reflects this change correctly. but when I retrieve individual points
using elementAtIndex(), it retrieves points in untransformed
coordinates. It seems that NSBezierPath has it's transform object
internally and using it when displaying. but I don't want to keep track
of transform objects of each paths unnecessarily. How do I retrieve
transform object or transformed points of bezier path?
NSPoint *pts = malloc(sizeof(NSPoint));
NSBezierPath *path;
NSAffineTransform* transform = (NSAffineTransform transform);
...
transform = [NSAffineTransform transform];
[transform translateXBy:dx yBy:dy];
[path transformUsingAffineTransform:transform];
...
for (j=0;j<[path elementCount]-1;j++) {
[path elementAtIndex:j associatedPoints:pts];
*((NSPoint*)(path_pts+j)) = *pts;
printf("x:%f,",pts->x);
printf("y:%f\n",pts->y); // will print untransfomed coordinates
}
Youngjin