From a32fa6b1ea821aff810eeb7fe9aeed33dc7ed378 Mon Sep 17 00:00:00 2001 From: NyuwBot Date: Mon, 1 Jan 2024 05:16:10 +0100 Subject: [PATCH] away with this --- DisCatSharp/Ascii/AsciiArt.cs | 7 ---- DisCatSharp/Ascii/Generator.cs | 40 ---------------------- DisCatSharp/Ascii/IImageSource.cs | 14 -------- DisCatSharp/Ascii/ImageSharpImageSource.cs | 31 ----------------- DisCatSharp/Ascii/Rgb.cs | 7 ---- DisCatSharp/DisCatSharp.csproj | 1 - 6 files changed, 100 deletions(-) delete mode 100644 DisCatSharp/Ascii/AsciiArt.cs delete mode 100644 DisCatSharp/Ascii/Generator.cs delete mode 100644 DisCatSharp/Ascii/IImageSource.cs delete mode 100644 DisCatSharp/Ascii/ImageSharpImageSource.cs delete mode 100644 DisCatSharp/Ascii/Rgb.cs diff --git a/DisCatSharp/Ascii/AsciiArt.cs b/DisCatSharp/Ascii/AsciiArt.cs deleted file mode 100644 index 6f6edcb37..000000000 --- a/DisCatSharp/Ascii/AsciiArt.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DisCatSharp.Ascii; - -internal sealed record AsciiArt( - string Art, - int Width, - int Height -); diff --git a/DisCatSharp/Ascii/Generator.cs b/DisCatSharp/Ascii/Generator.cs deleted file mode 100644 index 1e99ddb9f..000000000 --- a/DisCatSharp/Ascii/Generator.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Text; - -namespace DisCatSharp.Ascii; - -internal sealed class Generator -{ - public AsciiArt GenerateAsciiArtFromImage( - IImageSource image - ) - { - var asciiChars = "@%#*+=-:,. "; - - var aspect = image.Width / (double)image.Height; - var outputWidth = image.Width / 16; - var widthStep = image.Width / outputWidth; - var outputHeight = (int)(outputWidth / aspect); - var heightStep = image.Height / outputHeight; - - StringBuilder asciiBuilder = new(outputWidth * outputHeight); - for (var h = 0; h < image.Height; h += heightStep) - { - for (var w = 0; w < image.Width; w += widthStep) - { - var pixelColor = image.GetPixel(w, h); - var grayValue = (int)((pixelColor.Red * 0.3) + (pixelColor.Green * 0.59) + (pixelColor.Blue * 0.11)); - var asciiChar = asciiChars[grayValue * (asciiChars.Length - 1) / 255]; - asciiBuilder.Append(asciiChar); - asciiBuilder.Append(asciiChar); - } - - asciiBuilder.AppendLine(); - } - - AsciiArt art = new( - asciiBuilder.ToString(), - outputWidth, - outputHeight); - return art; - } -} diff --git a/DisCatSharp/Ascii/IImageSource.cs b/DisCatSharp/Ascii/IImageSource.cs deleted file mode 100644 index 90f1c80b7..000000000 --- a/DisCatSharp/Ascii/IImageSource.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace DisCatSharp.Ascii; - -internal interface IImageSource : IDisposable -{ - int Width { get; } - - int Height { get; } - - float AspectRatio { get; } - - Rgb GetPixel(int x, int y); -} diff --git a/DisCatSharp/Ascii/ImageSharpImageSource.cs b/DisCatSharp/Ascii/ImageSharpImageSource.cs deleted file mode 100644 index 2998fb655..000000000 --- a/DisCatSharp/Ascii/ImageSharpImageSource.cs +++ /dev/null @@ -1,31 +0,0 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; - -namespace DisCatSharp.Ascii; - -internal sealed class ImageSharpImageSource : IImageSource -{ - private readonly Image _image; - - public ImageSharpImageSource(Image image) - { - this._image = image; - } - - public int Width => this._image.Width; - - public int Height => this._image.Height; - - public float AspectRatio => this._image.Width / (float)this._image.Height; - - public Rgb GetPixel(int x, int y) - { - var pixel = this._image[x, y]; - return new( - pixel.R, - pixel.G, - pixel.B); - } - - public void Dispose() => this._image.Dispose(); -} diff --git a/DisCatSharp/Ascii/Rgb.cs b/DisCatSharp/Ascii/Rgb.cs deleted file mode 100644 index 445ab0145..000000000 --- a/DisCatSharp/Ascii/Rgb.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DisCatSharp.Ascii; - -internal record struct Rgb( - byte Red, - byte Green, - byte Blue -); diff --git a/DisCatSharp/DisCatSharp.csproj b/DisCatSharp/DisCatSharp.csproj index 02783d028..88e6a8796 100644 --- a/DisCatSharp/DisCatSharp.csproj +++ b/DisCatSharp/DisCatSharp.csproj @@ -42,7 +42,6 @@ -