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 TransformDial : View { private int step = 1; protected override void RenderCore(IContext context) { context.SetFill(new Color(0xFAF7FFFF)); context.FillRect(Frame); context.Save(); try { context.Translate((Frame.Center.X, Frame.Center.Y)); NFloat scale = NFloat.Min(Frame.Width, Frame.Height) / 320; context.Scale((scale, scale)); for (int i = 0; i < 12; i++) { context.Save(); context.Rotate(i * NFloat.Pi / 6); context.SetFill(new Color(0xD9B6F4FF)); context.FillRect(new Rect(-3, -120, 6, 16)); context.Restore(); } context.Rotate(step * NFloat.Pi / 6); context.SetFill(new Color(0x8538CEFF)); context.FillRect(new Rect(-8, -90, 16, 105)); context.BeginPath(); context.Arc((0, 0), 14, 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 rotate one step", (Frame.Center.X, Frame.Y + 56)); } public override void OnPointerEvent(ref PointerEventRef e, EventPhase phase) { if (phase == EventPhase.Bubble && e.Type == PointerEventType.Down) { step = (step + 1) % 12; InvalidateRender(); } } }