public void RegisterIcon(string name, string imageUrl, bool blackBg = false)
        {
            var si = new ScaledImage(new HTMLImageElement()
            {
                Src = imageUrl
            }, blackBg);

            itemImages.Add(name, si);
        }
Beispiel #2
0
        private void DrawImage(ScaledImage img, bool blackWhite)
        {
            if (img == null)
            {
                return;
            }
            ctx.Save();
            img.TargetSize = (int)Math.Round(boxScale * iconSize * 2);
            ctx.DrawImage(img.ScaledImg, 0, 0, 1.0, 1.0);

            ctx.Restore();
        }
Beispiel #3
0
        private void DrawButton(ScaledImage img, string borderColor, double alpha = 1, bool bw = false, bool whitebghide = false)
        {
            var drawBlack = img != null && img.BlackBackground;

            if (drawBlack)
            {
                DrawButtonFill("black");
            }
            else
            {
                if (!whitebghide)
                {
                    ctx.Save();
                    ctx.GlobalAlpha = (float)0.5;
                    DrawButtonFill("white");
                    ctx.GlobalAlpha = (float)1;
                    ctx.Restore();
                }
            }

            ctx.Save();

            ctx.Translate(iconMargin, iconMargin);
            ctx.Scale(iconSize, iconSize);

            ctx.GlobalAlpha = (float)alpha;
            DrawImage(img, bw);
            ctx.Restore();

            var bc = borderColor;

            if (bw && img != null)
            {
                ctx.Save();
                ctx.GlobalAlpha = 1;
                ctx.GlobalCompositeOperation = CanvasTypes.CanvasCompositeOperationType.Saturation;
                ctx.FillStyle = "white";
                ctx.RoundedRectPath(0, 0, 1, 1, 0.2);
                ctx.Fill();
                //ctx.FillRect(0, 0, 1, 1);
                ctx.Restore();
            }

            DrawButtonBorder(bc);
        }