diff --git a/Fractal/FlowerFractal.sln b/Fractal/FlowerFractal.sln new file mode 100644 index 0000000..37aa738 --- /dev/null +++ b/Fractal/FlowerFractal.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fractal", "Fractal\Fractal.csproj", "{32A99F54-C8B1-41C9-AE3D-DA28227A9FF9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {32A99F54-C8B1-41C9-AE3D-DA28227A9FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32A99F54-C8B1-41C9-AE3D-DA28227A9FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32A99F54-C8B1-41C9-AE3D-DA28227A9FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32A99F54-C8B1-41C9-AE3D-DA28227A9FF9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Fractal/Fractal/Form1.Designer.cs b/Fractal/Fractal/Form1.Designer.cs new file mode 100644 index 0000000..a22e068 --- /dev/null +++ b/Fractal/Fractal/Form1.Designer.cs @@ -0,0 +1,45 @@ +namespace Fractal +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 600); + this.Name = "Form1"; + this.Text = "Flower Fractal"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + } + #endregion + } +} \ No newline at end of file diff --git a/Fractal/Fractal/Form1.cs b/Fractal/Fractal/Form1.cs new file mode 100644 index 0000000..d3eb1a0 --- /dev/null +++ b/Fractal/Fractal/Form1.cs @@ -0,0 +1,93 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace Fractal +{ + public partial class Form1 : Form + { + private int recursionDepth = 6; + private double sizeRatio = 0.4; + + public Form1() + { + InitializeComponent(); + this.Text = "Flower Fractal"; + this.Size = new Size(800, 600); + this.DoubleBuffered = true; // + } + + private void Form1_Load(object sender, EventArgs e) + { + // + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + + // + PointF center = new PointF(this.ClientSize.Width / 2, this.ClientSize.Height / 2); + float initialRadius = Math.Min(this.ClientSize.Width, this.ClientSize.Height) * 0.3f; + + DrawFlowerFractal(e.Graphics, center, initialRadius, recursionDepth); + } + + private void DrawFlowerFractal(Graphics g, PointF center, float radius, int depth) + { + if (depth <= 0 || radius < 1) + return; + + // + DrawCircle(g, center, radius, depth); + + int childCount = 6; + for (int i = 0; i < childCount; i++) + { + double angle = 2 * Math.PI * i / childCount; + float distance = radius * 0.8f; + float childX = center.X + distance * (float)Math.Cos(angle); + float childY = center.Y + distance * (float)Math.Sin(angle); + float childRadius = radius * (float)sizeRatio; + + DrawFlowerFractal(g, new PointF(childX, childY), childRadius, depth - 1); + } + + if (depth >= 3) + { + float innerRadius = radius * 0.5f; + DrawFlowerFractal(g, center, innerRadius, depth - 2); + } + } + + private void DrawCircle(Graphics g, PointF center, float radius, int depth) + { + Color circleColor = GetColorByDepth(depth); + + using (Pen pen = new Pen(circleColor, 1.5f)) + { + g.DrawEllipse(pen, center.X - radius, center.Y - radius, + radius * 2, radius * 2); + } + + if (radius > 20) + { + using (Brush brush = new SolidBrush(Color.FromArgb(30, circleColor))) + { + g.FillEllipse(brush, center.X - radius, center.Y - radius, + radius * 2, radius * 2); + } + } + } + + private Color GetColorByDepth(int depth) + { + int red = Math.Min(255, 200 + depth * 5); + int green = Math.Min(255, 100 - depth * 10); + int blue = Math.Min(255, 50 + depth * 15); + + return Color.FromArgb(red, green, blue); + } + } +} \ No newline at end of file diff --git a/Fractal/Fractal/Form1.resx b/Fractal/Fractal/Form1.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/Fractal/Fractal/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Fractal/Fractal/Fractal.csproj b/Fractal/Fractal/Fractal.csproj new file mode 100644 index 0000000..eaa3b1a --- /dev/null +++ b/Fractal/Fractal/Fractal.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net8.0-windows + true + enable + enable + + + \ No newline at end of file diff --git a/Fractal/Fractal/Program.cs b/Fractal/Fractal/Program.cs new file mode 100644 index 0000000..50671eb --- /dev/null +++ b/Fractal/Fractal/Program.cs @@ -0,0 +1,17 @@ +using Fractal; +using System; +using System.Windows.Forms; + +namespace FlowerFractal +{ + internal static class Program + { + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/text.txt b/text.txt index 3bd151e..73b7424 100644 --- a/text.txt +++ b/text.txt @@ -1 +1 @@ -Айдар не лох \ No newline at end of file +тут ничего не было \ No newline at end of file