Example #1
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);
            }
        }
Example #2
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);
        }