можно
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace PulsatingCircleApp
{
public partial class MainForm : Form
{
private System.Windows.Forms.Timer timer;
private int diameter;
private int minDiameter = 50;
private int maxDiameter = 100;
private bool increasing = true;
public MainForm()
{
InitializeComponent();
this.DoubleBuffered = true;
this.diameter = minDiameter;
timer = new System.Windows.Forms.Timer();
timer.Interval = 1000; // 1 секунда
timer.Tick += Timer_Tick;
timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
if (increasing)
{
diameter += 10;
if (diameter >= maxDiameter)
{
increasing = false;
}
}
else
{
diameter -= 10;
if (diameter <= minDiameter)
{
increasing = true;
}
}
this.Invalidate(); // Запрашивает перерисовку формы
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int x = (this.ClientSize.Width - diameter) / 2;
int y = (this.ClientSize.Height - diameter) / 2;
DrawHeart(e.Graphics, x, y, diameter, diameter);
}
private void DrawHeart(Graphics g, int x, int y, int width, int height)
{
GraphicsPath path = new GraphicsPath();
path.AddBezier(x + width / 2, y, x + width, y, x + width, y + height / 2, x + width / 2, y + height);
path.AddBezier(x + width / 2, y + height, x, y + height / 2, x, y, x + width / 2, y);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillPath(Brushes.Red, path);
}
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics ;
g.FillEllipse(new SolidBrush( Color.Red ), 300, 100, 100, 100);
g.FillEllipse(new SolidBrush( Color.Red ), 375, 100, 100, 100);
Point heartPoint1 = new Point(306, 175);
Point heartPoint2 = new Point(469, 175);
Point heartPoint3 = new Point(387, 255);
Point[] heartPoints = { heartPoint1, heartPoint2, heartPoint3 };
g.FillPolygon(new SolidBrush( Color.Red ), heartPoints);
}
private void timer1_Tick(object sender, EventArgs e)
{
}