[Drawkit] whoopsie...

Graham Cox graham.cox at bigpond.com
Sat Apr 18 17:08:19 PDT 2009


On 19/04/2009, at 3:07 AM, Michael Caron wrote:

> So I realized that my fix to the radius transform only took x into  
> account, which is fine for a scale, but other transforms are left out.
>
> I am reworking it for calculating the hypotenuse instead.
>
> tbc...
>

Hi Michael,

Looks like you found an oversight in DK - not unexpected I guess! Of  
course one problem with DKArcPath is that it is inherently circular,  
meaning it can't meaningfully be scaled by different x, y values...  
you see the same effect when you distort one in a group and ungroup  
it. I think using the hypoteneuse is a good compromise however. This  
is what I do when ungrouping an arc path, where the transform  
represents what the group has done to it:

	NSPoint loc = [self location];
	loc = [aTransform transformPoint:loc];
	
	NSSize radSize = NSMakeSize([self radius], [self radius]);
	radSize = [aTransform transformSize:radSize];
		
	[self setLocation:loc];
	[self setRadius:hypotf( radSize.width, radSize.height ) /  
sqrtf( 2.0f )];
	[self setAngle:[self angle] + [aGroup angle]];


On a general note, don't expect the unionOfAllObjectBounds method to  
be exactly scaled by the same factor, though it should be close. The  
reason is that the bounds of an object is its path bounds + some fixed  
amount, and the union will be the union of these. The "fixed amount"  
isn't scaled with the path bounds, because it depends on style factors  
which don't change with scale.

--Graham




More information about the Drawkit mailing list