Re: Coordinate conversions in CALayer

2013-01-24 Thread Graham Cox
On 25/01/2013, at 11:41 AM, Matt Neuburg wrote: > It sounds like you sometimes program the way I do - just bang on the black > box until the right thing comes out the other end, then stop. :) m. Well in this case, yes. I hate that - I much prefer to have a good understanding rather than acce

Re: Coordinate conversions in CALayer

2013-01-24 Thread Matt Neuburg
On Jan 24, 2013, at 3:12 PM, Graham Cox wrote: > stumbled upon the right result which correctly transforms down through a > series of nested layers and back up again. Don't ask me how it works or I'll > start to whimper It sounds like you sometimes program the way I do - just bang on the blac

Re: Coordinate conversions in CALayer

2013-01-24 Thread Graham Cox
On 25/01/2013, at 12:42 AM, Matt Neuburg wrote: > They are not equivalent because the first one starts with > CGContextTranslateCTM but the second one starts with > CGAffineTransformMakeTranslation. In other words, the first one begins by > translating the current transform. The second one be

Re: Coordinate conversions in CALayer

2013-01-24 Thread Matt Neuburg
> Date: Thu, 24 Jan 2013 12:01:28 +1100 > From: Graham Cox > To: "cocoa-dev@lists.apple.com Dev" > Subject: Re: Coordinate conversions in CALayer > Boiling down my problem to its bare essentials, why are these two bits of > code not equivalent? > > >

Re: Coordinate conversions in CALayer

2013-01-24 Thread James Montgomerie
On 24 Jan 2013, at 08:19, Graham Cox wrote: > I've made some progress, in that I managed to make the two code snippets work > the same, by changing this line: > > tfm = CGAffineTransformConcat( tfm, layer.transform ); > > to this: > > tfm = CGAffineTransformConcat( layer.transform

Re: Coordinate conversions in CALayer

2013-01-24 Thread Graham Cox
On 24/01/2013, at 12:42 PM, Quincey Morris wrote: > This sort of thing drives me nuts too. You have to simplify the problem. > > 1. In the scenario where bounds.origin is (0,0) and the anchor point is (0,0) > -- which should be be a very ordinary scenario to set up, even if you have to > abu

Re: Coordinate conversions in CALayer

2013-01-23 Thread Quincey Morris
On Jan 23, 2013, at 17:01 , Graham Cox wrote: > The above works correctly, but below, which I thought should do the same, > does not, if the layer.transform property is not the identity matrix: > > > CGPoint anch = layer.anchorPoint; > CGRect br = layer.bounds; > CGPoint pos

Re: Coordinate conversions in CALayer

2013-01-23 Thread Graham Cox
On 23/01/2013, at 5:41 PM, Graham Cox wrote: > To create a transform that supposedly will transform from the superlayer TO > the layer, and I then invert it to go back the other way. It works in the > simple case, but a rotation transform upsets things. I've tried pretty much > every combinat

Re: Coordinate conversions in CALayer

2013-01-22 Thread Graham Cox
On 22/01/2013, at 4:35 PM, Andy Lee wrote: > On Jan 21, 2013, at 5:12 PM, Graham Cox wrote: >> My question is, is there a way to directly convert coordinates between two >> unrelated layers in a tree, or are these methods implemented by recursion up >> to a common parent node and then back do

Re: Coordinate conversions in CALayer

2013-01-21 Thread Andy Lee
On Jan 21, 2013, at 5:12 PM, Graham Cox wrote: > My question is, is there a way to directly convert coordinates between two > unrelated layers in a tree, or are these methods implemented by recursion up > to a common parent node and then back down to the target layer? If I had some > hint of ho

Coordinate conversions in CALayer

2013-01-21 Thread Graham Cox
Hi all, Recently I built an (experimental) app around CALayer and friends which implements a vector schematic editor. I found that CALayer isn't, not too surprisingly, really a good base for vector graphics - CAShapeLayer is nice enough but there's nothing for text and I rapidly ran into probl