I'm trying to convert an array of points using a CGAffineTransform
. The scaling works perfectly, however the points are using the top left as (0,0) not the bottom left. like so...
Normally I would simply use CGAffineTransformMakeScale(1,-1);
but because I'm already performing a scale I can't add it to the existing transform.
Here's my current code
- (CGAffineTransform)transformFromValueToScreen
{
CGRect fromRect = self.valueSpace;
CGRect viewRect = self.screenSpace;
CGSize scales = CGSizeMake(viewRect.size.width/fromRect.size.width,
viewRect.size.height/fromRect.size.height);
CGAffineTransform transform = CGAffineTransformMakeScale(scales.width,
scales.height);
return transform;
}
I'm assuming
fromRect.origin
isCGPointZero
.You need a compound transform that moves the origin to the lower left, flips the Y axis, and applies the scaling you want.
You can make a compound transform using the functions that modify a transform, like this: