-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to specify a certain point of the equation bounding box as a reference point? #27
Comments
Use the Measure property of a MathPainter or TextPainter. |
Change these two lines to make the displayed formulae shorter, - @"$4\times4-4-4$",
- @"$4+4+\frac{4}{4}$",
+ @"$\sqrt{4}\times4$",
+ @"$\:\:(4-\frac{4}{4})^{\sqrt{4}}$", and change these lines to draw the formulae at the centre. (DrawOneLine's coordinates are at the baseline - like in penmanship, while Draw's coordinates are at the corner) - painter.DrawOneLine(canvas, (float)(80 * Cos((90 - 6 * i) / 180f * PI)), (float)(-80 * Sin((90 - 6 * i) / 180f * PI)));
+ var measure = painter.Measure(width).Value;
+ var θ = (90 - 6 * i) / 180f * PI;
+ var sinθ = (float)Sin(θ);
+ var cosθ = (float)Cos(θ);
+ painter.Draw(canvas, new System.Drawing.PointF((75) * cosθ - measure.Width / 2, (-75) * sinθ - measure.Height / 2), float.PositiveInfinity); |
P.S. Use ```cs instead of ``` to start a C# code block since it will also provide syntax highlighting. I fixed it for you. |
For a MathPainter (which is better to use here) the height adjustment would be |
Thank you very much for answering. No problem for reusing this code. By the way, the code was "retyped" (but not exactly the same) from Charles Petzold's webinar about SkiaSharp. |
I am making a crazy analog clock as follows.
The problem is that I have not control to specify a certain point on the equation bounding box as a reference point at which I position the equation with
DrawOneLine
method.Here is my code:
The text was updated successfully, but these errors were encountered: