From ec6be8014335825349c4fc5d99c361f3c26349d7 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Sun, 23 Jul 2023 19:29:47 -0400 Subject: [PATCH] do memegen-style text better. also fix indentation --- Program.cs | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Program.cs b/Program.cs index 0a472c2..ced04e4 100644 --- a/Program.cs +++ b/Program.cs @@ -166,19 +166,26 @@ public class Photo { } public Texture Texture() { - if (texture == placeholder && image != null) { - IPath yourPolygon = new Star(x: 2000.0f, y: 1000.0f, prongs: 5, innerRadii: 20.0f, outerRadii: 50.0f, angle: Util.PI); - image.Mutate(x => x.Fill(Color.White, yourPolygon)); - Font font = SystemFonts.CreateFont("Consolas", 120); - string text = "oh no i made a memegen"; - image.Mutate(x => x.DrawText(text, font, Color.White, new PointF(800, 10))); - Console.WriteLine("making texture for " + file); - texture = new Texture(image); - image.Dispose(); - image = null; - } - return texture; - } + if (texture == placeholder && image != null) { + IPath yourPolygon = new Star(x: 2000.0f, y: 1000.0f, prongs: 5, innerRadii: 20.0f, outerRadii: 50.0f, angle: Util.PI); + image.Mutate(x => x.Fill(Color.White, yourPolygon)); + Font font = SystemFonts.CreateFont("Impact", 120); + TextOptions options = new(font) { + WrappingLength = image.Width, + HorizontalAlignment = HorizontalAlignment.Center, + Origin = new PointF(image.Width / 2, image.Height / 2 - 60), + }; + string text = "oh no i made a memegen"; + IBrush brush = Brushes.Solid(Color.White); + IPen pen = Pens.Solid(Color.Black, 2.5f); + image.Mutate(x => x.DrawText(options, text, brush, pen)); + Console.WriteLine("making texture for " + file); + texture = new Texture(image); + image.Dispose(); + image = null; + } + return texture; + } } public class Texture : IDisposable {