画圆线以与圆周围的文字配合

编程入门 行业动态 更新时间:2024-10-28 18:31:13
本文介绍了画圆线以与圆周围的文字配合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我找到了一段代码,可以在一个圆圈(即时钟或指南针)周围绘制文本,现在我需要绘制与其相伴的圆圈. 这是代码段...

I found a piece of code that draws text around a circle (i.e. clock or a compass), now I need to draw the circle that goes with it. Here is the code snippet...

private void SetScale(Graphics g) { g.TranslateTransform(Width/2, Height/2); float inches = Math.Min(Width / g.DpiX, Height / g.DpiX); g.ScaleTransform(inches * g.DpiX / 2000, inches * g.DpiY / 2000); } private void DrawFace(Graphics g) { Brush brush = new SolidBrush(ForeColor); Font font = new Font("Arial", 40); float x, y; const int numHours = 12; const int deg = 360 / numHours; const int FaceRadius = 450; for (int i = 1; i <= numHours; i++) { x = GetCos(i*deg + 90) * FaceRadius; y = GetSin(i*deg + 90) * FaceRadius; StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; g.DrawString( i.ToString(), font, brush, -x, -y,format); } brush.Dispose(); font.Dispose(); } private static float GetSin(float degAngle) { return (float) Math.Sin(Math.PI * degAngle / 180f); } private static float GetCos(float degAngle) { return (float) Math.Cos(Math.PI * degAngle / 180f); } }

问题是...如何使用画线或画圆来匹配圆周围的文字?感谢

Question is...how do I use drawline or draw the circle to match the text around the circle? thanks

推荐答案

,您应该使用 Graphics.DrawEllipse [ ^ ],您必须计算谁的边是圆的切线的矩形. you should use Graphics.DrawEllipse[^], you have to calculate the rectangle whos sides are tangents of the circle.

更多推荐

画圆线以与圆周围的文字配合

本文发布于:2023-11-24 03:05:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623745.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:圆周   文字   画圆线

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!