Re: Retrieving transformed points of BezierPath
Re: Retrieving transformed points of BezierPath
- Subject: Re: Retrieving transformed points of BezierPath
- From: Youngjin Kim <email@hidden>
- Date: Sun, 3 Jun 2001 15:10:09 +0900
Hi,
I found I my assumption of prior mail is utterly not true. The code
below prints transformed points of elements in a path.
Strangely, the output had been printing coordinates of original path due
to simple mistake in coding, apology to all for the confusion my
question might have caused.
transformUsingAffineTransform applies to individual points of
BezierPath. BezierPath doesn't have internal transform object.
So please ignore my question.
Thanks,
Youngjin
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