考虑到NSrect,如何绘制坐标轴但保持正确的表示方式?
使用以下代码,我可以将轴居中放置在视图中间
NSRect funcRect= {-50,-50,50,50};
[tf translateXBy:[self bounds].size.width/2
yBy:[self bounds].size.height/2];
[tf scaleXBy:[self bounds].size.width/funcRect.size.width
yBy:[self bounds].size.height/funcRect.size.height];
[tf concat];
然后,我使用NSBezierPath绘制轴。 参见:i.imgur.com/rT7M5WX.jpg
但是假设我的NSrect是不同的,例如:
NSRect funcRect= {-5,-5,15,30};
如何应用af转换,以便在我的视图的正确位置绘制轴,而不是始终在中间绘制轴 参见:i.imgur.com/Z2aBcbE.jpg
我的绘制轴代码: ...
NSrect * aPoint;
aPoint.x = funcRect.origin.x;
aPoint.y = 0;
[drawer moveToPoint:aPoint];
while (aPoint.x <= funcRect.origin.x + funcRect.size.width)
{
[drawer lineToPoint:aPoint];
aPoint.x += 1;
}
[drawer stroke];
...