{"action":"created","issue":{"url":"https://api.github.com/repos/Khan/Prototope/issues/89","labels_url":"https://api.github.com/repos/Khan/Prototope/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/Khan/Prototope/issues/89/comments","events_url":"https://api.github.com/repos/Khan/Prototope/issues/89/events","html_url":"https://github.com/Khan/Prototope/issues/89","id":78641406,"number":89,"title":"ShapeLayer's geometry semantics are weird","user":{"login":"andymatuschak","id":2771,"avatar_url":"https://avatars.githubusercontent.com/u/2771?v=3","gravatar_id":"","url":"https://api.github.com/users/andymatuschak","html_url":"https://github.com/andymatuschak","followers_url":"https://api.github.com/users/andymatuschak/followers","following_url":"https://api.github.com/users/andymatuschak/following{/other_user}","gists_url":"https://api.github.com/users/andymatuschak/gists{/gist_id}","starred_url":"https://api.github.com/users/andymatuschak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andymatuschak/subscriptions","organizations_url":"https://api.github.com/users/andymatuschak/orgs","repos_url":"https://api.github.com/users/andymatuschak/repos","events_url":"https://api.github.com/users/andymatuschak/events{/privacy}","received_events_url":"https://api.github.com/users/andymatuschak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-20T18:39:59Z","updated_at":"2015-05-20T19:00:24Z","closed_at":null,"body":"`ShapeLayer` is built on `CAShapeLayer`, from which it inherits an odd API detail: the geometry of the layer is distinct from the geometry of the path.\r\n\r\nThat is to say: if I make a shape layer and add two segments at (0, 0) and (100, 100), the bounds of the layer is unaffected by those segments' positions. Changing the layer's position doesn't change the segments' position and vice-versa. Hit testing in particular becomes a very weird thing!\r\n\r\nI propose:\r\n* `ShapeLayer.position { get }` returns `path.bounds` at `ShapeLayer.anchorPoint`.\r\n* `ShapeLayer.anchorPoint` operates relative to `path`, not the full bounds of the layer.\r\n* Changing `segments` changes `Layer.anchorPoint` so that it reflects `ShapeLayer.anchorPoint` relative to the new path's bounds.\r\n* `ShapeLayer.position { set }` adds `newValue`'s delta to each segment's points.\r\n* `ShapeLayer.bounds { get }` returns `path.bounds`.\r\n* `ShapeLayer.frame { get }` transforms the `position` and `bounds` overrides described above, not `Layer`'s implementations.\r\n* `ShapeLayer.frame { set }` and `ShapeLayer.bounds { set }` throw an exception if the `size` of the new `Rect` is different from the current one.\r\n\r\nSegment coordinates are specified in the `ShapeLayer`'s superlayer's coordinate space."},"comment":{"url":"https://api.github.com/repos/Khan/Prototope/issues/comments/103996472","html_url":"https://github.com/Khan/Prototope/issues/89#issuecomment-103996472","issue_url":"https://api.github.com/repos/Khan/Prototope/issues/89","id":103996472,"user":{"login":"jbrennan","id":131923,"avatar_url":"https://avatars.githubusercontent.com/u/131923?v=3","gravatar_id":"","url":"https://api.github.com/users/jbrennan","html_url":"https://github.com/jbrennan","followers_url":"https://api.github.com/users/jbrennan/followers","following_url":"https://api.github.com/users/jbrennan/following{/other_user}","gists_url":"https://api.github.com/users/jbrennan/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrennan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrennan/subscriptions","organizations_url":"https://api.github.com/users/jbrennan/orgs","repos_url":"https://api.github.com/users/jbrennan/repos","events_url":"https://api.github.com/users/jbrennan/events{/privacy}","received_events_url":"https://api.github.com/users/jbrennan/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T19:00:24Z","updated_at":"2015-05-20T19:00:24Z","body":">- ShapeLayer.anchorPoint operates relative to path, not the full bounds of the layer.\r\n>- Changing segments changes Layer.anchorPoint so that it reflects ShapeLayer.anchorPoint relative to the new path's bounds.\r\n\r\nI think I’m a little clear on the implications of this. What does this mean practically?"}}