/// <summary>
/// 塔 长臂的长度
/// </summary>
private double towerLong = 200;
/// <summary>
/// 小车短臂的距离
/// </summary>
private double towerShort = 30;
/// <summary>
/// 当前的塔吊的回传角度
/// </summary>
private double returnAngle=30;
/// <summary>
/// 指针也就是塔臂的颜色
/// </summary>
private Color towerColor = Color.Black;
/// <summary>
/// 小车远端距离
/// </summary>
private double remoteL = 150;
/// <summary>
/// 小车近端距离
/// </summary>
private double nearL = 50;
/// <summary>
/// 当前的塔吊的顶点位置
/// </summary>
private Point towerPoint;
/// <summary>
/// 长臂坐标
/// </summary>
private Point longPoint;
/// <summary>
/// 短臂坐标
/// </summary>
private Point shortPoint;
/// <summary>
/// 小车坐标
/// </summary>
private Point carPoint; /// <summary>
/// 绘图
/// </summary>
/// <param name="g">图形设备接口</param>
/// <param name="circleCenter">圆心坐标</param>
/// <param name="radius">半径</param>
/// <param name="carPosition">车中心</param>
private void DrawPic(Graphics g, Point circleCenter, int radius, Point carPosition)
{
int r = 3;
//填充圆圈 塔吊
g.FillEllipse(new SolidBrush(Color.LightGreen), circleCenter.X - radius, circleCenter.Y - radius, radius * 2, radius * 2);
//填充圆心
g.FillRectangle(new SolidBrush(Color.White), circleCenter.X - r, circleCenter.Y - r, r * 2, r * 2);
//填充边框
g.DrawRectangle(new Pen(Color.Orange), circleCenter.X - r, circleCenter.Y - r, r * 2, r * 2);
//填充小车
g.FillEllipse(new SolidBrush(Color.Black), carPosition.X - r, carPosition.Y - r, r * 2, r * 2);
//填充指针
g.DrawLine(new Pen(Color.Black, 2), circleCenter, carPosition);
}
private void timer1_Tick(object sender, EventArgs e)
{
returnAngle++;
towerLong = 200;
towerShort = 100;
double nearX = nearL * Math.Sin(DegToRad(returnAngle));
double nearY = nearL * Math.Cos(DegToRad(returnAngle));
double longX = towerLong * Math.Sin(DegToRad(returnAngle));
double longY = towerLong * Math.Cos(DegToRad(returnAngle));
towerPoint = new Point(x, y);
carPoint = new Point((int)(longX + x), (int)(nearY));
longPoint = new Point((int)(longX + x), (int)(longY)); Bitmap bmp = new Bitmap(800, 800);
using (Graphics g = Graphics.FromImage(bmp))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//g.FillEllipse(new SolidBrush(Color.Blue), 50, 50, 100, 100);
DrawPic(g, towerPoint, x, carPoint);
}
Graphics g2 = this.CreateGraphics();
g2.DrawImage(bmp, 0, 0);
}这角度变化,为什么指针不会懂,具体实现效果你可以看 http://zhidao.baidu.com/question/305892891.html
/// 塔 长臂的长度
/// </summary>
private double towerLong = 200;
/// <summary>
/// 小车短臂的距离
/// </summary>
private double towerShort = 30;
/// <summary>
/// 当前的塔吊的回传角度
/// </summary>
private double returnAngle=30;
/// <summary>
/// 指针也就是塔臂的颜色
/// </summary>
private Color towerColor = Color.Black;
/// <summary>
/// 小车远端距离
/// </summary>
private double remoteL = 150;
/// <summary>
/// 小车近端距离
/// </summary>
private double nearL = 50;
/// <summary>
/// 当前的塔吊的顶点位置
/// </summary>
private Point towerPoint;
/// <summary>
/// 长臂坐标
/// </summary>
private Point longPoint;
/// <summary>
/// 短臂坐标
/// </summary>
private Point shortPoint;
/// <summary>
/// 小车坐标
/// </summary>
private Point carPoint; /// <summary>
/// 绘图
/// </summary>
/// <param name="g">图形设备接口</param>
/// <param name="circleCenter">圆心坐标</param>
/// <param name="radius">半径</param>
/// <param name="carPosition">车中心</param>
private void DrawPic(Graphics g, Point circleCenter, int radius, Point carPosition)
{
int r = 3;
//填充圆圈 塔吊
g.FillEllipse(new SolidBrush(Color.LightGreen), circleCenter.X - radius, circleCenter.Y - radius, radius * 2, radius * 2);
//填充圆心
g.FillRectangle(new SolidBrush(Color.White), circleCenter.X - r, circleCenter.Y - r, r * 2, r * 2);
//填充边框
g.DrawRectangle(new Pen(Color.Orange), circleCenter.X - r, circleCenter.Y - r, r * 2, r * 2);
//填充小车
g.FillEllipse(new SolidBrush(Color.Black), carPosition.X - r, carPosition.Y - r, r * 2, r * 2);
//填充指针
g.DrawLine(new Pen(Color.Black, 2), circleCenter, carPosition);
}
private void timer1_Tick(object sender, EventArgs e)
{
returnAngle++;
towerLong = 200;
towerShort = 100;
double nearX = nearL * Math.Sin(DegToRad(returnAngle));
double nearY = nearL * Math.Cos(DegToRad(returnAngle));
double longX = towerLong * Math.Sin(DegToRad(returnAngle));
double longY = towerLong * Math.Cos(DegToRad(returnAngle));
towerPoint = new Point(x, y);
carPoint = new Point((int)(longX + x), (int)(nearY));
longPoint = new Point((int)(longX + x), (int)(longY)); Bitmap bmp = new Bitmap(800, 800);
using (Graphics g = Graphics.FromImage(bmp))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//g.FillEllipse(new SolidBrush(Color.Blue), 50, 50, 100, 100);
DrawPic(g, towerPoint, x, carPoint);
}
Graphics g2 = this.CreateGraphics();
g2.DrawImage(bmp, 0, 0);
}这角度变化,为什么指针不会懂,具体实现效果你可以看 http://zhidao.baidu.com/question/305892891.html
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货