Язык программирования:
C#
Среда программирования:
Microsoft Visual Studio Community C#
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication6 { public partial class Form1 : Form { private Bitmap b;//создаём bitmap и графику private Graphics g; SolidBrush bl = new SolidBrush(Color.Black);//определяем цвета кругов SolidBrush wh = new SolidBrush(Color.White); float x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;//объявляем координаты-переменные float angle1 = 0; int cnt1; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { timer1.Start(); } private void Draw() { b = new Bitmap(pictureBox1.Width, pictureBox1.Height);//создаём графику из bitmap Graphics g = Graphics.FromImage(b); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;//для сглаживания g.TranslateTransform((float)pictureBox1.Width / 2, (float)pictureBox1.Height / 2);//смещаем координатную сетку в центр g.FillEllipse(bl, -200, -200, 400, 400); x1 = -100 + (float)(-100 * (float)Math.Cos(0.01 + angle1));//вращаем круг по траектории окружности y1 = -100 + (float)(-100 * (float)Math.Sin(0.01 + angle1)); x2 = -50 + (float)(2 * -50 * (float)Math.Cos(0.01 + angle1)) - (float)(-50 * (float)Math.Cos(2 * (0.01 + angle1)));//вращаем круги по траектории кардиоиды y2 = -50 + (float)(2 * -50 * (float)Math.Sin(0.01 + angle1)) - (float)(-50 * (float)Math.Sin(2 * (0.01 + angle1))); x3 = -25 + (float)(2 * -50 * (float)Math.Cos(0.01 + angle1)) - (float)(-25* (float)Math.Cos(2 * (0.01 + angle1))); y3 = -25 + (float)(2 * -50 * (float)Math.Sin(0.01 + angle1)) - (float)(-25 * (float)Math.Sin(2 * (0.01 + angle1))); x4 = -13 + (float)(2 * -50 * (float)Math.Cos(0.01 + angle1)) - (float)(-13 * (float)Math.Cos(2 * (0.01 + angle1))); y4 = -13 + (float)(2 * -50 * (float)Math.Sin(0.01 + angle1)) - (float)(-13 * (float)Math.Sin(2 * (0.01 + angle1))); x5 = -6 + (float)(2 * -50 * (float)Math.Cos(0.01 + angle1)) - (float)(-6 * (float)Math.Cos(2 * (0.01 + angle1))); y5 = -6 + (float)(2 * -50 * (float)Math.Sin(0.01 + angle1)) - (float)(-6 * (float)Math.Sin(2 * (0.01 + angle1))); x6 = -3 + (float)(2 * -50 * (float)Math.Cos(0.01 + angle1)) - (float)(-3 * (float)Math.Cos(2 * (0.01 + angle1))); y6 = -3 + (float)(2 * -50 * (float)Math.Sin(0.01 + angle1)) - (float)(-3 * (float)Math.Sin(2 * (0.01 + angle1))); g.FillEllipse(wh, x1, y1, 200, 200);//отрисовываем круги g.FillEllipse(bl, x2, y2, 100, 100); g.FillEllipse(wh, x3, y3, 50, 50); g.FillEllipse(bl, x4, y4, 25, 25); g.FillEllipse(wh, x5, y5, 13, 13); g.FillEllipse(bl, x6, y6, 6, 6); pictureBox1.BackgroundImage = b; } private void timer1_Tick(object sender, EventArgs e) { angle1 -= (float)0.01;//изменяем приращение угла cnt1++;//увеличиваем переменную количества if (cnt1 == 1550) { angle1 = 0; cnt1 = 0; }//когда таймер пройдет определенное количество циклов, все обнуляем Draw();//вызываем функцию прорисовки pictureBox1.BackgroundImage = b; } } }
Прикрепленный файл | Размер |
---|---|
Cardio-hypnotize_Sidelev.zip | 49.4 кб |