protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent == _drawEvent)
            {
                using (SKBitmap bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Rgba8888, alphaType: SKAlphaType.Premul))
                    using (SKCanvas canvas = new SKCanvas(bitmap))
                        using (SKPaint paint = new SKPaint())
                        {
                            paint.IsAntialias = true;
                            canvas.Clear();

                            paint.Shader = SKShader.CreateRadialGradient(
                                new SKPoint(args.Area.Width / 2f, args.Area.Height / 2f),
                                Math.Max(args.Area.Width, args.Area.Height) / 10f,
                                new SKColor[] { SKColor.Parse("#77FFFFFF"), SKColor.Parse("#33FFFFFF"), SKColor.Parse("#00000000") },
                                null,
                                SKShaderTileMode.Mirror);

                            canvas.DrawRect(new SKRect(0, 0, args.Area.Width, args.Area.Height), paint);

                            var img = bitmap.ToSciterImage();
                            var gfx = SciterGraphics.Create(args.Handle);
                            gfx.BlendImage(img, args.Area.Left, args.Area.Top);

                            //return true;
                        }
            }

            return(base.OnDraw(se, args));
        }
Exemple #2
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent == DrawEvent.Content)
            {
                using (var graphics = SciterGraphics.Create(args.Handle))
                {
                    graphics.SaveState()
                    .Translate(args.Area.Left, args.Area.Top)
                    .SetLineColor(SciterColor.Create(0, 255, 255, .75f))
                    .SetFillColor(SciterColor.Create(127, 78, 194, .75f))
                    .SetLineWidth(4)
                    .DrawPolygon(
                        PolygonPoint.Create(51.0f, 58.0f),
                        PolygonPoint.Create(70.0f, 28.0f),
                        PolygonPoint.Create(48.0f, 1.0f),
                        PolygonPoint.Create(15.0f, 14.0f),
                        PolygonPoint.Create(17.0f, 49.0f)
                        )
                    .DrawEllipse(200, 50, 50, 50)
                    .RestoreState();
                }

                return(true);
            }
            return(false);
        }
Exemple #3
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent != DrawEvent.Content)
            {
                return(false);
            }

            var txt = SciterText.CreateForElement("hi", se);

            using (var g = SciterGraphics.Create(args.Handle))
            {
                g.DrawText(txt, 0, 0, 1);
            }

            return(true);
        }
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent == _drawEvent)
            {
                using (var bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Rgba8888, alphaType: SKAlphaType.Premul))
                    using (var canvas = new SKCanvas(bitmap: bitmap))
                    {
                        canvas.Clear(color: SKColor.Parse("#445F59").WithAlpha(255));

                        var img = bitmap.ToSciterImage();
                        var gfx = SciterGraphics.Create(args.Handle);
                        gfx.BlendImage(img, args.Area.Left, args.Area.Top);
                    }
            }

            return(base.OnDraw(se, args));
        }
Exemple #5
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent == DrawEvent.Content)
            {
                using (var graphics = SciterGraphics.Create(args.Handle))
                {
                    graphics
                    .SaveState()
                    .Translate(args.Area.Left, args.Area.Top)
                    .SetLineColor(0, 255, 255, .75f)
                    .SetFillColor(127, 78, 194, .75f)
                    .SetLineWidth(4)
                    .DrawPolygon(
                        PolygonPoint.Create(51.0f, 58.0f),
                        PolygonPoint.Create(70.0f, 28.0f),
                        PolygonPoint.Create(48.0f, 1.0f),
                        PolygonPoint.Create(15.0f, 14.0f),
                        PolygonPoint.Create(17.0f, 49.0f)
                        )
                    .SetLineWidth(2)
                    .SetLineColor(SciterColor.IndianRed)
                    .SetFillColor(SciterColor.CornflowerBlue)
                    .DrawRectangle(25, 125, 75, 175)
                    .SetLineColor(SciterColor.Goldenrod)
                    .DrawLine(50, 125, 50, 175)
                    .DrawLine(25, 150, 75, 150)

                    .SetLineWidth(0)
                    .SetLineColor(127, 78, 194, .75f)
                    .SetFillColor(0, 255, 255, .75f)
                    .DrawEllipse(200, 50, 50, 50)
                    .SetFillColor(127, 78, 194, .75f)
                    .DrawEllipse(225, 100, 50, 50)
                    .SetFillColor(255, 0, 0, 127)
                    .DrawEllipse(175, 100, 50, 50)

                    .RestoreState();
                }

                return(true);
            }
            return(false);
        }
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent == DrawEvent.Foreground)
            {
                using (SKBitmap bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Rgba8888, alphaType: SKAlphaType.Premul))
                    using (SKCanvas canvas = new SKCanvas(bitmap))
                        using (SKPaint paint = new SKPaint())
                        {
                            canvas.Clear();

                            paint.IsAntialias = true;
                            paint.TextSize    = 14f;

                            var hasAltText = se.Attributes.TryGetValue("alt", out var altText);

                            if (hasAltText)
                            {
                                SKRect textBounds = new SKRect();
                                paint.MeasureText(altText, ref textBounds);

                                paint.Color = new SKColor(0, 0, 0, 127);
                                canvas.DrawRect(bitmap.Width, bitmap.Height, -(textBounds.Width + 10),
                                                -(textBounds.Height + 10), paint);

                                paint.Color     = new SKColor(255, 255, 255);
                                paint.TextAlign = SKTextAlign.Right;
                                canvas.DrawText(altText, bitmap.Width - 5, bitmap.Height - 5, paint);
                            }

                            var img = bitmap.ToSciterImage();
                            var gfx = SciterGraphics.Create(args.Handle);
                            gfx.BlendImage(img, args.Area.Left, args.Area.Top);
                        }
            }

            // Resume normal drawing
            return(false);
        }
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent == DrawEvent.Background)
            {
                using (SKBitmap bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Rgba8888, alphaType: SKAlphaType.Premul))
                    using (SKCanvas canvas = new SKCanvas(bitmap))
                        using (SKPaint paint = new SKPaint())
                        {
                            paint.IsAntialias = true;

                            canvas.Clear();

                            paint.Shader = SKShader.CreateLinearGradient(
                                //new SKPoint(prms.area.Width / 2f, prms.area.Height / 2f),
                                new SKPoint(0, 0),
                                new SKPoint(args.Area.Width, args.Area.Height),
                                //Math.Max(prms.area.Width, prms.area.Height) / 10f,
                                new SKColor[] { SKColor.Parse("#FF75B7FE"), SKColor.Parse("#00000000") },
                                null,
                                SKShaderTileMode.Clamp);

                            canvas.DrawRect(new SKRect(0, 0, args.Area.Width, args.Area.Height), paint);

                            var img = bitmap.ToSciterImage();
                            var gfx = SciterGraphics.Create(args.Handle);
                            gfx.BlendImage(img, args.Area.Left, args.Area.Top);
                            //return true;
                        }

                //// set up drawing tools
                //using (var paint = new SKPaint())
                //{
                //    paint.IsAntialias = true;
                //    paint.Color = new SKColor(127, 78, 194, 50);
                //    paint.StrokeCap = SKStrokeCap.Round;

                //    // create the Xamagon path
                //    using (var path = new SKPath())
                //    {
                //        path.MoveTo(71.4311121f, 56f);
                //        path.CubicTo(68.6763107f, 56.0058575f, 65.9796704f, 57.5737917f, 64.5928855f, 59.965729f);
                //        path.LineTo(43.0238921f, 97.5342563f);
                //        path.CubicTo(41.6587026f, 99.9325978f, 41.6587026f, 103.067402f, 43.0238921f, 105.465744f);
                //        path.LineTo(64.5928855f, 143.034271f);
                //        path.CubicTo(65.9798162f, 145.426228f, 68.6763107f, 146.994582f, 71.4311121f, 147f);
                //        path.LineTo(114.568946f, 147f);
                //        path.CubicTo(117.323748f, 146.994143f, 120.020241f, 145.426228f, 121.407172f, 143.034271f);
                //        path.LineTo(142.976161f, 105.465744f);
                //        path.CubicTo(144.34135f, 103.067402f, 144.341209f, 99.9325978f, 142.976161f, 97.5342563f);
                //        path.LineTo(121.407172f, 59.965729f);
                //        path.CubicTo(120.020241f, 57.5737917f, 117.323748f, 56.0054182f, 114.568946f, 56f);
                //        path.LineTo(71.4311121f, 56f);
                //        path.Close();

                //        // draw the Xamagon path
                //        canvas.DrawPath(path, paint);
                //    }

                //    paint.Color = new SKColor(255, 255, 255);
                //    paint.TextSize = 24f;
                //    canvas.DrawText("Hello from SkiaSharp", 0, 5 * b.Height / 6, paint);
                //}

                //var b = new Image(406, 400);
                //using (var g = System.Drawing.Graphics.FromImage(b))
                //{
                //	LinearGradientBrush linGrBrush = new LinearGradientBrush(
                //		new Point(0, 10),
                //		new Point(200, 10),
                //		Color.FromArgb(255, 255, 0, 0),   // Opaque red
                //		Color.FromArgb(255, 0, 0, 255));  // Opaque blue
                //	g.SmoothingMode = SmoothingMode.AntiAlias;
                //	g.FillEllipse(linGrBrush, 0, 30, 200, 100);
                //}
            }

            return(base.OnDraw(se, args));
        }