void RCTPathCreateOuterOutline(bool drawToEdge, CGRect rect, RCTCornerRadii cornerRadii) { if (drawToEdge) { Log.Info(ReactConstants.Tag, "[RCTPathCreateOuterOutline] ReactBorderDrawingManager , cairo:" + cairo); Log.Info(ReactConstants.Tag, "[RCTPathCreateOuterOutline] rect.origin.x:" + rect.origin.x + ", rect.origin.y:" + rect.origin.y + ", rect.size.width:" + rect.size.width + ", rect.size.height:" + rect.size.height); // add a new rectangle path here in cairo context Cairo.cairo_rectangle(cairo, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); pathOuter = Cairo.cairo_copy_path(cairo); //Cairo.cairo_stroke(cairo); return; } //RCTPathCreateWithRoundedRect(rect, RCTGetCornerInsets(cornerRadii, new UIEdgeInsets(0,0,0,0))); pathOuter = RCTPathCreateWithRoundedRect(rect, RCTGetCornerInsets(cornerRadii, new UIEdgeInsets(0, 0, 0, 0))); }
IntPtr RCTPathCreateWithRoundedRect(CGRect bounds, RCTCornerInsets cornerInsets ) { Log.Info(ReactConstants.Tag, "[RCTPathCreateWithRoundedRect] ReactBorderDrawingManager::RCTPathCreateWithRoundedRect BGN "); Log.Info(ReactConstants.Tag, "[RCTPathCreateWithRoundedRect] bounds.origin.x:" + bounds.origin.x + ", bounds.origin.y:" + bounds.origin.y + ", bounds.size.width:" + bounds.size.width + ", bounds.size.height:" + bounds.size.height); float minX = RectGetMinX(bounds); float minY = RectGetMinY(bounds); float maxX = RectGetMaxX(bounds); float maxY = RectGetMaxY(bounds); CGSize topLeft = new CGSize ( Math.Max(0, Math.Min(cornerInsets.topLeft.width, bounds.size.width - cornerInsets.topRight.width)), Math.Max(0, Math.Min(cornerInsets.topLeft.height, bounds.size.height - cornerInsets.bottomLeft.height)) ); CGSize topRight = new CGSize ( Math.Max(0, Math.Min(cornerInsets.topRight.width, bounds.size.width - cornerInsets.topLeft.width)), Math.Max(0, Math.Min(cornerInsets.topRight.height, bounds.size.height - cornerInsets.bottomRight.height)) ); CGSize bottomLeft = new CGSize ( Math.Max(0, Math.Min(cornerInsets.bottomLeft.width, bounds.size.width - cornerInsets.bottomRight.width)), Math.Max(0, Math.Min(cornerInsets.bottomLeft.height, bounds.size.height - cornerInsets.topLeft.height)) ); CGSize bottomRight = new CGSize ( Math.Max(0, Math.Min(cornerInsets.bottomRight.width, bounds.size.width - cornerInsets.bottomLeft.width)), Math.Max(0, Math.Min(cornerInsets.bottomRight.height, bounds.size.height - cornerInsets.topRight.height)) ); CGPoint p1 = new CGPoint ( minX + topLeft.width, minY + topLeft.height ); CGPoint p2 = new CGPoint ( maxX - topRight.width, minY + topRight.height ); CGPoint p3 = new CGPoint ( maxX - bottomRight.width, maxY - bottomRight.height ); CGPoint p4 = new CGPoint ( minX + bottomLeft.width, maxY - bottomLeft.height ); // begin a new cairo drawing path without current point Cairo.cairo_new_sub_path(cairo); RCTPathAddEllipticArc(cairo, IntPtr.Zero, p1, topLeft, Math.PI, 3 * Math.PI / 2, false); RCTPathAddEllipticArc(cairo, IntPtr.Zero, p2, topRight, 3 * Math.PI / 2, 0, false); RCTPathAddEllipticArc(cairo, IntPtr.Zero, p3, bottomRight, 0, Math.PI / 2, false); RCTPathAddEllipticArc(cairo, IntPtr.Zero, p4, bottomLeft, Math.PI / 2, Math.PI, false); /// auto close the current by draw a line to the init point Cairo.cairo_close_path(cairo); IntPtr path = Cairo.cairo_copy_path(cairo); //Cairo.cairo_stroke(cairo); return(path); }