Создание анимации вращения пропеллера на Visual C#
Формулировка задачи:
Помогите пожалуйста с проблемой. Пока есть только код вращения линии. Можите предложить идеи или решения по реализации проекта?
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace Пропеллер { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int angle = 0; private void Form1_Paint(object sender, PrintEventArgs e) { PointF ptCenter = new PointF(this.ClientRectangle.Width / 2, this.ClientRectangle.Height / 2); float rad = Math.Min(ptCenter.X, ptCenter.Y) / 1.1f; GraphicsPath myCrPath = new GraphicsPath(); myCrPath.AddLine(ptCenter.X, ptCenter.Y - rad, ptCenter.X, ptCenter.Y); PointF myPtf = new PointF(ptCenter.X, ptCenter.Y); Matrix myMatr = new Matrix(1, 0, 0, 1, 1, 1); myMatr.RotateAt(angle, myPtf); myCrPath.Transform(myMatr); myMatr.Dispose(); using (Pen myPen = new Pen(Color.Black, 3)) { e.Graphics.DrawPath(myPen, myCrPath); } myCrPath.Dispose(); angle += 6; if (angle == 360) angle = 0; using (Pen myPen = new Pen(Color.Blue, 2)) { e.Graghies.DrawEllipse(myPen, ptCenter.X - rad, ptCenter.Y - rad, 2 * rad, 2 * rad); } } private void timer1_Tick(object sender, EventArgs e) { Invalidate(); } } }
Решение задачи: «Создание анимации вращения пропеллера на Visual C#»
textual
Листинг программы
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace Rotabe_Lines { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int angle = 0; private void Form1_Paint(object sender, PaintEventArgs e) { PointF ptCenter = new PointF(this.ClientRectangle.Width / 2, this.ClientRectangle.Height / 2 ); float rad = Math.Min(ptCenter.X, ptCenter.Y)/4.1f; GraphicsPath myCrPath = new GraphicsPath(); myCrPath.AddEllipse(38, 150, 121, 20); PointF myPtf = new PointF(ptCenter.X, ptCenter.Y); Matrix myMatr = new Matrix(1, 0, 0, 1, 1, 1); myMatr.RotateAt(angle, myPtf); myCrPath.Transform(myMatr); myMatr.Dispose(); using (Pen myPen = new Pen(Color.Black, 3)) { e.Graphics.DrawPath(myPen, myCrPath); } using (Pen myPen = new Pen(Color.Blue, 2)) { e.Graphics.DrawEllipse(myPen, ptCenter.X - rad, ptCenter.Y - rad, 2 * rad, 2 * rad); } myCrPath.Dispose(); angle += 1; if (angle == 360) angle = 0; } private void timer1_Tick(object sender, EventArgs e) { Invalidate(); } } }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д