public override void GetOutline(global::Android.Views.View view, Outline outline) { // scale based on height var cornerRadius = (view.Width / _hexView.Width) * _hexView.CornerRadius; var offsetAngle = _hexView.OffsetAngle; var hexPath = PolygonUitls.RegularPolygonPath(view.Width, view.Height, _hexView.Sides, cornerRadius, 0, offsetAngle); if (hexPath.IsConvex) { outline.SetConvexPath(hexPath); } }
private void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius, bool pressed) { using (var paint = new Paint { AntiAlias = true }) using (var path = PolygonUitls.RegularPolygonPath(width, height, _polygonFrame.Sides, _polygonFrame.CornerRadius, 0, _polygonFrame.OffsetAngle)) using (Paint.Style style = Paint.Style.Fill) { global::Android.Graphics.Color color = _polygonFrame.BackgroundColor.ToAndroid(); paint.SetStyle(style); paint.Color = color; canvas.DrawPath(path, paint); } }
protected override bool DrawChild(ACanvas canvas, global::Android.Views.View child, long drawingTime) { if (Element == null) { return(false); } var control = Element as PolygonFrame; SetClipChildren(true); using (var path = PolygonUitls.RegularPolygonPath(Width, Height, control.Sides, control.CornerRadius, 0, control.OffsetAngle)) { canvas.Save(); canvas.ClipPath(path); } var result = base.DrawChild(canvas, child, drawingTime); canvas.Restore(); return(result); }