private void PaintSurface(object sender, SKPaintSurfaceEventArgs e) { const int count = 10; //number of digits in outer circle const float r = 100f; //outer circle radius const float f = 40f; //font size in points const float thicknessAdjust = 2 * f / 3; //thickness adjust of the two circles const float θ = 360f / count; //angle to rotate when drawing each digit painter ??= new SkiaSharp.MathPainter { FontSize = f }; //{ GlyphBoxColor = (SKColors.Red, SKColors.Red) }; var cx = e.Info.Width / 2; var cy = e.Info.Height / 2; var c = e.Surface.Canvas; //draw outer circle c.DrawCircle(cx, cy, r + thicknessAdjust, black); painter.TextColor = SKColors.White; for (int i = 0; i < count; i++) { painter.LaTeX = i.ToString(); var m = painter.Measure().Value; painter.Draw(c, cx - m.Width / 2, cy - r - m.Y / 2); c.RotateDegrees(θ, cx, cy); } //draw inner circle c.DrawCircle(cx, cy, r - thicknessAdjust, white); painter.TextColor = SKColors.Black; painter.LaTeX = @"\raisebox{25mu}{\text{\kern.7222emC\#}\\Math}"; //.7222em is 13/18em painter.Draw(c); }
public static void Draw(SKCanvas c) { const int count = 10; //number of digits in outer circle const float r = 100f; //outer circle radius const float f = 40f; //font size in points const float thicknessAdjust = 2 * f / 3; //thickness adjust of the two circles const float θ = 360f / count; //angle to rotate when drawing each digit var painter = new SkiaSharp.MathPainter(); var cx = c.DeviceClipBounds.Width / 2; var cy = c.DeviceClipBounds.Height / 2; painter.FontSize = f; //{ GlyphBoxColor = (SKColors.Red, SKColors.Red) }; //draw outer circle using (var black = new SKPaint { Color = SKColors.Black, IsAntialias = true }) c.DrawCircle(cx, cy, r + thicknessAdjust, black); painter.TextColor = SKColors.White; for (int i = 0; i < count; i++) { painter.LaTeX = i.ToString(); var m = painter.Measure() ?? throw new Structures.InvalidCodePathException("Invalid LaTeX"); painter.Draw(c, cx - m.Width / 2, cy + m.Height / 2 - r); c.RotateDegrees(θ, cx, cy); } //draw inner circle using (var white = new SKPaint { Color = SKColors.White, IsAntialias = true }) c.DrawCircle(cx, cy, r - thicknessAdjust, white); painter.TextColor = SKColors.Black; painter.LaTeX = @"\ \raisebox{25mu}{\begin{gather}C\#\\Math\end{gather}}\ "; painter.Draw(c); }