Язык программирования:
C#
Среда программирования:
Microsoft Visual Studio 2017 Community
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 demoscene1 { public partial class Form1 : Form { private Bitmap bitmap; //инициализируем битмап private Graphics graphix; //инициализируем графику SolidBrush background = new SolidBrush(Color.MediumPurple); //задаем цвет фона SolidBrush circles = new SolidBrush(Color.White); //задаем цвет кружков float step; //шаг анимации float angle; //угол вращения float x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9; //координаты кружков public Form1() { InitializeComponent(); } private void CirclesLoading() { bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); graphix = Graphics.FromImage(bitmap); graphix.FillRectangle(background, 0, 0, pictureBox1.Width, pictureBox1.Height); //закрашиваем фон graphix.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //сглаживание graphix.TranslateTransform((float)pictureBox1.Width / 2, (float)pictureBox1.Height / 2); //перемещаем координаты в центр pictureBox1.BackgroundImage = bitmap; //здесь будет отображаться анимация } private void Form1_Load(object sender, EventArgs e) { timer1.Start(); //начало работы анимации } private void timer1_Tick(object sender, EventArgs e) { CirclesLoading(); //загружаем функцию с битмэпом, графикой и отображением анимации step++; //количество шагов анимации будет постепенно увеличиваться на шаг angle += (float)0.02262; //изменяем приращение угла if (step >= 0) { // внешний слой // center distance way of running x1 = -30 + (float)(180 * (float)Math.Sin(0.2 + angle)); //описываем положение кругов y1 = -30 + (float)(180 * (float)Math.Cos(0.2 + angle)); x2 = -30 + (float)(180 * (float)Math.Sin(-0.5 + angle)); y2 = -30 + (float)(180 * (float)Math.Cos(-0.5 + angle)); x3 = -30 + (float)(180 * (float)Math.Sin(-1.2 + angle)); //описываем положение кругов y3 = -30 + (float)(180 * (float)Math.Cos(-1.2 + angle)); x4 = -30 + (float)(180 * (float)Math.Sin(-1.9 + angle)); y4 = -30 + (float)(180 * (float)Math.Cos(-1.9 + angle)); x5 = -30 + (float)(180 * (float)Math.Sin(-2.6 + angle)); //описываем положение кругов y5 = -30 + (float)(180 * (float)Math.Cos(-2.6 + angle)); x6 = -30 + (float)(180 * (float)Math.Sin(-3.3 + angle)); y6 = -30 + (float)(180 * (float)Math.Cos(-3.3 + angle)); x7 = -30 + (float)(180 * (float)Math.Sin(-4.0 + angle)); //описываем положение кругов y7 = -30 + (float)(180 * (float)Math.Cos(-4.0 + angle)); x8 = -30 + (float)(180 * (float)Math.Sin(-4.7 + angle)); y8 = -30 + (float)(180 * (float)Math.Cos(-4.7 + angle)); x9 = -30 + (float)(180 * (float)Math.Sin(-5.4 + angle)); y9 = -30 + (float)(180 * (float)Math.Cos(-5.4 + angle)); graphix.FillEllipse(circles, x1, y1, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x2, y2, 50, 50); graphix.FillEllipse(circles, x3, y3, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x4, y4, 50, 50); graphix.FillEllipse(circles, x5, y5, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x6, y6, 50, 50); graphix.FillEllipse(circles, x7, y7, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x8, y8, 50, 50); graphix.FillEllipse(circles, x9, y9, 50, 50); // средний слой x1 = -30 + (float)(120 * (float)Math.Sin(0.2 - angle)); //описываем положение кругов y1 = -30 + (float)(120 * (float)Math.Cos(0.2 - angle)); x2 = -30 + (float)(120 * (float)Math.Sin(-0.5 - angle)); y2 = -30 + (float)(120 * (float)Math.Cos(-0.5 - angle)); x3 = -30 + (float)(120 * (float)Math.Sin(-1.2 - angle)); //описываем положение кругов y3 = -30 + (float)(120 * (float)Math.Cos(-1.2 - angle )); x4 = -30 + (float)(120 * (float)Math.Sin(-1.9 - angle )); y4 = -30 + (float)(120 * (float)Math.Cos(-1.9 - angle )); x5 = -30 + (float)(120 * (float)Math.Sin(-2.6 - angle )); //описываем положение кругов y5 = -30 + (float)(120 * (float)Math.Cos(-2.6 - angle )); x6 = -30 + (float)(120 * (float)Math.Sin(-3.3 - angle )); y6 = -30 + (float)(120 * (float)Math.Cos(-3.3 - angle )); x7 = -30 + (float)(120 * (float)Math.Sin(-4.0 - angle)); //описываем положение кругов y7 = -30 + (float)(120 * (float)Math.Cos(-4.0 - angle)); x8 = -30 + (float)(120 * (float)Math.Sin(-4.7 - angle)); y8 = -30 + (float)(120 * (float)Math.Cos(-4.7 - angle)); x9 = -30 + (float)(120 * (float)Math.Sin(-5.4 - angle)); y9 = -30 + (float)(120 * (float)Math.Cos(-5.4 - angle)); graphix.FillEllipse(circles, x1, y1, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x2, y2, 50, 50); graphix.FillEllipse(circles, x3, y3, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x4, y4, 50, 50); graphix.FillEllipse(circles, x5, y5, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x6, y6, 50, 50); graphix.FillEllipse(circles, x7, y7, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x8, y8, 50, 50); graphix.FillEllipse(circles, x9, y9, 50, 50); // внутренний слой x1 = -30 + (float)(50 * (float)Math.Sin(0.2 + angle )); //описываем положение кругов y1 = -30 + (float)(50 * (float)Math.Cos(0.2 + angle )); x2 = -30 + (float)(50 * (float)Math.Sin(-0.5 + angle )); y2 = -30 + (float)(50 * (float)Math.Cos(-0.5 + angle )); x3 = -30 + (float)(50 * (float)Math.Sin(-1.2 + angle )); //описываем положение кругов y3 = -30 + (float)(50 * (float)Math.Cos(-1.2 + angle )); x4 = -30 + (float)(50 * (float)Math.Sin(-1.9 + angle )); y4 = -30 + (float)(50 * (float)Math.Cos(-1.9 + angle )); x5 = -30 + (float)(50 * (float)Math.Sin(-2.6 + angle)); //описываем положение кругов y5 = -30 + (float)(50 * (float)Math.Cos(-2.6 + angle )); x6 = -30 + (float)(50 * (float)Math.Sin(-3.3 + angle )); y6 = -30 + (float)(50 * (float)Math.Cos(-3.3 + angle )); x7 = -30 + (float)(50 * (float)Math.Sin(-4.0 + angle )); //описываем положение кругов y7 = -30 + (float)(50 * (float)Math.Cos(-4.0 + angle )); x8 = -30 + (float)(50 * (float)Math.Sin(-4.7 + angle )); y8 = -30 + (float)(50 * (float)Math.Cos(-4.7 + angle )); x9 = -30 + (float)(50 * (float)Math.Sin(-5.4 + angle )); y9 = -30 + (float)(50 * (float)Math.Cos(-5.4 + angle )); graphix.FillEllipse(circles, x1, y1, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x2, y2, 50, 50); graphix.FillEllipse(circles, x3, y3, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x4, y4, 50, 50); graphix.FillEllipse(circles, x5, y5, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x6, y6, 50, 50); graphix.FillEllipse(circles, x7, y7, 50, 50); //закрашиваем круги graphix.FillEllipse(circles, x8, y8, 50, 50); graphix.FillEllipse(circles, x9, y9, 50, 50); } } } }
Прикрепленный файл | Размер |
---|---|
suzdal_demoscene2.rar | 178.74 кб |