Beispiel #1
0
        public override IRender Render(float dt)
        {
            var chromas = _featureCache.GetChromas();

            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                for (int i = 0; i < NumBars; i++)
                {
                    if (chromas[i] >= _threshold)
                    {
                        var paint = new SKPaint
                        {
                            IsAntialias = true,
                            Color       = _color.WithScale(chromas[i]),
                            Style       = SKPaintStyle.Fill
                        };

                        int x0 = i * _barSize;
                        canvas.DrawRect(x0, 0, _barSize, Height, paint);
                        paint.Dispose();
                    }
                }
            }

            return(_render);
        }
Beispiel #2
0
        public override IRender Render(float dt)
        {
            float barValue = 0;

            if (_featureCache.IsBeat())
            {
                _beatPeriod        = _featureCache.GetBeatPeriod();
                _remainingBeatTime = _beatPeriod;
            }
            else if (_remainingBeatTime > 0)
            {
                _remainingBeatTime = Math.Max(_remainingBeatTime - dt, 0);
                barValue           = (1f - _remainingBeatTime / _beatPeriod);
            }

            int barSize = (int)(Width / 2 * barValue);

            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                var paint = new SKPaint
                {
                    IsAntialias = true,
                    Color       = _color,
                    Style       = SKPaintStyle.Fill
                };

                canvas.DrawRect(Width / 2, 0, barSize, Height, paint);
                canvas.DrawRect(Width / 2 - barSize, 0, barSize, Height, paint);
                paint.Dispose();
            }

            return(_render);
        }
Beispiel #3
0
        /*	In this method you will be able to render your effect. It will be called for
         *      each frame of your project, assuming this layer is enabled. */
        public override IRender Render(float dt)
        {
            using (var canvas = _render.CreateCanvas())
                canvas.Clear(_color);

            return(_render);
        }
Beispiel #4
0
        private IRender RenderBlob()
        {
            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                float x = _xCenterPos;
                float y = Height / 2f;

                var paint = new SKPaint
                {
                    IsAntialias = true,
                    Style       = SKPaintStyle.Fill,
                    Shader      = SKShader.CreateRadialGradient(
                        new SKPoint(x, y),
                        _size, new[] { _color, SKColors.Black },
                        null, SKShaderTileMode.Clamp),
                };

                canvas.DrawOval(x, y, _size, _size, paint);
                paint.Dispose();
            }

            return(_render);
        }
Beispiel #5
0
        private IRender RenderBars()
        {
            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                lock (_barsLock)
                {
                    foreach (var bar in _bars)
                    {
                        float scale = bar.Life / bar.MaxLife;
                        float size  = (1 - scale) * bar.MaxSize;
                        float x     = bar.Position - size / 2f;

                        var paint = new SKPaint
                        {
                            IsAntialias = true,
                            Color       = bar.Color.WithScale(scale),
                            Style       = SKPaintStyle.Fill
                        };

                        canvas.DrawRect(x, 0, size, Height, paint);
                        paint.Dispose();
                    }
                }
            }

            return(_render);
        }
Beispiel #6
0
        public override IRender Render(float dt)
        {
            lock (_barsLock)
            {
                UpdateBars(dt);

                using (var canvas = _render.CreateCanvas())
                {
                    canvas.Clear();

                    for (int i = 0; i < _numBars; i++)
                    {
                        int   x0        = i * _barSize;
                        float intensity = 0;

                        if (_bars[i].MaxLife > 0)
                        {
                            intensity = _bars[i].Value / _bars[i].MaxLife;
                        }

                        var paint = new SKPaint
                        {
                            IsAntialias = true,
                            Color       = _bars[i].Color.WithScale(intensity),
                            Style       = SKPaintStyle.Fill
                        };

                        canvas.DrawRect(x0, 0, _barSize, Height, paint);
                        paint.Dispose();
                    }
                }
            }

            return(_render);
        }
Beispiel #7
0
        private IRender RenderBlobs()
        {
            float y = Height / 2f;

            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                lock (_blobsLock)
                {
                    foreach (var blob in _blobs)
                    {
                        float scale = blob.Life / blob.MaxLife;
                        float size  = (1 - scale) * blob.MaxSize;
                        float x     = blob.Position;

                        var paint = new SKPaint
                        {
                            IsAntialias = true,
                            Style       = SKPaintStyle.Fill,
                            Shader      = SKShader.CreateRadialGradient(
                                new SKPoint(x, y),
                                size,
                                new[] { blob.Color.WithScale(scale), SKColors.Black },
                                null, SKShaderTileMode.Clamp),
                        };

                        canvas.DrawOval(x, y, size, size, paint);
                        paint.Dispose();
                    }
                }
            }

            return(_render);
        }
Beispiel #8
0
        /*	In this method you will be able to render your effect. It will be called for
         *      each frame of your project, assuming this layer is enabled. */
        public override IRender Render(float dt)
        {
            /*  Map every pixel in the render to the configured color */
            using (var canvas = _render.CreateCanvas())
                canvas.Clear(_color);

            return(_render);
        }
Beispiel #9
0
        /*	In this method you will be able to render your effect. It will be called for
         *      each frame of your project, assuming this layer is enabled. */
        public override IRender Render(float dt)
        {
            /*  Create a new color on each beat. */
            if (_featureCache.IsBeat())
            {
                _color = _api.CreateRandomColor();
            }

            /*  Map every pixel in the render to the configured color */
            using (var canvas = _render.CreateCanvas())
                canvas.Clear(_color);

            return(_render);
        }
Beispiel #10
0
        public override IRender Render(float dt)
        {
            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                lock (_lock)
                {
                    UpdateAndRenderBlobs(dt, canvas);
                }
            }

            return(_render);
        }
Beispiel #11
0
        public override IRender Render(float dt)
        {
            if (_flashDuration > MaxFlashDuration)
            {
                _color = new SKColor(0, 0, 0);
            }
            else
            {
                _flashDuration += dt;
                _color          = _color.WithScale(1f - _flashDuration / MaxFlashDuration);
            }

            using (var canvas = _render.CreateCanvas())
                canvas.Clear(_color);

            return(_render);
        }
Beispiel #12
0
        public override IRender Render(float dt)
        {
            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                var paint = new SKPaint
                {
                    IsAntialias = true,
                    Color       = _color,
                    Style       = SKPaintStyle.Fill
                };

                canvas.DrawRect(0, 0, Width * _barValue, Height, paint);
                paint.Dispose();
            }

            return(_render);
        }
Beispiel #13
0
        public override IRender Render(float dt)
        {
            using (var canvas = _render.CreateCanvas())
                using (SKPaint paint = new SKPaint())
                {
                    canvas.Clear();

                    paint.IsAntialias = true;
                    paint.Shader      = SKShader.CreateRadialGradient(
                        new SKPoint(_x0Pos, _y0Pos),
                        0.5f * (_xSize + _ySize),
                        new[] { _color, SKColors.Black },
                        null,
                        SKShaderTileMode.Clamp);

                    canvas.DrawOval(_x0Pos, _y0Pos, _xSize, _ySize, paint);
                }

            return(_render);
        }
Beispiel #14
0
        private IRender RenderBar()
        {
            using (var canvas = _render.CreateCanvas())
            {
                canvas.Clear();

                var paint = new SKPaint
                {
                    IsAntialias = true,
                    Color       = _color,
                    Style       = SKPaintStyle.Fill
                };

                float xPos = _xCenterPos - _xSize / 2f;
                canvas.DrawRect(xPos, 0, _xSize, Height, paint);
                paint.Dispose();
            }

            return(_render);
        }