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 WindowsFormsApp2
{
public partial class Form1: Form
{
private void Form1_Load(object sender, EventArgs e)
{
}
int count = 0;
Random r = new Random(1);
int[] ar;
public Form1()
{
InitializeComponent();
this.DoubleBuffered = true;
this.BackColor = Color.FromArgb(240, 235, 220);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
this.Text = count++.ToString();
Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
int squareSize = 200;
int x = (this.ClientSize.Width - squareSize) / 2;
int y = (this.ClientSize.Height - squareSize) / 2;
// Чёрный квадрат
using (SolidBrush blackBrush = new SolidBrush(Color.Black))
{
g.FillRectangle(blackBrush, x, y, squareSize, squareSize);
}
// Состаренная рамка (цвет старой охры с лёгкой прозрачностью)
using (Pen agedPen = new Pen(Color.FromArgb(180, 160, 110, 70), 3))
{
g.DrawRectangle(agedPen, x, y, squareSize, squareSize);
}
// Добавляем "кракелюры" — мелкие трещинки по краям (эффект старения)
using (Pen crackPen = new Pen(Color.FromArgb(100, 90, 60, 40), 1))
{
for (int i = 0; i < 12; i++)
{
int offsetX = r.Next(-8, 8);
int offsetY = r.Next(-8, 8);
// небольшие штрихи вокруг квадрата
g.DrawLine(crackPen,
x + offsetX, y + i * 18,
x + offsetX - 5, y + i * 18 + 10);
g.DrawLine(crackPen,
x + squareSize + offsetX, y + i * 18,
x + squareSize + offsetX + 5, y + i * 18 + 10);
}
}
// Лёгкий эффект "выцветшей" рамки поверх квадрата
using (Pen fadedPen = new Pen(Color.FromArgb(80, 200, 185, 150), 2))
{
g.DrawRectangle(fadedPen, x - 1, y - 1, squareSize + 2, squareSize + 2);
}
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
this.Invalidate();
}
}
}