public void DrawCircle(Renderer renderer, Vector2 center, float radius, float step, double a, double b, ref D2D1.PathGeometry outline, int col, float txt) { D2D1.PathGeometry path = new D2D1.PathGeometry(renderer.D2DFactory); D2D1.GeometrySink s = path.Open(); s.SetFillMode(D2D1.FillMode.Winding); s.BeginFigure(center + new Vector2((float)Math.Cos(a) * radius, (float)Math.Sin(a) * radius), D2D1.FigureBegin.Filled); for (double i = a; i <= b; i += Math.PI * .05) { s.AddLine(center + new Vector2((float)Math.Cos(i) * radius, (float)Math.Sin(i) * radius)); } s.AddLine(center + new Vector2((float)Math.Cos(b) * radius, (float)Math.Sin(b) * radius)); s.AddLine(center); s.EndFigure(D2D1.FigureEnd.Closed); s.Close(); s.Dispose(); renderer.D2DContext.FillGeometry(path, renderer.Brushes[Colors[col % Colors.Length]]); if (path.FillContainsPoint(Input.MousePos, 1)) { if (txt == 0) { txt = radius + 50; } RawRectangleF r = new RawRectangleF(center.X - 100, center.Y - txt, center.X + 100, center.Y - txt + 16); renderer.D2DContext.FillRectangle(r, renderer.Brushes["TransparentBlack"]); renderer.Consolas14.TextAlignment = DWrite.TextAlignment.Leading; renderer.D2DContext.DrawText( Name + " (" + Stopwatch.Elapsed.TotalMilliseconds.ToString("F1") + "ms)", renderer.Consolas14, r, renderer.Brushes[Colors[col % Colors.Length]], D2D1.DrawTextOptions.None, D2D1.MeasuringMode.GdiNatural); txt += 16; outline = path; } else { path.Dispose(); } double t = 0; foreach (Profiler p in Children) { col++; //if (p.ParentTickOffset > 0) // t += (p.ParentTickOffset / (double)Stopwatch.Elapsed.Ticks) * (b - a); double f = (p.Stopwatch.Elapsed.Ticks / (double)Stopwatch.Elapsed.Ticks) * (b - a); p.DrawCircle(renderer, center, radius - step, step, a + t, a + t + f, ref outline, col, txt); t += f; } }
public bool Contains(ref Point point) { var p = point.ToD2D(); return(_path.FillContainsPoint(p) || _path.StrokeContainsPoint(p, 1)); }