Skip to content

Instantly share code, notes, and snippets.

@hfossli
Last active July 21, 2017 10:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hfossli/5130975 to your computer and use it in GitHub Desktop.
Save hfossli/5130975 to your computer and use it in GitHub Desktop.
Tests
CGPoint CGPointApplyCATransform3D(CGPoint point, CATransform3D transform, CGPoint anchorPoint, CATransform3D parentSublayerTransform)
{
static CALayer *sublayer, *layer;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sublayer = [CALayer layer];
layer = [CALayer layer];
[layer addSublayer:sublayer];
});
objc_sync_enter(layer);
layer.sublayerTransform = parentSublayerTransform;
sublayer.transform = transform;
sublayer.anchorPoint = anchorPoint;
CGPoint retval = [sublayer convertPoint:point toLayer:layer];
objc_sync_exit(layer);
return retval;
}
- (void)testCGPointApplyCATransform3D
{
{
CGPoint p = CGPointMake(0, 0);
CATransform3D t = CATransform3DMakeScale(1.8, 1.4, 0.0);
CGPoint anchorPoint = CGPointMake(0, 0);
CGPoint retval = CGPointApplyCATransform3D(p, t, anchorPoint, CATransform3DIdentity);
CGPoint correct = CGPointMake(0, 0);
STAssertEquals(retval, correct, nil);
}
{
CGPoint p = CGPointMake(100, 100);
CATransform3D t = CATransform3DMakeScale(1.8, 1.4, 0.0);
CGPoint anchorPoint = CGPointMake(0, 0);
CGPoint retval = CGPointApplyCATransform3D(p, t, anchorPoint, CATransform3DIdentity);
CGPoint correct = CGPointMake(180, 140);
STAssertEquals(retval, correct, nil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment