public static void DrawBackground(SKCanvas c, BaseIcon icon) { using (var path = new SKPath { FillType = SKPathFillType.EvenOdd }) { path.MoveTo(0, icon.Height); path.LineTo(0, icon.Height - 75); path.LineTo(icon.Width, icon.Height - 85); path.LineTo(icon.Width, icon.Height); path.Close(); using (var shadow = SKImageFilter.CreateDropShadow(0, -3, 5, 5, SKColors.Black)) using (var paint = new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true, Color = icon.RarityColors[0], ImageFilter = shadow }) c.DrawPath(path, paint); } using (var path = new SKPath { FillType = SKPathFillType.EvenOdd }) { path.MoveTo(0, icon.Height); path.LineTo(0, icon.Height - 65); path.LineTo(icon.Width, icon.Height - 75); path.LineTo(icon.Width, icon.Height); path.Close(); using (var paint = new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true, Color = new SKColor(30, 30, 30) }) c.DrawPath(path, paint); } }
public static void DrawDescription(SKCanvas c, BaseIcon icon) { string text = icon.Description; int lineCount = text.Split("\n").Length; if (string.IsNullOrEmpty(text)) { return; } SKPaint paint = new SKPaint { IsAntialias = true, FilterQuality = SKFilterQuality.High, TextSize = 13, Color = SKColors.White }; { float lineHeight = paint.TextSize * 1.2f; float height = lineCount * lineHeight; while (height > icon.Height - BOTTOM_TEXT_SIZE - 3 - STARTER_POSITION - NAME_TEXT_SIZE - 12) { paint.TextSize--; lineHeight = paint.TextSize * 1.2f; height = lineCount * lineHeight; } } ChicHelper.DrawCenteredMultilineText(c, text, 4, icon, SKTextAlign.Right, new SKRect(5, STARTER_POSITION + NAME_TEXT_SIZE, icon.Width - 5, icon.Height - BOTTOM_TEXT_SIZE - 3), paint); }
public static void DrawDisplayName(SKCanvas c, BaseIcon icon) { string text = icon.DisplayName; if (string.IsNullOrEmpty(text)) { return; } int x = 5; int y = STARTER_POSITION + NAME_TEXT_SIZE; using (var shadow = SKImageFilter.CreateDropShadow(0, 0, 5, 5, SKColors.Black)) using (var paint = new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true, Typeface = ChicTypefaces.BurbankBigCondensedBold, TextSize = NAME_TEXT_SIZE, ImageFilter = shadow, Color = SKColors.White }) { while (paint.TextSize > icon.Width - x * 5) { paint.TextSize--; } c.DrawText(text, x, y, paint); } }
public static void DrawRarity(SKCanvas c, BaseIcon icon) { if (icon.RarityBackgroundImage != null) { int size = Math.Max(icon.Height, icon.Width); int x = (icon.Width - size) / 2; int y = (icon.Height - size) / 2; using (var paint = new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true }) c.DrawBitmap(icon.RarityBackgroundImage, new SKRect(x, y, size, size)); } else { using (var shader = SKShader.CreateRadialGradient( new SKPoint(icon.Width / 2, icon.Height / 2), icon.Height / 5 * 4, new SKColor[] { new SKColor(30, 30, 30), new SKColor(50, 50, 50) }, SKShaderTileMode.Clamp)) using (var paint = new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true, Shader = shader }) c.DrawRect(0, 0, icon.Width, icon.Height, paint); } }
public static void DrawPreviewImage(SKCanvas c, BaseIcon icon) { int x = (icon.Width - icon.Height) / 2; int y = 0; using (var shadow = SKImageFilter.CreateDropShadow(0, 0, 5, 5, SKColors.Black)) using (var paint = new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true, ImageFilter = shadow }) c.DrawBitmap(icon.IconImage, new SKRect(x, y, x + icon.Height, y + icon.Height), paint); }
public static void DrawToBottom(SKCanvas c, BaseIcon icon, SKTextAlign align, string text) { if (string.IsNullOrEmpty(text)) { return; } using (var paint = new SKPaint { FilterQuality = SKFilterQuality.High, IsAntialias = true, Typeface = ChicTypefaces.BurbankBigRegularBlack, TextSize = BOTTOM_TEXT_SIZE, TextAlign = align, Color = SKColors.White }) if (align == SKTextAlign.Left) { c.DrawText(text, 5, icon.Height - 7, paint); } else { c.DrawText(text, icon.Width - 5, icon.Height - 7, paint); } }
public static void GetRarityColors(BaseIcon icon, string rarity) { switch (rarity) { case "EFortRarity::Common": case "EFortRarity::Handmade": default: icon.RarityColors = new SKColor[2] { SKColor.Parse("6D6D6D"), SKColor.Parse("333333") }; break; case "EFortRarity::Uncommon": icon.RarityColors = new SKColor[2] { SKColor.Parse("5EBC36"), SKColor.Parse("305C15") }; break; case "EFortRarity::Rare": case "EFortRarity::Sturdy": icon.RarityColors = new SKColor[2] { SKColor.Parse("3669BB"), SKColor.Parse("133254") }; break; case "EFortRarity::Epic": case "EFortRarity::Quality": icon.RarityColors = new SKColor[2] { SKColor.Parse("8138C2"), SKColor.Parse("35155C") }; break; case "EFortRarity::Legendary": case "EFortRarity::Fine": icon.RarityColors = new SKColor[2] { SKColor.Parse("C06A38"), SKColor.Parse("5C2814") }; break; } }
public static SKBitmap DrawIcon(BaseIcon icon) { var ret = new SKBitmap(icon.Width, icon.Height, SKColorType.Rgba8888, SKAlphaType.Premul); using (var c = new SKCanvas(ret)) { ChicRarity.DrawRarity(c, icon); ChicWatermark.DrawChicFace(c, SKColors.White, icon.Width - 116); ChicImage.DrawPreviewImage(c, icon); ChicText.DrawBackground(c, icon); ChicText.DrawDisplayName(c, icon); ChicText.DrawDescription(c, icon); if (!(icon.ShortDescription == icon.DisplayName) && !(icon.ShortDescription == icon.Description)) { ChicText.DrawToBottom(c, icon, SKTextAlign.Left, icon.ShortDescription); } /*string sourceText = icon.CosmeticSource switch * { * "ItemShop" => "Item Shop", * "Granted.Founders" => "Founder's Pack", * _ => icon.CosmeticSource * }; * * if (sourceText.Contains("BattlePass.Paid")) * { * string season = sourceText.Replace("Season", "").Replace(".BattlePass.Paid", ""); * season = season == "10" ? "X" : season; * * sourceText = $"Season {season} Battle Pass"; * } * * ChicText.DrawToBottom(c, icon, SKTextAlign.Right, sourceText);*/ } return(ret); }
public static void DrawCenteredMultilineText(SKCanvas canvas, string text, int maxLineCount, BaseIcon icon, SKTextAlign side, SKRect area, SKPaint paint) => DrawCenteredMultilineText(canvas, text, maxLineCount, icon.Width, 5, side, area, paint);