Язык программирования:
C#
Среда программирования:
Microsoft Visual Studio 2015
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 WindowsFormsApplication1 { public partial class Form1 : Form { private Bitmap bitmap; //инициализируем битмэп private Graphics graphix; //инициализируем графику SolidBrush bg = new SolidBrush(Color.FromArgb(255, 225, 255)); //цвет фона SolidBrush E2 = new SolidBrush(Color.FromArgb(28 ,28 ,28)); //цвет кружков Pen E1 = new Pen(Color.FromArgb(85 ,26 ,139), 5); int r; //радиус кружков int cnt; //счетчик float angle; //угол float x1, y1, x2, y2, x3, y3, x4, y4; //координаты кружков public Form1() { InitializeComponent(); } private void FillEllipse() { bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); //создаём графику из bitmap graphix = Graphics.FromImage(bitmap); graphix.FillRectangle(bg, 0, 0, pictureBox1.Width, pictureBox1.Height); //закрашиваем фон graphix.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //сглаживание graphix.TranslateTransform((float)pictureBox1.Width / 2, (float)pictureBox1.Height / 2); //перемещаем координаты в центр graphix.DrawEllipse(E1, -200 - r, -200 - r, 50 + r * 2, 50 + r * 2); //рисуем кружки graphix.FillEllipse(E2, -200, -200, 50, 50); graphix.DrawEllipse(E1, 150 - r, 150 - r, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, 150, 150, 50, 50); graphix.DrawEllipse(E1, -200 - r, 150 - r, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, -200, 150, 50, 50); graphix.DrawEllipse(E1, 150 - r, -200 - r, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, 150, -200, 50, 50); graphix.DrawEllipse(E1, -25 - r, -25 - r, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, -25, -25, 50, 50); graphix.DrawEllipse(E1, -25 - r - x1, 50 - r - y1, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, -25 - x1, 50 - y1, 50, 50); graphix.DrawEllipse(E1, -25 - r - x2, 50 - r - y2, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, -25 - x2, 50 - y2, 50, 50); graphix.DrawEllipse(E1, -25 - r - x3, 50 - r - y3, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, -25 - x3, 50 - y3, 50, 50); graphix.DrawEllipse(E1, -25 - r - x4, 50 - r - y4, 50 + r * 2, 50 + r * 2); graphix.FillEllipse(E2, -25 - x4, 50 - y4, 50, 50); pictureBox1.BackgroundImage = bitmap; //отображаем битмап на pictureBox } private void timer1_Tick(object sender, EventArgs e) { cnt++; //увеличиваем счетчик angle += (float)0.03; //увеличиваем угол x1 = (float)(90 * (float)Math.Sin(300 + angle)); //описываем положение кругов y1 = 85 + (float)(190 * (float)Math.Cos(300 + angle)); x2 = (float)(190 * (float)Math.Sin(-300 + angle)); y2 = 85 + (float)(90 * (float)Math.Cos(-300 + angle)); x3 = (float)(190 * (float)Math.Sin(300 + angle)); y3 = 85 + (float)(90 * (float)Math.Cos(300 + angle)); x4 = (float)(90 * (float)Math.Sin(-300 + angle)); y4 = 85 + (float)(190 * (float)Math.Cos(-300 + angle)); FillEllipse(); if (cnt < 30) //если счетчик меньше 30-ти увеличиваем радиус кружков { r++; } if (cnt > 30) //если счетчик больше 30-ти уменьшаем радиус кружков { r--; } if(cnt == 60) //как только счетчик становится равным 60-ти обнуляем радиус и сам счетчик { cnt = 0; r = 0; } } } }