コード例 #1
0
        protected override void Render(RenderContext context)
        {
            var backBuffer  = context.BackBuffer;
            var height      = context.Height;
            var width       = context.Width;
            var waveForm    = PlayerService.GetWaveform(waveformLength.Value).Transform <float>(x => x > 1 ? 1 : x < -1 ? -1 : x);
            var xStep       = width / (double)waveForm.Length;
            var halfHeight  = height * 0.5d;
            var subLineStep = 1d / waveForm.Length;
            var pal         = palette.AsFrozen();

            for (var i = 1; i < waveForm.Length; ++i)
            {
                var x1     = (i - 1) * xStep;
                var x2     = i * xStep;
                var y1     = (halfHeight) * waveForm[i - 1];
                var y2     = (halfHeight) * waveForm[i];
                var sample = ((double)i / waveForm.Length + paletteOffset);
                backBuffer.DrawLineVector(new VectorD(x1, (height - halfHeight) - y1), new VectorD(x2, (height - halfHeight) - y2),
                                          (d, d1, position) => pal.GetColour(sample + position * subLineStep),
                                          width, height);
            }
        }