예제 #1
0
        protected override void SkiaRender()
        {
            var inputs = new SKRuntimeEffectInputs(_runtimeEffect);

            if (inputs.Contains("iTime"))
            {
                inputs.Set("iTime", (float)_st.Elapsed.TotalSeconds * 5);
            }
            if (inputs.Contains("iResolution"))
            {
                inputs.Set("iResolution", new float[]
                {
                    Size.X,
                    Size.Y,
                    0
                });
            }

            using (var shader = _runtimeEffect.ToShader(inputs, false))
                using (var paint = new SKPaint
                {
                    Shader = shader
                })
                {
                    Canvas.Save();

                    //Canvas.Translate(MousePosition.X, Size.Y - MousePosition.Y);
                    //Canvas.DrawCircle(0, 0, 50, paint);
                    //Canvas.DrawCircle(MousePosition.X,Size.Y - MousePosition.Y, 50, paint);
                    //Canvas.Restore();
                    Canvas.DrawRect(0, 0, Size.X, Size.Y, paint);

                    /*
                     * Canvas.DrawRect(0, 0, Size.X/3, Size.Y, paint);
                     * Canvas.DrawRect(Size.X/3*2, 0, Size.X/3, Size.Y, paint);*/
                }
        }
예제 #2
0
            public void Test(SKSurface surface, SKImageInfo info, SKColor[] expected, Action <SKCanvas, SKPaint> preTestCallback = null)
            {
                using var shader = effect.ToShader(false, uniforms, children);
                Assert.NotNull(shader);

                using var paint = new SKPaint
                      {
                          Shader    = shader,
                          BlendMode = SKBlendMode.Src
                      };

                preTestCallback?.Invoke(surface.Canvas, paint);

                surface.Canvas.DrawPaint(paint);

                var actual = new SKColor[4];

                fixed(void *a = actual)
                {
                    Assert.True(surface.ReadPixels(info, (IntPtr)a, info.RowBytes, 0, 0));
                }

                Assert.Equal(expected, actual);
            }