Ejemplo n.º 1
0
        public IActionResult Rectangle(int width, int height, string bgColor, string fgColor, string text = null, int?textSize = null)
        {
            if (width * height > _options.MaxSize)
            {
                return(UnprocessableEntity());
            }

            if (width <= 0 || height <= 0 ||
                !SKColor.TryParse(bgColor ?? _options.BackgroundColor, out var skBgColor) ||
                !SKColor.TryParse(fgColor ?? _options.ForegroundColor, out var skFgColor))
            {
                return(BadRequest());
            }

            var image = Draw.Steps(
                Draw.BackgroundColor(skBgColor),
                Draw.CenteredText(text ?? $"{width}×{height}", textSize ?? _options.TextSize, skFgColor));

            return(new ImageResult(width, height, image));
        }