コード例 #1
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent != DrawEvent)
            {
                return(base.OnDraw(se, args));
            }

            //Sciter requires BGRA data, ensure you use the correct SKColorType `Bgra8888`!
            using (var bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Bgra8888, alphaType: SKAlphaType.Premul))
                using (var canvas = new SKCanvas(bitmap))
                    using (var paint = new SKPaint())
                    {
                        paint.IsAntialias = true;
                        canvas.Clear();

                        paint.Shader = SKShader.CreateRadialGradient(
                            new SKPoint(args.Area.Width / 2f, args.Area.Height / 2f),
                            30f,
                            new SKColor[] { SKColors.Black.WithAlpha(0), SKColors.Green, SKColors.Black.WithAlpha(0), SKColors.Red, SKColors.Black.WithAlpha(0), SKColors.Blue, SKColors.Black.WithAlpha(0) },
                            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(base.OnDraw(se, args));
        }
コード例 #2
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent != DrawEvent)
            {
                return(base.OnDraw(se, args));
            }

            //Sciter requires BGRA data, ensure you use the correct SKColorType `Bgra8888`!
            using (var bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Bgra8888, alphaType: SKAlphaType.Premul))
                using (var canvas = new SKCanvas(bitmap))
                    using (var paint = new SKPaint())
                    {
                        paint.IsAntialias = true;

                        canvas.Clear();

                        var colorArray = new SKColor[] { SKColor.Parse("#00FEB775"), SKColor.Parse("#FEB775") };

                        paint.Shader = SKShader.CreateLinearGradient(
                            new SKPoint(args.Area.Width / 2f, 0),
                            new SKPoint(args.Area.Width / 2f, args.Area.Height),
                            colorArray,
                            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;
                    }

            return(base.OnDraw(se, args));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent != DrawEvent)
            {
                return(base.OnDraw(se, args));
            }

            //Sciter requires BGRA data, ensure you use the correct SKColorType `Bgra8888`!
            using (var bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Bgra8888, alphaType: SKAlphaType.Premul))
                using (var canvas = new SKCanvas(bitmap: bitmap))
                {
                    canvas.Clear(color: SKColor.Parse("#595F44").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));
        }
コード例 #6
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent != DrawEvent.Foreground)
            {
                return(false);
            }

            //Sciter requires BGRA data, ensure you use the correct SKColorType `Bgra8888`!
            using (var bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Bgra8888, alphaType: SKAlphaType.Premul))
                using (var canvas = new SKCanvas(bitmap))
                    using (var paint = new SKPaint())
                    {
                        canvas.Clear();

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

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

                        if (hasAltText)
                        {
                            var 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);
        }
コード例 #7
0
        protected override bool OnDraw(SciterElement se, DrawArgs args)
        {
            if (args.DrawEvent != DrawEvent.Background)
                return base.OnDraw(se, args);

            //Sciter requires BGRA data, ensure you use the correct SKColorType `Bgra8888`!
            using (var bitmap = new SKBitmap(width: args.Area.Width, height: args.Area.Height, colorType: SKColorType.Bgra8888, alphaType: SKAlphaType.Premul))
            using (var canvas = new SKCanvas(bitmap))
            using (var 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);
        }