Mirror of
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: primary color

+10 -5
+1
README.md
··· 4 4 5 5 - **text**: Configure the text display in the middle of the image: [https://release-image-generator.trueberryless.org?text=2.0](https://release-image-generator.trueberryless.org?text=2.0), by default there is no text 6 6 - **width** & **height**: Configure the width and height of the image: [https://release-image-generator.trueberryless.org?width=1560&height=640](https://release-image-generator.trueberryless.org?width=1560&height=640) 7 + - **primaryColor**: Set the HEX value of the desired primary color (with or without the octothorpe); example with pink: [https://release-image-generator.trueberryless.org/?text=1.0&primaryColor=#ffc0d2](https://release-image-generator.trueberryless.org/?text=1.0&primaryColor=#ffc0d2) 7 8 - **fontFamily** & **fontWeight**: Configure the font family and weight used: [https://release-image-generator.trueberryless.org?text=1.0&fontFamily=jetbrainsmono&fontWeight=bold](https://release-image-generator.trueberryless.org?text=1.0&fontFamily=jetbrainsmono&fontWeight=bold) 8 9 9 10 Family Options:
+2 -2
app/ReleaseImageGenerator.API/Program.cs
··· 19 19 app.UseHttpsRedirection(); 20 20 21 21 app.MapGet("/", 22 - (string? text, int? width, int? height, SupportedFontFamily? fontFamily, SupportedFontWeight? fontWeight) => 22 + (string? text, int? width, int? height, SupportedFontFamily? fontFamily, SupportedFontWeight? fontWeight, string? primaryColor) => 23 23 { 24 24 var options = new ImageGeneratorOptions(text, width ?? 1920, height ?? 1080, 25 - fontFamily ?? SupportedFontFamily.readexpro, fontWeight ?? SupportedFontWeight.bold); 25 + fontFamily ?? SupportedFontFamily.readexpro, fontWeight ?? SupportedFontWeight.bold, primaryColor); 26 26 var imageGenerator = new ImageGenerator(options); 27 27 return Results.File(imageGenerator.GenerateImage().ToArray(), "image/png"); 28 28 })
+6 -2
app/ReleaseImageGenerator.Domain/Implementations/ImageGenerator.cs
··· 11 11 public int Height { get; set; } 12 12 public SupportedFontFamily FontFamily { get; set; } 13 13 public SupportedFontWeight FontWeight { get; set; } 14 + public string? PrimaryColor { get; set; } 14 15 15 16 public ImageGenerator(ImageGeneratorOptions options) 16 17 { ··· 19 20 Height = options.height; 20 21 FontFamily = options.fontFamily; 21 22 FontWeight = options.fontWeight; 23 + PrimaryColor = options.primaryColor; 22 24 } 23 25 24 26 public MemoryStream GenerateImage() ··· 27 29 var canvas = surface.Canvas; 28 30 var random = new Random(); 29 31 30 - var primaryColor = ColorGenerator.GetRandomColor(ColorGenerator.ColorLimitation.NEUTRAL_LIGHTNESS, 31 - ColorGenerator.ColorLimitation.NEUTRAL_SATURATION); 32 + var primaryColor = PrimaryColor != null 33 + ? new Unicolour(PrimaryColor) 34 + : ColorGenerator.GetRandomColor(ColorGenerator.ColorLimitation.NEUTRAL_LIGHTNESS, 35 + ColorGenerator.ColorLimitation.NEUTRAL_SATURATION); 32 36 BackgroundGenerator.GenerateBackground(canvas, Width, Height, random, primaryColor); 33 37 PatternGenerator.GeneratePattern(canvas, Width, Height, random, primaryColor); 34 38 NoiseGenerator.GenerateNoise(canvas, Width, Height, random);
+1 -1
app/ReleaseImageGenerator.Domain/Implementations/ImageGeneratorOptions.cs
··· 1 1 namespace ReleaseImageGenerator.Domain.Implementations; 2 2 3 - public record ImageGeneratorOptions(string? text, int width, int height, SupportedFontFamily fontFamily, SupportedFontWeight fontWeight); 3 + public record ImageGeneratorOptions(string? text, int width, int height, SupportedFontFamily fontFamily, SupportedFontWeight fontWeight, string? primaryColor); 4 4 5 5 public enum SupportedFontFamily 6 6 {