diff --git a/Calculator/Calculator.cs b/Calculator/Calculator.cs index cef31ec..1988235 100644 --- a/Calculator/Calculator.cs +++ b/Calculator/Calculator.cs @@ -18,7 +18,7 @@ public decimal Calc(decimal arg1, decimal arg2, string oper) { return _calculatorOperations[oper](arg1, arg2); } - public decimal GetNumber(string s) + private static decimal GetNumber(string s) { const NumberStyles styles = NumberStyles.AllowDecimalPoint; var provider = new CultureInfo("en-US"); diff --git a/CalculatorASP/Calculator/Calculator.cs b/CalculatorASP/Calculator/Calculator.cs new file mode 100644 index 0000000..cef31ec --- /dev/null +++ b/CalculatorASP/Calculator/Calculator.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace Calculator +{ + public class Calculator + { + private readonly Dictionary> _calculatorOperations = + new Dictionary>() + { + {"+", (a, b) => a + b }, + {"-", (a, b) => a - b }, + {"*", (a, b) => a * b }, + {"/", (a, b) => a / b } + }; + public decimal Calc(decimal arg1, decimal arg2, string oper) + { + return _calculatorOperations[oper](arg1, arg2); + } + public decimal GetNumber(string s) + { + const NumberStyles styles = NumberStyles.AllowDecimalPoint; + var provider = new CultureInfo("en-US"); + return decimal.Parse(s, styles, provider); + } + public decimal Calc(string s) + { + var str = s.Split(); + var arg1 = GetNumber(str[0]); + var arg2 = GetNumber(str[2]); + return Calc(arg1, arg2, str[1]); + } + } +} \ No newline at end of file diff --git a/CalculatorASP/Calculator/Calculator.csproj b/CalculatorASP/Calculator/Calculator.csproj new file mode 100644 index 0000000..65cb1e3 --- /dev/null +++ b/CalculatorASP/Calculator/Calculator.csproj @@ -0,0 +1,19 @@ + + + + Exe + netcoreapp3.1 + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/CalculatorASP/Calculator/Program.cs b/CalculatorASP/Calculator/Program.cs new file mode 100644 index 0000000..e6cdaab --- /dev/null +++ b/CalculatorASP/Calculator/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Diagnostics.CodeAnalysis; +namespace Calculator +{ + [ExcludeFromCodeCoverage] + internal static class Program + { + private static void Main() + { + try + { + var calculator = new Calculator(); + var str = Console.ReadLine(); + var value = calculator.Calc(str); + Console.WriteLine(value); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + } +} diff --git a/CalculatorASP/CalculatorASP.sln b/CalculatorASP/CalculatorASP.sln new file mode 100644 index 0000000..3ac663d --- /dev/null +++ b/CalculatorASP/CalculatorASP.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30523.141 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorASP", "CalculatorASP\CalculatorASP.csproj", "{11D5E5E8-8456-4A3D-9038-496437BF33D0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calculator", "..\Calculator\Calculator.csproj", "{84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ProxyF", "ProxyF\ProxyF.fsproj", "{69E6A6AB-C19A-4243-8C9C-9B9EAB919092}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {11D5E5E8-8456-4A3D-9038-496437BF33D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11D5E5E8-8456-4A3D-9038-496437BF33D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11D5E5E8-8456-4A3D-9038-496437BF33D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11D5E5E8-8456-4A3D-9038-496437BF33D0}.Release|Any CPU.Build.0 = Release|Any CPU + {84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Release|Any CPU.Build.0 = Release|Any CPU + {69E6A6AB-C19A-4243-8C9C-9B9EAB919092}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69E6A6AB-C19A-4243-8C9C-9B9EAB919092}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69E6A6AB-C19A-4243-8C9C-9B9EAB919092}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69E6A6AB-C19A-4243-8C9C-9B9EAB919092}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B882847A-B94B-491F-BB5A-5E7A7C064526} + EndGlobalSection +EndGlobal diff --git a/CalculatorASP/CalculatorASP/CalculatorASP.csproj b/CalculatorASP/CalculatorASP/CalculatorASP.csproj new file mode 100644 index 0000000..6af6ab2 --- /dev/null +++ b/CalculatorASP/CalculatorASP/CalculatorASP.csproj @@ -0,0 +1,11 @@ + + + + netcoreapp3.1 + + + + + + + diff --git a/CalculatorASP/CalculatorASP/CalculatorMiddleware.cs b/CalculatorASP/CalculatorASP/CalculatorMiddleware.cs new file mode 100644 index 0000000..9979d05 --- /dev/null +++ b/CalculatorASP/CalculatorASP/CalculatorMiddleware.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using System; +using System.Threading.Tasks; + +namespace CalculatorASP +{ + public class CalculatorMiddleware + { + private readonly RequestDelegate _next; + + public CalculatorMiddleware(RequestDelegate next) => _next = next; + + public async Task InvokeAsync(HttpContext context) + { + var value = context.Request.Query["value"]; + var calclulator = new Calculator.Calculator(); + var ans = calclulator.Calc(value); + await context.Response.WriteAsync(ans.ToString()); + await _next.Invoke(context); + } + } +} diff --git a/CalculatorASP/CalculatorASP/Program.cs b/CalculatorASP/CalculatorASP/Program.cs new file mode 100644 index 0000000..688d450 --- /dev/null +++ b/CalculatorASP/CalculatorASP/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace CalculatorASP +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/CalculatorASP/CalculatorASP/Properties/launchSettings.json b/CalculatorASP/CalculatorASP/Properties/launchSettings.json new file mode 100644 index 0000000..8567cc9 --- /dev/null +++ b/CalculatorASP/CalculatorASP/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:51963", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "CalculatorASP": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file diff --git a/CalculatorASP/CalculatorASP/Startup.cs b/CalculatorASP/CalculatorASP/Startup.cs new file mode 100644 index 0000000..811aa1e --- /dev/null +++ b/CalculatorASP/CalculatorASP/Startup.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace CalculatorASP +{ + +public class Startup + { + public Startup() + { + + } + public void Configure(IApplicationBuilder app) + { + app.UseMiddleware(); + } + } +} diff --git a/CalculatorASP/CalculatorASP/appsettings.Development.json b/CalculatorASP/CalculatorASP/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/CalculatorASP/CalculatorASP/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/CalculatorASP/CalculatorASP/appsettings.json b/CalculatorASP/CalculatorASP/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/CalculatorASP/CalculatorASP/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/CalculatorASP/ProxyF/Program.fs b/CalculatorASP/ProxyF/Program.fs new file mode 100644 index 0000000..9e84071 --- /dev/null +++ b/CalculatorASP/ProxyF/Program.fs @@ -0,0 +1,58 @@ +open System +open System.Text.RegularExpressions; +open System.Net.Http + +type AsyncMaybeBuilder () = + member this.Bind(x, f) = + async { + let! x' = x + match x' with + | Some s -> return! f s + | None -> return None + } + + member this.Return x = + async{return x} + +let asyncMaybe = new AsyncMaybeBuilder() + +let checkAccess input = + Regex.IsMatch(input, @"(-?\d+(?:\.\d+)?)\s*([-]?[*]?[%2B]?[%2F]?)\s(-?\d+(?:\.\d+)?)") + +let GetOper op = + match op with + | "+" -> "%2B" + | "*" -> "*" + | "/" -> "%2F" + | "-" -> "-" + | _ -> "" + +let GiveRequest expression = async{ + + let client = new HttpClient() + let! response = client.GetAsync("http://localhost:51963?value=" + expression) |> Async.AwaitTask + let! content = response.Content.ReadAsStringAsync() |> Async.AwaitTask + let result = + match response.IsSuccessStatusCode with + |true -> Some(content) + |false -> None + return result + } + +let output (result : string option) = + match result with + | None -> Console.WriteLine("Bad Request") + | Some result -> Console.WriteLine(result) + +[] +let main argv = + let a = Console.ReadLine() + let op = GetOper(Console.ReadLine()) + let b = Console.ReadLine() + let expression = a + " " + op + " " + b; + let result = + match checkAccess expression with + | true -> Async.RunSynchronously(GiveRequest expression) |> Some + | false -> None + output result.Value + 0 \ No newline at end of file diff --git a/CalculatorASP/ProxyF/ProxyF.fsproj b/CalculatorASP/ProxyF/ProxyF.fsproj new file mode 100644 index 0000000..5e4d540 --- /dev/null +++ b/CalculatorASP/ProxyF/ProxyF.fsproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/CalculatorF/CalculatorF.sln b/CalculatorF/CalculatorF.sln deleted file mode 100644 index a66da7c..0000000 --- a/CalculatorF/CalculatorF.sln +++ /dev/null @@ -1,16 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "CalculatorF", "CalculatorF\CalculatorF.fsproj", "{A55ACE78-975B-4CCD-8176-33831A6D162F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A55ACE78-975B-4CCD-8176-33831A6D162F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A55ACE78-975B-4CCD-8176-33831A6D162F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A55ACE78-975B-4CCD-8176-33831A6D162F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A55ACE78-975B-4CCD-8176-33831A6D162F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/CalculatorF/Program.fs b/CalculatorF/Program.fs deleted file mode 100644 index aafce82..0000000 --- a/CalculatorF/Program.fs +++ /dev/null @@ -1,65 +0,0 @@ -open System -open System.Globalization - -type MaybeBuilder() = - member this.Bind(x, f) = - match x with - | None -> None - | Some a -> f a - - member this.Return(x) = - Some x - -let maybe = MaybeBuilder() - -let add x y = x + y - -let subtract x y = x - y - -let multiply x y = x * y - -let divide x y = maybe{ - let! x = match y with - | 0.0 -> None - | _ -> Some (x / y) - return x - } - -let calculate op x y = maybe{ - let! x = match op with - | "+" -> Some(add x y) - | "-" -> Some(subtract x y) - | "*" -> Some(multiply x y) - | "/" -> divide x y - | _ -> None - return x - } -let styles = NumberStyles.AllowDecimalPoint - -let provider = new CultureInfo("en-US") - -let output (result : float option) = - if - result = None then Console.WriteLine("Введено неверное число/оператор или попытка деления на нуль") - else - Console.WriteLine(result.Value) - -let getNumber (str:string) = maybe{ - let isNumber, number = Double.TryParse(str, styles, provider) - let! str = match isNumber with - | true -> Some(number) - | false -> None - return str - } - -[] -let main argv = - let a = getNumber(Console.ReadLine()) - let op = Console.ReadLine() - let b = getNumber(Console.ReadLine()) - if a = None || b = None then output None else - let result = calculate op a.Value b.Value - output result - 0 - - \ No newline at end of file diff --git a/Maldelbrot/Maldelbrot app/Form1.Designer.cs b/Maldelbrot/Maldelbrot app/Form1.Designer.cs new file mode 100644 index 0000000..6dd5626 --- /dev/null +++ b/Maldelbrot/Maldelbrot app/Form1.Designer.cs @@ -0,0 +1,83 @@ +namespace Maldelbrot_app +{ + 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.components = new System.ComponentModel.Container(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.button1 = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(37, 32); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(749, 631); + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(812, 32); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(121, 57); + this.button1.TabIndex = 1; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick_1); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(973, 687); + this.Controls.Add(this.button1); + this.Controls.Add(this.pictureBox1); + this.ForeColor = System.Drawing.SystemColors.ControlLightLight; + this.Name = "Form1"; + this.Text = "Form1"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Timer timer1; + } +} + diff --git a/Maldelbrot/Maldelbrot app/Form1.cs b/Maldelbrot/Maldelbrot app/Form1.cs new file mode 100644 index 0000000..fccf5d2 --- /dev/null +++ b/Maldelbrot/Maldelbrot app/Form1.cs @@ -0,0 +1,54 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace Maldelbrot_app +{ + public partial class Form1 : Form + { + private double _hx, _hy; + private Bitmap _bmp; + private double _sizeArea = 3; + private readonly double _zoom = 1.1; + + private void button1_Click(object sender, EventArgs e) + { + Draw(); + timer1.Start(); + } + + private void pictureBox1_MouseClick(object sender, MouseEventArgs e) + { + int X = e.X, + Y = e.Y; + switch (e.Button) + { + case MouseButtons.Left: + _hx = Fractal.temp(X, _hx, _sizeArea, pictureBox1.Width); + _hy = Fractal.temp(Y, _hy, _sizeArea, pictureBox1.Height); + Draw(); + break; + } + } + + private void timer1_Tick_1(object sender, EventArgs e) + { + _sizeArea /= _zoom; + Draw(); + } + + public Form1() + { + InitializeComponent(); + + _bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); + pictureBox1.Image = _bmp; + } + + private void Draw() + { + _bmp = Fractal.createImage(_sizeArea, pictureBox1.Height, pictureBox1.Width, _hx, _hy); + pictureBox1.Image = _bmp; + } + } +} diff --git a/Maldelbrot/Maldelbrot app/Form1.resx b/Maldelbrot/Maldelbrot app/Form1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Maldelbrot/Maldelbrot app/Form1.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/Maldelbrot/Maldelbrot app/Maldelbrot app.csproj b/Maldelbrot/Maldelbrot app/Maldelbrot app.csproj new file mode 100644 index 0000000..1d934a2 --- /dev/null +++ b/Maldelbrot/Maldelbrot app/Maldelbrot app.csproj @@ -0,0 +1,14 @@ + + + + WinExe + netcoreapp3.1 + Maldelbrot_app + true + + + + + + + \ No newline at end of file diff --git a/Maldelbrot/Maldelbrot app/Program.cs b/Maldelbrot/Maldelbrot app/Program.cs new file mode 100644 index 0000000..f1b7be8 --- /dev/null +++ b/Maldelbrot/Maldelbrot app/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Windows.Forms; + +namespace Maldelbrot_app +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Maldelbrot/MaldelbrotSet/Fractal.fs b/Maldelbrot/MaldelbrotSet/Fractal.fs new file mode 100644 index 0000000..dca2611 --- /dev/null +++ b/Maldelbrot/MaldelbrotSet/Fractal.fs @@ -0,0 +1,29 @@ +module Fractal +open System.Drawing +open System.Windows.Forms +open System.Numerics +open System +let temp c f size k = f - (size / 2.0) + (float c) * size / k + +let createImage sizeArea heigth wight hx hy = + let image = new Bitmap((int heigth), (int wight)) + for x in 0..image.Width-1 do + for y in 0..image.Height-1 do + let mutable x_ = temp x hx sizeArea wight + let mutable y_ = temp y hy sizeArea heigth + let mutable z = new Complex(0.0, 0.0) + let mutable it = 0 + let mutable Break = false + while (Break = false && it < 100) do + it <- it + 1 + z <- z*z + z <- z + new Complex(x_, y_) + if (z.Magnitude > 2.0) then Break <- true + else + image.SetPixel(x, y, Color.FromArgb(255, it % 8 * 16, it % 4 * 32, it % 2 * 64)) + image + + + + + diff --git a/Maldelbrot/MaldelbrotSet/Library.fs b/Maldelbrot/MaldelbrotSet/Library.fs new file mode 100644 index 0000000..55186ef --- /dev/null +++ b/Maldelbrot/MaldelbrotSet/Library.fs @@ -0,0 +1,44 @@ +module Fractal +open System.Windows.Forms +open System.Drawing +open System.Numerics + + +let cMax = Complex(1.0, 1.0) +let cMin = Complex (-1.0, -1.0) + +let compare (z: Complex) = cMin.Real < z.Real && z.Real < cMax.Real && cMin.Imaginary < z.Imaginary && z.Imaginary < cMax.Imaginary +let rec isInMandelbrotSet (z, c, iter, count) = + if (compare z) && (count < iter) then + isInMandelbrotSet ( ((z * z) + c), c, iter, (count + 1) ) + else count + +let scalingFactor s = s * 1.0 / 200.0 +let offsetX = -1.0 +let offsetY = -1.0 + +let mapPlane (x, y, s, mx, my) = + let fx = ((float x) * scalingFactor s) + mx + let fy = ((float y) * scalingFactor s) + my + Complex(fx, fy) + +let colorize c = + let r = (4 * c) % 255 + let g = (6 * c) % 255 + let b = (8 * c) % 255 + Color.FromArgb(r,g,b) + +let createImage (s, mx, my, iter) = + let image = new Bitmap(400, 400) + for x = 0 to image.Width - 1 do + for y = 0 to image.Height - 1 do + let count = isInMandelbrotSet( Complex.Zero, (mapPlane (x, y, s, mx, my)), iter, 0) + if count = iter then + image.SetPixel(x,y, Color.Black) + else + image.SetPixel(x,y, colorize( count ) ) + let temp = new Form() in + temp.Paint.Add(fun e -> e.Graphics.DrawImage(image, 0, 0)) + temp + +do Application.Run(createImage (1.5, -1.5, -1.5, 20)) \ No newline at end of file diff --git a/CalculatorF/CalculatorF.fsproj b/Maldelbrot/MaldelbrotSet/MaldelbrotSet.fsproj similarity index 56% rename from CalculatorF/CalculatorF.fsproj rename to Maldelbrot/MaldelbrotSet/MaldelbrotSet.fsproj index 05bd285..e9c243d 100644 --- a/CalculatorF/CalculatorF.fsproj +++ b/Maldelbrot/MaldelbrotSet/MaldelbrotSet.fsproj @@ -1,12 +1,13 @@ - + Exe netcoreapp3.1 + true - + diff --git a/Maldelbrot/Mandelbrot set.sln b/Maldelbrot/Mandelbrot set.sln new file mode 100644 index 0000000..28fab8c --- /dev/null +++ b/Maldelbrot/Mandelbrot set.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30523.141 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maldelbrot app", "Maldelbrot app\Maldelbrot app.csproj", "{0121F812-5AAA-4388-B6D7-2732FDC786AB}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MaldelbrotSet", "MaldelbrotSet\MaldelbrotSet.fsproj", "{A0A27C51-BE9C-4B74-95B0-112E666AD724}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0121F812-5AAA-4388-B6D7-2732FDC786AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0121F812-5AAA-4388-B6D7-2732FDC786AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0121F812-5AAA-4388-B6D7-2732FDC786AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0121F812-5AAA-4388-B6D7-2732FDC786AB}.Release|Any CPU.Build.0 = Release|Any CPU + {A0A27C51-BE9C-4B74-95B0-112E666AD724}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0A27C51-BE9C-4B74-95B0-112E666AD724}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0A27C51-BE9C-4B74-95B0-112E666AD724}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0A27C51-BE9C-4B74-95B0-112E666AD724}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DA678E87-B0D9-4E7E-BC56-F37F28A53035} + EndGlobalSection +EndGlobal