예제 #1
0
        public static void DrawToBottom(SKCanvas c, BaseIcon icon, SKTextAlign align, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            using (var paint = new SKPaint
            {
                IsAntialias = true,
                FilterQuality = SKFilterQuality.High,
                Typeface = ChicTypefaces.BurbankBigRegularBlack,
                TextSize = icon.Height * (align == SKTextAlign.Left ? BOTTOM_TEXT_SIZE_RATIO : ChicRatios.Get(30)),
                Color = SKColors.White,
                TextAlign = align
            })
            {
                var five = (int)(icon.Height * ChicRatios.Get(5));

                if (align == SKTextAlign.Left)
                {
                    c.DrawText(text, five, icon.Height - five, paint);
                }
                else
                {
                    c.DrawText(text, icon.Width - five - (int)(icon.Height * ChicRatios.Get(27.5f)), icon.Height - five, paint);
                }
            }
        }
예제 #2
0
        public static void DrawVbuck(SKCanvas c, BaseIcon icon)
        {
            var two       = (int)(icon.Height * ChicRatios.Get(2));
            var vbuckSize = (int)(icon.Height * ChicRatios.Get(27.5f));

            using (var paint = new SKPaint
            {
                IsAntialias = true,
                FilterQuality = SKFilterQuality.High,
            }) c.DrawBitmap(SKBitmap.Decode(Program.Root + "Resources/T-VBuck-128.png"),
                            new SKRect(icon.Width - vbuckSize - two, icon.Height - vbuckSize - two, icon.Width - two, icon.Height - two), paint);
        }
예제 #3
0
        public static void DrawBanner(SKCanvas c, BaseIcon icon)
        {
            var f  = (int)(ChicRatios.Get1024(50) * icon.Height);
            var tf = (int)(ChicRatios.Get1024(25) * icon.Height);
            var tt = (int)(ChicRatios.Get1024(23) * icon.Height);
            var t  = (int)(ChicRatios.Get1024(20) * icon.Height);
            var et = (int)(ChicRatios.Get1024(18) * icon.Height);
            var ft = (int)(ChicRatios.Get1024(15) * icon.Height);
            var tw = (int)(ChicRatios.Get1024(12) * icon.Height);
            var n  = (int)(ChicRatios.Get1024(9) * icon.Height);
            var s  = (int)(ChicRatios.Get1024(7) * icon.Height);

            using (var textPaint = new SKPaint
            {
                IsAntialias = true,
                FilterQuality = SKFilterQuality.High,
                Color = SKColors.White,
                Typeface = ChicTypefaces.BurbankBigRegularBlack,
                TextAlign = SKTextAlign.Left,
                TextSize = f
            })
            {
                int width = (int)textPaint.MeasureText(icon.Banner);

                using (var path = new SKPath())
                {
                    path.FillType = SKPathFillType.EvenOdd;

                    path.MoveTo(ft, ft);
                    path.LineTo(width + f, tw);
                    path.LineTo(width + tf, textPaint.TextSize + tt);
                    path.LineTo(t, textPaint.TextSize + et);
                    path.Close();

                    using (var filter = SKImageFilter.CreateDropShadow(0, 0, s, s, SKColors.Black))
                        c.DrawPath(path,
                                   new SKPaint
                        {
                            IsAntialias   = true,
                            FilterQuality = SKFilterQuality.High,
                            Color         = SKColor.Parse("#f5112c"),
                            ImageFilter   = filter
                        });
                }

                c.DrawText(icon.Banner, tf, textPaint.TextSize + n, textPaint);
            }
        }
예제 #4
0
        public static void DrawDisplayName(SKCanvas c, BaseIcon icon)
        {
            string text = icon.DisplayName;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            int x = (int)(icon.Height * ChicRatios.Get(5));
            int y = (int)(icon.Height * STARTER_POSITION_RATIO + icon.Height * NAME_TEXT_SIZE_RATIO);

            using (var namePaint = new SKPaint
            {
                IsAntialias = true,
                FilterQuality = SKFilterQuality.High,
                Typeface = ChicTypefaces.BurbankBigCondensedBold,
                TextSize = icon.Height * NAME_TEXT_SIZE_RATIO,
                Color = SKColors.White,
                //TextAlign = SKTextAlign.Left,
                ImageFilter = SKImageFilter.CreateDropShadow(0, 0, icon.Height * 0.009765625f, icon.Height * 0.009765625f, SKColors.Black)
            })
            {
                using (var paint = new SKPaint
                {
                    IsAntialias = true,
                    FilterQuality = SKFilterQuality.High,
                    Typeface = ChicTypefaces.BurbankBigCondensedBold,
                    TextSize = icon.Height * ChicRatios.Get(23),
                    Color = SKColors.White,
                    ImageFilter = SKImageFilter.CreateDropShadow(0, 0, icon.Height * ChicRatios.Get(5), icon.Height * ChicRatios.Get(5), SKColors.Black)
                })
                {
                    while (namePaint.MeasureText(icon.DisplayName) + paint.MeasureText(icon.BundleInfo) > icon.Width - x * 5)
                    {
                        namePaint.TextSize--;
                        if (paint.TextSize > icon.Height * ChicRatios.Get(20))
                        {
                            paint.TextSize--;
                        }
                    }
                }

                c.DrawText(text, x, y, namePaint);
            }
        }
예제 #5
0
        public static void DrawPreviewImage(SKCanvas c, BaseIcon icon)
        {
            int x = (icon.Width - icon.Height) / 2;
            int y = 0;

            /*Console.WriteLine(x);
             * Console.WriteLine(y);
             * Console.WriteLine(icon.IconImage.Width);
             * Console.WriteLine(icon.IconImage.Height);
             * Console.WriteLine(icon.Width);
             * Console.WriteLine(icon.Height);*/

            using (var filter = SKImageFilter.CreateDropShadow(0, 0, icon.Height * ChicRatios.Get(5), icon.Height * ChicRatios.Get(5), SKColors.Black))
                using (var paint = new SKPaint
                {
                    IsAntialias = true,
                    FilterQuality = SKFilterQuality.High,
                    ImageFilter = filter
                }) c.DrawBitmap(icon.IconImage, new SKRect(x, y, x + icon.Height, y + icon.Height), paint);
        }
예제 #6
0
        public static SKBitmap GenerateIcon(BaseIcon icon)
        {
            int h = (int)(ChicRatios.Get1024(100) * icon.Height);

            var bitmap = new SKBitmap(icon.Width + h, icon.Height + h);

            using (var bmp = new SKBitmap(icon.Width, icon.Height, SKColorType.Rgba8888, SKAlphaType.Premul))
            {
                using (var c = new SKCanvas(bmp))
                {
                    //#CE9BB5

                    //Background
                    ChicRarity.DrawRarity(c, icon);

                    //Draw item icon
                    ChicImage.DrawPreviewImage(c, icon);

                    //Draw Text Background
                    ChicText.DrawBackground(c, icon);
                    //Display Name
                    ChicText.DrawDisplayName(c, icon);
                    ChicText.DrawBundleInfo(c, icon);

                    if (!icon.ShortDescription.Equals(icon.DisplayName))
                    {
                        //Draw Item Type
                        ChicText.DrawToBottom(c, icon, SKTextAlign.Left, icon.ShortDescription.ToUpper());
                    }

                    ChicText.DrawVbuck(c, icon);

                    {
                        string priceText = icon.Price > 0 ? icon.Price.ToString("N0", CultureInfo.GetCultureInfo("en-US")) : "FREE";

                        ChicText.DrawToBottom(c, icon, SKTextAlign.Right, priceText);
                    }

                    //Watermark
                    //ChicWatermark.DrawWatermark(c, icon.Size, shadow: true); // watermark should only be applied on icons with width = 512
                    //ChicWatermark.DrawWatermark(c, icon, 18, "@ChicIsCoolio", 2);
                    //ChicWatermark.DrawChicFace(c, SKColors.White, icon.Size - 120);

                    //Shows the image
                    //ImageBoxVm.imageBoxViewModel.Set(ret, assetName);
                }

                using (var c = new SKCanvas(bitmap))
                {
                    int f = (int)(ChicRatios.Get1024(50) * icon.Height);
                    int t = (int)(ChicRatios.Get1024(20) * icon.Height);

                    using (var paint = new SKPaint
                    {
                        IsAntialias = true,
                        FilterQuality = SKFilterQuality.High,
                        ImageFilter = SKImageFilter.CreateDropShadow(0, 0, t, t, SKColors.Black)
                    }) c.DrawBitmap(bmp, f, f, paint);

                    if (icon.HasBanner)
                    {
                        ChicBanner.DrawBanner(c, icon);
                    }
                }
            }



            return(bitmap);
        }
예제 #7
0
        public static void DrawBackground(SKCanvas c, BaseIcon icon)
        {
            /*var pathTop = new SKPath { FillType = SKPathFillType.EvenOdd };
             * pathTop.MoveTo(icon.Margin, icon.Margin);
             * pathTop.LineTo(icon.Margin + icon.Width, icon.Margin);
             * pathTop.LineTo(icon.Margin + icon.Width, icon.Margin + 20);
             * pathTop.LineTo(icon.Margin, icon.Margin + 30);
             * pathTop.Close();
             * c.DrawPath(pathTop, new SKPaint
             * {
             *  IsAntialias = true,
             *  FilterQuality = SKFilterQuality.High,
             *  Color = new SKColor(30, 30, 30), //new SKColor(206, 155, 181),
             *  ImageFilter = SKImageFilter.CreateDropShadow(0, 3, 5, 5, SKColors.Black, null, new SKImageFilter.CropRect(SKRect.Create(icon.Margin, icon.Margin, icon.Width - icon.Margin, icon.Height - icon.Margin)))
             * });*/

            using (var rarityPath = new SKPath {
                FillType = SKPathFillType.EvenOdd
            })
            {
                rarityPath.MoveTo(0, icon.Height);
                rarityPath.LineTo(0, icon.Height - icon.Height * ChicRatios.Get(75));
                rarityPath.LineTo(icon.Width, icon.Height - icon.Height * ChicRatios.Get(85));
                rarityPath.LineTo(icon.Width, icon.Height);
                rarityPath.Close();

                SKColor rarityColor = icon.RarityColors[0];

                using (var filter = SKImageFilter.CreateDropShadow(0, -3, icon.Height * ChicRatios.Get(5), icon.Height * ChicRatios.Get(5), SKColors.Black))
                    using (var paint = new SKPaint
                    {
                        IsAntialias = true,
                        FilterQuality = SKFilterQuality.High,
                        Color = rarityColor,
                        ImageFilter = filter
                    }) c.DrawPath(rarityPath, paint);
            }

            using (var pathBottom = new SKPath {
                FillType = SKPathFillType.EvenOdd
            })
            {
                pathBottom.MoveTo(0, icon.Height);
                pathBottom.LineTo(0, icon.Height - icon.Height * ChicRatios.Get(65));
                pathBottom.LineTo(icon.Width, icon.Height - icon.Height * ChicRatios.Get(75));
                pathBottom.LineTo(icon.Width, icon.Height);
                pathBottom.Close();
                c.DrawPath(pathBottom, new SKPaint
                {
                    IsAntialias   = true,
                    FilterQuality = SKFilterQuality.High,
                    Color         = new SKColor(30, 30, 30)
                });
            }

            using (var pathBottomBottom = new SKPath {
                FillType = SKPathFillType.EvenOdd
            })
            {
                pathBottomBottom.MoveTo(0, icon.Height);
                pathBottomBottom.LineTo(0, icon.Height - icon.Height * ChicRatios.Get(22));
                pathBottomBottom.LineTo(icon.Width, icon.Height - icon.Height * ChicRatios.Get(32));
                pathBottomBottom.LineTo(icon.Width, icon.Height);
                pathBottomBottom.Close();
                c.DrawPath(pathBottomBottom, new SKPaint
                {
                    IsAntialias   = true,
                    FilterQuality = SKFilterQuality.High,
                    Color         = new SKColor(20, 20, 20)
                });
            }
        }