diff --git a/docs/_docs/corner-rounding.md b/docs/_docs/corner-rounding.md index a69f8fa6a2..1163ed3fe9 100755 --- a/docs/_docs/corner-rounding.md +++ b/docs/_docs/corner-rounding.md @@ -97,3 +97,130 @@ CALayer's `.shouldRasterize` is unrelated to Texture `node.shouldRasterizeDescen Use this flowchart to select the most performant strategy to round a set of corners. corner rounding strategy flowchart + +## Texture Support + +The following code exemplifies different ways how to archive corner rounding within Texture: + +### Use `.cornerRadius` + +
+SwiftObjective-C +
+
+CGFloat cornerRadius = 20.0;
+    
+_photoImageNode.cornerRoundingType = ASCornerRoundingTypeDefaultSlowCALayer;
+_photoImageNode.cornerRadius = cornerRadius;
+
+ +
+
+ + +### Use precomposition for rounding corners + +
+SwiftObjective-C +
+
+CGFloat cornerRadius = 20.0;
+    
+_photoImageNode.cornerRoundingType = ASCornerRoundingTypePrecomposited;
+_photoImageNode.cornerRadius = cornerRadius;
+
+ +
+
+ + +### Use clipping for rounding corners + +
+SwiftObjective-C +
+
+CGFloat cornerRadius = 20.0;
+
+_photoImageNode.cornerRoundingType = ASCornerRoundingTypeClipping;
+_photoImageNode.backgroundColor = [UIColor whiteColor];
+_photoImageNode.cornerRadius = cornerRadius;
+
+ +
+
+ + +### Use `willDisplayNodeContentWithRenderingContext` to set a clipping path for the content for rounding corners + +
+SwiftObjective-C +
+
+CGFloat cornerRadius = 20.0;
+    
+// Use the screen scale for corner radius to respect content scale
+CGFloat screenScale = UIScreen.mainScreen.scale;
+_photoImageNode.willDisplayNodeContentWithRenderingContext = ^(CGContextRef context, id drawParameters) {
+    CGRect bounds = CGContextGetClipBoundingBox(context);
+    CGFloat radius = cornerRadius * screenScale; 
+    UIImage *overlay = [UIImage as_resizableRoundedImageWithCornerRadius:radius
+                                                             cornerColor:[UIColor clearColor]
+                                                               fillColor:[UIColor clearColor]];
+    [overlay drawInRect:bounds];
+    [[UIBezierPath bezierPathWithRoundedRect:bounds cornerRadius:radius] addClip];
+};
+
+
+ +
+
+ +### Use `ASImageNode` extras to round the image and add a border. + +This is great for example to round avatar images. + +
+SwiftObjective-C +
+
+CGFloat cornerRadius = 20.0;
+
+_photoImageNode.imageModificationBlock = ASImageNodeRoundBorderModificationBlock(5.0, [UIColor orangeColor]);
+
+ +
+