C#怎么实现画布的旋转
发布网友
发布时间:2022-08-17 23:08
我来回答
共1个回答
热心网友
时间:2023-10-14 13:04
/// <summary>
/// 绘画时针,计算旋转的角度
/// </summary>
/// <param name="grfx"></param>
/// <param name="pn"></param>
protected void DrawHourHand(Graphics dc, Pen pn)
{
GraphicsState gs = dc.Save();
pn.Color = HourHandColor;//属性设置指针颜色
//绘图模式默认为粗糙模式,将会出现锯齿!
dc.SmoothingMode = SmoothingMode.AntiAlias;
dc.SmoothingMode = SmoothingMode.HighQuality;
//下句就是旋转画布。
dc.RotateTransform((float)(Time.Second * 0.01 + Time.Minute * 0.1 + Time.Hour * 30));
pn.Width = 10;
pn.EndCap = LineCap.Triangle;
dc.DrawLine(pn, 0, 20, 0, -50);//圆点一边20,另一边50
dc.Restore(gs);
}