using Xui.Core.Canvas; using Xui.Core.Math2D; using Xui.Core.UI; using Xui.Core.UI.Input; using NFloat = System.Runtime.InteropServices.NFloat; public sealed class PathView : View { private bool fill = true; protected override void RenderCore(IContext context) { context.SetFill(new Color(0xFAF7FFFF)); context.FillRect(Frame); context.Save(); try { context.Translate((Frame.X + Frame.Width / 2, Frame.Y + Frame.Height / 2)); NFloat scale = NFloat.Min(Frame.Width / 320, Frame.Height / 440); context.Scale((scale, scale)); context.BeginPath(); context.MoveTo((-120, 40)); context.CurveTo((-120, -160), (120, -160), (120, 40)); context.LineTo((0, 120)); context.ClosePath(); if (fill) { context.SetFill(new Color(0xD9B6F4FF)); context.Fill(); } context.SetStroke(new Color(0x8538CEFF)); context.LineWidth = 6; context.LineJoin = LineJoin.Round; context.Stroke(); context.BeginPath(); context.Arc((0, 0), 28, 0, NFloat.Pi * 2); context.SetFill(new Color(0xD957A8FF)); context.Fill(); } finally { context.Restore(); } context.SetFill(new Color(0x492571FF)); context.SetFont(new Font(18, "Inter")); context.TextAlign = TextAlign.Center; context.FillText("Tap to switch fill on or off", (Frame.Center.X, Frame.Y + 56)); } public override void OnPointerEvent(ref PointerEventRef e, EventPhase phase) { if (phase == EventPhase.Bubble && e.Type == PointerEventType.Down) { fill = !fill; InvalidateRender(); } } }